Add hash to lift menu entry url - lift

I need something like this
def sitemap(): SiteMap = SiteMap( Menu.i("Home") / "index#myhash/subhash" )
The point is I need add hash to the menu url. So, the resulting url would be like this
Home .
Is there any way to do it? I need just a temporary solution, so, any idea/hack would help.
thank you

The answer I recieved in lift community mail list is that I can't add hash when using sitemap because (as I see) sitemap is intented to be a server side thing that will also catch/match different url locations and help to router them. And since hashes are never sent to server, SiteMap does not work with hashes at all.
To solve my problem I just built menu links myself (I just added html markup to the page). It was acceptable for my case. In more complicated situation one can use snippet (self-written) to generate the menu in preferable way.

Related

cgi page with #!/:0 at the end of URL

I am coding for a perl/cgi webpage. Can anyone explain what does this url mean?
http://www.example.com/cgi-bin/test.cgi#!/:0
What I am reading is starting from # sign, everything afterwards is an html item and it will not be sent to server. And, then I am confused. Thanks.
Update:
Seems the items at back of the URL is created explicitly by the cgi code itself. Thanks (or maybe sorry to) everyone who used brain cell on it.
It looks like an anchor (a reference to a part of the website). Please have a look here: http://en.wikipedia.org/wiki/HTML_element#Anchor (NB: this url contains an anchor, too)

History: avoiding hash ("#") character in URLs

We are using GWT and take advantage of History framework. Everything works fine in application, but some of our clients are trying to put hyperlinks to our application in their PowerPoint presentations. But there is known problem in PP2007 with hash signs ("#") in hyperlinks which makes them unusable.
So is there any way to change separator character used in URLs generated by GWT Hisory framework to something other than hash?
Or is it possible to intercept new URL generated by GWT history and modify it before browser's adress bar is updated with it?
I don't think you can/should change the hash sign. Mainly because this sign does not come from GWT but from HTTP specifications. You can read the part on hash fragments in this doc for a good explanation. The main point being that adding a # sign to a url will not cause a full browser refresh. This is why this sign is used for ajax and GWT's history.
If you still want to intercept new URLs, you should probably add a ValueChangeHandler to your History, and then use Window.Location.getHref() and Window.Location.assign() to change the URL. But that's like using History to do something it doesn't do, so you're better off implementing your own History management system.
See http://code.google.com/p/google-web-toolkit/issues/detail?id=7101 (there are links to sample code)
Basically, you can only do this in a browser that supports HTML5's pushState and onpopstate. This rules out Internet Explorer, and unfortunately those people using PowerPointer are likely to also use IE, so basically you're doomed.

Duplicate URLs in Zend

I am developing a ZF website: howtowritecitations (dot) com
and it has a TOS page:
howtowritecitations (dot) com/termsofservice
But what are these duplicate pages?
http://www.howtowritecitations.com/termsofservice/index
http://www.howtowritecitations.com/index.php/termsofservice
http://www.howtowritecitations.com/index.php/index/termsofservice
Where did they come from? Will this be a problem? I hope not. For example, when Google crawls the page, it will only find and index howtowritecitations (dot) com/termsofservice, right?
If it is a potential problem, show me in the right direction so I can try and solve it.
Someone suggested to start looking at getRequestUri() in routeShutdown() (or something similar)
to use preg_replace to remove index.php, in order to 301-redirect to the proper URL, but I lost here.
Thanks in advance for advice or comments
This is caused by the routes you have setup. By default, Zend Framework applications usually route like:
www.yoursite.com/:controller/:action/:param
Right now, your termsofservice controller located at www.yoursite.com/termsofservice when called will show the :index action by default when no action is specified without changing the URL. It is also perfectly valid to access it using www.yoursite.com/termsofservice/index.
In order to fix these, you need to setup custom routes where everything that matches www.yoursite.com/:controller/* will route to www.yoursite.com/:controller. That way Google will never get a chance to see an alternate URL to index.

How to show a User view in GWT app by typing in browser address bar

I have this gwt app which say, runs on http://mygwtapp.com/ (which is actually: http://mygwtapp.com/index.html)
The app host a database of users, queried by searching usernames using the search view and results are shown in the user results view. Pretty useful enough. However I need to bb add a way that user view can be viewed by just typing http://myapp.com/user123
I am thinking that the question I have here, the answer is a server side solution. However if there's a client side solution, please let me know.
One fellow here in StackOVerflow suggested that the format would be like this:
mygwtapp.com/index.html#user123
However the format is important to be like: http://myapp.com/user123
The 'something' in 'http://host/path#something' is a Fragment identifier. FIs have a specific feature: the page isn't reloaded if only FI part in URL changes, but they still take part in browser history.
FI's are a browser mechanism that GWT uses to create "pages", i.e. parts of GWT application that are bookmarkable and have history support.
You can try to use an URL without # (the FI separator), but then you will have a normal URL, that reloads the page with every change and it could not be (easily) a part of a normal GWT app.
mygwtapp.com/index.html#user123
That would be using the History mechanism (http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsHistory.html) which I would add is the recommended way of doing it.
However, if you insist on using something like http://myapp.com/user123, one of the possible ways is to have a servlet which accepts this request (you might have to switch to something like http://myapp.com/details?id=user123). The servlet will look up the DB and return your host html back. Before returning it will inject the required details as a Dictionary entry in the page (http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/i18n/client/Dictionary.html) On the client you can read this data and display on the UI

How should I use <a href> tag to access other templates in lift?

According the Lift wiki, I know the "View First" concept of Lift. That's very different from any framework I used. Take the basic JSP things as the example, I could write
Create a new post
in the page, and write the logic in a servlet. How can I do things like this with lift? I wrote the same tag in a template and when I accessed this page I got 404 error. But if I add a Menu to the SiteMap, things goes well. Is there any possible to make a link without making a new Menu? I am a beginner of Lift and Scala. Thanks in advance.
When everything is declared in your SiteMap, you can have Lift generate the links for you.
Yes, it is possible.
Just don't call LiftRules.setSiteMap at your boot class, then Lift will let you access every pages under your webapp/ directory. You could test your code in this mode.
But this will also lead to no access control, so be careful.
It is also possible to do what I think you asked, which is to make the link accessible, but not visible in the SiteMap (if you don't want the SiteMap at all, go with Brian's answer), with code like this:
SiteMap(Menu("PreClass") / "preClass" >> Hidden)
We prefer to leave the SiteMap enabled as tightly controlling access seems like a good idea in our case.