polymer starter kit open url with multi level path - polymer

In the starter-kit when I run using 'gulp serve' and enter an url with more than one level path for e.g. localhost:5000/register/user then it fails. It basically looks for elements.html in localhost:5000/register/elements/elements.html rather than localhost:5000/elements/elements.html.
However when I open the link by clicking from another page, it works. Any idea how to make this work when I enter the url ?

Solution 1:
Are you implementing your own logic for the register page? Or are you working off of a tutorial? Because that page does not exist in the default Polymer Starter Kit (PSK). Please add a comment to this answer.
If you have implemented a register page, edit app/elements/routing.html to define the routing rules for the page.
Solution 2:
Do you have the hashbang rule enabled still? When I run gulp serve and then click the Users nav menu item it takes me to http://localhost:5000/#!/users.
So if you still have the following rule enabled in routing.html:
// add #! before urls
page({
hashbang: true
});
Perhaps that is messing you up. Try setting hashbang to false.

Related

polymer / page.js change route in javascript without causing page refresh

I use Polymer starter kit to build my app. I removed the hashbang in the urls.
I am trying to build a login screen and after successful login, I want to change the page to default route. To do this, I have a listener in app.js for successful log in. On successful log in, I change the route which causes page refresh. I tried multiple options:
location = 'entireUrl'
location.pathname = '/route'
location = 'route'
All the options causes page refresh. Is there any way to code this without causing page refresh. Shouldn't page.js catch this and do the routing without page refresh?
For those looking for an answer, I fixed it by calling page.redirect('/route').
note: page.redirect will replace the browser history. If you want to retain browser history you can use page.show('/route')

Chrome Dev Editor's Sample Polymer App Displays Blank Window

The polymer app that is generated when "JavaScript Polymer custom element" is selected as the project type in Chrome Dev Editor's "New Project" dialog displays a blank screen when run.
Is this a bug or am I doing something wrong?
If it is a bug, then how would I get the polymer app to display something?
Judging by your description, it sounds like you are forgetting to refactor for CSP. Right click on your project name, and select Refactor for CSP. This will take a while, but when it's done, it will work.
Sorry for the delayed response.
Please try the up-to-date Chrome Dev Editor. It's possible that the mentioned template was broken and got fixed since you've submitted the question.
Also make sure that you either:
have index.html or demo.html selected when clicking the Run button; or
right-click on of them and select Run... from the context menu.
What might have happened is that you confused Polymer element with a Polymer app. The template that've you used generates an element. It also provides an example of the element's usage in form of demo.html, and a standard Polymer element description page (based on the core-component-page element that reads and displays elements properties from the metadata.html) in form of index.html. So you have to explicitly run one of those to see something. If you attempt to "run" the element itself (say, click the Run button with my-element.html selected), you will see a blank screen, just like with any other pure Polymer template, because there is no renderable HTML in there (it's called a template for a reason).
If you do indeed want a Polymer app, consider using JavaScript web app (using Polymer paper elements) or JavaScript Chrome app (using Polymer paper elements) project types.
Try at first, to run the bower update from your command line
bower install Polymer/core-elements --save
And you might also need to right click on your project directory from the right panel of chrome dev editor and select Refractor for CSP.
Possibly in the example app, the CDE project (bower.json level) was in a subdirectory of the directory that you imported into the editor. Try to import a level deeper instead.

Integrating a Back button

I have this theme http://themes.two2twelve.com/site/fluidapp/light/ installed on my website running wordpress. I converted the template to a wordpress theme by following the steps here: http://thethemefoundry.com/blog/html-wordpress/ and its all working fine.
However, I have now been given the crazy task to integrate a "Back button" function in it.
What they want is to have some sort of Back button functionality (or the browser one) so when they open Team and they press Back - they go back to Home. The template is basically one-paged, you can see so in the source code.
One way I can see this happening is if I make every page a different .php file, upload them to my theme folder and then just hyperlink them. like www.yoursite.com/team.php
Another possible way (I think) would be to create a page.php template file and then post the pages using wordpress. Question: How do I tell wordpress to use page.php as the page template file?
Can you think of another way to integrate this functionality? Thanks a lot in advance.
If it always is going to return the user to the startpage you could just use the home_url(); function.
Back
If you got more advance structure and you want the button to just redirect the user back one page, you should use javascript.
Back
page.php is the default template for wordpress pages. So if no other is selected in admin, page.php will be used.
If you're using javascript to load the new content, you could use javascript pushState()and popState() to log the stuff to new url's, and it gets added to the browser history. Here's an example.

Mediawiki open external links in a new window

I want to enable opening external links in a new window function in Mediawiki. I tried to modify the "LocalSettings.php" file according to the below instructions:
http://www.mediawiki.org/wiki/Manual:Opening_external_links_in_a_new_window
But I still couldn't get it working. When I looked up in the above link "Discussion" wiki page I found more informations which confused me. Any idea how to set this work in a simple and straightforward way?
If you want a few specific links to open in a new window:
You can use the LinkTarget extension. You can then surround the appropriate links with an HTML element with a class of your choosing and get the extension to handle them.
(tor's answer also had a relevant extension linked, but Wikia removed that extension and it probably will not be maintained).
If you want all external links to open in a new window:
MediaWiki already has a setting for it: $wgExternalLinkTarget.
Just add the following to your LocalSettings.php file:
$wgExternalLinkTarget = '_blank';
Do keep in mind that some internal links might not be identified as such, and therefore will open in a new window; one such example is an internal edit link created by using
[{{fullurl:Main Page|action=edit}}]
Link: $wgExternalLinkTarget on MediaWiki.org
I'm not sure if you want to open all external links in new windows (tabs) or only select links.
If it's the latter, then you can try our new window links extension. Not necessarily pretty, but will work if you only need a few links.
Now, if you want all external links to open up in new windows, you need to use the LinkerMakeExternalLink hook and modify the $attribs parameter to your liking.
Happy hacking!

How to link a relative html file in the scenario where user can call the files from the browser by adding a / at the end

(Sorry I am not able to frame question correctly.)
Following is the scenario.
I have 2 Html files.
File1.Html has
Click Me
File2.Html has
Click Me
Now when I open the file1.html in browser by typing following in browser.
http://Localhost/File1.html
The file1.html with a link is shown and when clicked it goes to
http://Localhost/File2.html
BUT
If I open the file1.html in browser by typing following in browser(note the / at the end).
http://Localhost/File1.html/
The file1.html with a link is shown and when clicked it goes to
http://Localhost/File1.html/File2.html
I know this is not a right way to do in browser but you cant stop user doing so.
The above example I have used just to simplify the issue. My real production issue issue is while using the MVC url are actually routed. So a user can legally use http://example.com/Employee Or http://example.com/Employee/ and due to this my jqGrid is not working.
Please guide me for a workaround.
UPDATE:
This works ok in IExplorer : wierd.
You want a link relative to the root. The following:
Click Me
(note the '/' at the start of the href) will link to http://Localhost/File1.html wherever the page containing the link is (so long as it's on the same host).
not relative to root i need it relative to parent
That's not possible. If you are using routed URIs there can be all sorts of /path/segments following the base name. The browser has no way of knowing what the real ‘parent’ is.
The usual solution is to use root-relative URIs as suggested by Joe. If you need to allow your application to be mounted at a configurable prefix under the root, that prefix will need to be copied out into the link.
Your question reminds me of a technique for search friendly URLs, implemented in PHP.
Things like:
http://localhost/index.php/2009/09/
It was described on Sitepoint.com The idea was that index.php could retrieve the trailing part of the URL from the web server and decide what to do with it. Including whether to deal with a final / or not.
It won't be relevant to html files (which could not, after all, retrieve the trailing part of a URL) but it might provide further ideas.