I want to make a APP based on Chrome offline to do local file write and read.
I tried to understand how the File System API work.
My question is where the "foo" path really is in windows 7?
HERE is the W3's documentary about the path.
I tried the example supplied by W3, and are there any other simple examples?
Any hint will be appreciated.
foo is a meta-variable, it's not an actual real thing, rather just something to use as a place-holder.
It's similar to things like /path/to/file which doesn't mean you need a literal hierarchy containing those directories, rather it means substitute in the real path to your file.
foo, bar, baz are all common, I also use xyzzy, plugh and twisty due to rather large amounts of my youth being wasted on text adventure games :-)
All that the W3C document is saying with a comment like:
Thus 'foo/./bar' is equivalent to 'foo/bar', and './foo' is equivalent to 'foo'.
is that ./ can be effectively removed from the path string if it's at the front or immediately following a /. This is true regardless of the actual path components you use in place of foo and bar.
foo and bar are typically used as placeholder terms when explaining something that relies on user defined names. It is used when the name can be something arbitrary.
Related
I cannot find an answer to this question. I guess it could be a general question that apply to all languages, but I am working in HTML right now.
So entering this:
foo
Will it look for a folder named "foo" or a file named "foo"?
If you're working on HTTP: No. It will ask the server for an HTTP resource called foo.
If you're dealing with file: URIs, then it will look for a file called foo … but a directory is just a special type of file.
Either way, it will only start to care about what type of resource it gets when it gets it (i.e. not at the time it asks for it).
I am using POEdit for translations in a web application.
However, when I start POEdit I can't find any sources when I run 'Catalog > Update from Sources'. I only have .CSHTML-Files where the texts need to be translated.
What I've already tried:
Set the source path in Catalog > Properties and the charset to
'UTF-8'.
Added additional keyword ("[[[w+]]]") for matching words in my files (the words to translate always have the following form: [[[wordToTranslate]]]
Added a cshtml-extractor (In File > Settings > Extractor). When I did this, the following error message appeared: "warning: unterminated string constant". Warning: ')' found where '}' was expected.
Browsing the web without finding any clue of how to include cshtml-files.
Any hints are appreciated.
Any solutions are MUCH appreciated. :-)
Added additional keyword ("[[[w+]]]") for matching words in my files
I don’t know why you assume the keyword values are regexes of all things; they are not. The GNU gettext manual makes it clear what “keyword” is in the gettext context: name of the function used to call gettext with translatable string literals as the argument.
Added a cshtml-extractor
You get errors coming from this, it would be reasonable to assume that’s the problem. Because you gloss over this crucial step and don’t reveal the details of how you configured it, it’s impossible to give you a concrete answer (not without a crystal ball, anyway).
So I can only make an educated guess: if you didn’t actually add a proper extractor that understands the syntax of the template language you use, and used some gross hack like using the Python parser, then that’s the cause of your errors, together with the use of keyword value that can’t possibly be valid.
In MediaWiki skin definitions, the BaseTemplate that gets extended has several attributes for creating links to other pages in the wiki, but I've got a situation where I need the path to the skin's directory, to pull some images used to create the UI. By default, that would just be /skins/mySkin/images/foo.png, by default but if someone changes the $wgStylePath variable, or renames the skin, that would be an issue. Is there an existing variable that has that URL build out, hidden somewhere in the BaseTemplate methods?
Yes, the SkinTemplate class, which contains the code to set up the template variables before executing the template, provides access to $wgStylePath via the 'stylepath' template variable.
When you subclass SkinTemplate to define your skin's main class, you are also expected to override the $stylename member variable, which specifies the subdirectory under which your skin's own stylesheets and images reside. (This would usually be the same as the name of your skin in lower case, but it doesn't have to be; it's perfectly fine to have, say, two related skins using images from the same directory.) This is also made available as a template variable, surprisingly named 'stylename'. So one way to specify an image path in your template would be something like:
<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/images/foo.png
Another way, (formerly) used e.g. by the Vector skin, is to use the getSkinStylePath() method from the Skin class (which is the superclass of SkinTemplate; it's kind of messy and tangled for historical reasons, but basically you can pretty much treat them as one class split into two files).
Update: As of MediaWiki 1.36, getSkinStylePath() has been deprecated. The recommended alternative, according to the release notes, is to "replace usages with the direct path to the resources."
To use it, you pass in the name of the file as a parameter, and the method automatically prepends $wgStylePath and $stylename to it (and appends $wgStyleVersion as a query string). Note that this is not a template method, so you have to escape and print the returned URL yourself:
<?php echo htmlspecialchars( $this->getSkin()->getSkinStylePath( 'images/foo.png' ) ) ?>
There's also a getCommonStylePath() method which does exactly the same thing, except that it uses the string "common" instead of $stylename.
Apparently this is the new way:
$this->getSkin()->getConfig()->get( 'StylePath' ) . '/SkinName/images/foo.png';
Source: https://phabricator.wikimedia.org/T270754
In MediaWiki, you can use a variable ("Magic Word") such as
{{PAGENAME}}
or
{{REVISIONDAY}}
to get specific information related to the current page being viewed. Is there a similar variable (or perhaps a different way) to get the current user who is logged in to the wiki, i.e. something like
{{USERNAME}}
context: Trying to use the #ask query in Semantic MediaWiki to narrow the list of resulting pages to show those only the user has created or edited:
{{#ask: [[Case Reflection:+]] [[Contributing User::{{USERNAME}}]]
| format=template
| template=Case Reflection Form Summary
| link=all
| sort=Last Edited
| order=DESC
| default=You have no case reflections related to this Case Study.}}
There are a bunch of extensions for that such as GetUserName, MyVariables, UserInfo. The whole concept of showing usernames is incompatible with page caching though (you need to parse the page again every time someone looks at it) so generally not a good idea.
I was just searching for the same thing, and looking to see if I could do it without extensions. It looks like there's a default feature that allows this, as long as you want it as part of writing a static version to a page, not to say "Hello, Username!" (That last case is why they have not implemented it as a standard variable, because it causes caching problems.)
Wikimedia feature request T14733 resolves with:
{{subst:REVISIONUSER}}
{{REVISIONUSER}} will dynamically show the last editor, which is usually not what you want. But if you want, for example, to make a template that includes the user's handle as part of some inserted text, this should do the job. I think in your example above,
[[Contributing User::{{subst:REVISIONUSER}}]]
(I'm not sure if Semantic Mediawiki will make you escape out the substitutions, but if it does, further instructions are at Manual:Substitution, Multilevel substitution section.)
I've been wondering this for a while now, but what is the best way to ensure that in a web app (RoR, Sinatra, PHP, anything) that when you are creating links (either generating with a method, or writing in by hand) that they go to the proper place whether you are on the root of a domain or not: http://www.example.com/ or http://www.example.com/this/is/where/the/app/is/
My thoughts are get the end-user to specify a document root somewhere in the config of your app, and use that, however I'm trying to think of a nice way to do it without the end-user having to configure anything.
Edit: By end-user, I mean the person setting up the application on a server.
Edit: I can use the beginning '/' to always get the link relative to the domain, but the problem is what if the app itself is not at the root, but some place like http://www.example.com/this/is/where/the/app/is/ so i want to say gen_link('/') and have it return /this/is/where/the/app/is/ or gen_link('/some/thing') and return /this/is/where/the/app/is/some/thing
How about trying to set the base element in the head of you html layout?
First, get the URL, eg. in a way Ilya suggests (if PHP is OK for you). After that you can use the base tag as follows:
<base href="<?= $full_site_url ?>" />
That will set the default URL for all the links and the browser will prepend it to every relative link on the page.
First of all you need to route all your urls through some kind of url re-writer function.
So you no longer do:
Foo
But instead something like:
Foo
All the web frameworks out there have a function like this. While they usually do all kinds of magic in there (to do with MVC controller paths and views and what not), at the end of the function (conceptually) they all prepend your url with a "root" (eg "/this/is/where/the/app/is/"), so as to allow you to create urls in your application that are independent of a hard-coded base path.
RoR uses a configuration directive called "relative_url_root".
Symfony (php) uses a configuration directive also called "relative_url_root".
CakePHP uses a configuration directive called "WEBROOT_DIR".
In cases where these frameworks are running on Apache, this value is often calculated dynamically (if you haven't set it explicitly). On other webservers the environment variables are often not available or are incorrect so this value cannot be determined consistently.
ilya's answer is a good one, but I think a simpler way to do this is just to precede all your links with a leading "/". This will ensure that they are always relative to the root of the domain:
Something <!-- Always links to www.domain.com/some/thing -->
Something <!-- Acutal destination depends current path -->
You can determine everything you need yourself, no need for configs.
Here’s a PHP example (let’s say index.php is your script name):
<?
$folder_on_server = substr ($_SERVER['PHP_SELF'], 0, strpos ($_SERVER['PHP_SELF'], '/index.php'));
$server_name = $_SERVER['SERVER_NAME'];
if (80 != $_SERVER['SERVER_PORT']) {
$server_name .= ':'. $_SERVER['SERVER_PORT'];
}
$full_site_url = 'http://'. $server_name . $folder_on_server;
?>
Now, you can always make a link like this:
Something
See also discussion in comments.