Redirect to another HAML page after clicking link - sinatra

After clicking a link, I want to redirect the user to another HAML view and send some local data along with it. How do I do this?

If I get your question right, you want to display a page with a link. If a user clicks the link he gets forwarded to the link target and you want to fetch information from the client when the request hits in.
If so, it depends what kind of information you want to send. If you have the information on server side when rendering the page, you would put them straight as query string parameters to the target url of the link, with HAML like this:
%a{ :href => "/target?var1=#{#var_x}&var2=#{#var_y}", :title => "your link" }
would become in HTML:
your link
If the user follows the link, you would fetch the information in your Sinatra route like this:
get "/target" do
puts params[:var1] # => value_x
puts params[:var2] # => value_y
end

Related

Redirect to page after successfully entering in information in Squarespace

I have a page in Squarespace that I only want viewable after someone inputs their contact information. For example, I would create a Form Block, and then direct them to the otherwise locked page so they can view for that session. But if they close the window, they would need to re-enter their information (Name + Email).
lets say the address to the otherwise unviewable page is www.website.com/access
Once the viewer puts in their Name + Email and hit submit, they can see the /access page. If they do that and say share the address with someone who has not entered in their information, then they would get the Form Block where they need to enter their information.
Is there a way to do this in Squarespace? Would that need to be done with some sort of PHP Session that can be injected into the header of the specific page?
Ideally it would be like if they could see the page which is normally hidden, but of course unless they are an admin, the page is not viewable to the public.
Squarespace doesn't support PHP since it uses JSON template, so you can't create a session there. Please refer to this page: https://support.squarespace.com/hc/en-us/articles/205815358-Custom-code-FAQ
The only option to achieve this will be to create a cookie via JS and redirect if there is no cookie. The page will be still accessible if you turnoff the JS.
Please have in mind that SquareSpace is very limited when it comes to this kind of changes.

Pass reference id from url bar to other internal pages

I am compiling a lead generation landing page and, in the form I have inserted a hidden field which collect whatever is written in the url bar after
"?rel=".
This is done in order to track where the leads come from (Facebook ads, direct linking etc).
To be more clear if this is the url: www.mywebsite.com/form.html?rel=fbads
the hidden field will be fill with "fbads" and this is working.
In the landing page I have a link to another page with more details and in this webpage I have the same form.
My idea is to run campaings on the first page with the rel link, but then if the user clicks on the link and go to the detailed page (and then compile the form from there), I am losing the rel field.
How can I pass the rel field to the url of the second page?
Thanks
You may refer the this stackoverflow page. Once the HTTP GET request comes, traverse in HTTP headers in your controller and look for Referer field but it is not always set and the client can change the header value. May be using google analytics is the better option.
If you just want to know that whether if they came to your form page from your landing page or not, you may add fix HTTP URL parameter prior to HTTP redirect.
If you save your rel in a variable, you can add it on your link to detailed page, for example in case of =fbads just once variable is set up, add it: <a href="http://myDetailedPage.com/detailed/?=<?php $rel;?>"</a>

Append Form text field value alone in the url

I am trying to create a sample Online shopping application using SPRING+REST. I have a 1000 of products and I would like to make use of #RequestMapping("watches/{id}") annotation . But i dont know how to send the id form field value alone while submitting a form in jsp.
I want something like this
www.example.com/watches/1001
Please help me out
I guess you will have some jsp page which consists of all watches. This web page can be access by localhost:8080/watches URL.
If user click on any watches, user will land to localhost:8080/watches/{watch-id} page as the click on watch will redirect the request.
If your JSP is form based page, then user need to enter the watch-id ( or watch name which we need to map to watch id) and click on submit button will redirect the request to localhost:8080/watches/{watch-id}. Please let me know if you are ok with this.

How to send a Facebook page as url using the Facebook send button?

I will try to explain a bit the context for my problem.
Context:
A while ago I started working on Facebook application. One of the requirements is to be included in a Facebook page as a tab. This application will contain on a page a send button in order to be able to make it more engaging with specific people, users of the application would choose on their own. The reason behind this is because the Facebook page containing the application is related to alcohol, and "liking" the application will get more audition and potential children. Another reason for using send button rather then other similar options from Facebook (like send dialog etc.) is because in Facebook documentation was stated that send button works on mobile devices and other options don't.
Problem:
My problem is related to the send button. What I need is to be able to completely configure the send button: url, image, title, description. I have research the open graph tags in order to be able to do this. Everything works fine if the page I want to be sent with the message is a website OUTSIDE Facebook. Once I started to use the url of a Facebook page (let's call it www.facebook.com/mycustompage), then the crawler takes the images, title, description from facebook.com ignoring the actual page and the produced message is not what I want.
I have searched a lot to better understand this limitation and could not find anything relevant.
The only article I could find as a potential solution was (and even this I had trouble finding):
Send button returning error codes, like button works fine
The above discussion is a workaround which I have already put in place but is not 100% what I want. The described workaround is about putting in the send button:
<div class="fb-send" data-href="http://www.mycustomdomain.com/og"></div>
a page that sniffs the user agent. In case the user agent is Facebook crawler to serve an html empty page just with the open graph tags, otherwise redirect to the desired URL - which in our case is the facebook page www.facebook.com/mycustompage.
The message produced contains:
the title which is a link to www.mycustomdomain.com/og which when
clicked opens a page in a new tab with the address
www.facebook.com/mycustompage - this is relatively ok
under the title I have a "sub-title" readonly text containing the domain of the link: www.mycustomdomain.com - THIS IS NOT OK since I don't want to share where I have hosted the application.
the image and the desired description - this is ok.
Conclusion:
What I want to know if there is a better way to do this rather than this workaround.
If not I would like to know how I can hide for the produced message the "sub-title" so that the hosted domain is not visible.

Equivalent of URL helper inside Zend Form

I have a zend form, and I need to provide a dynamic link on the form. ie. user tries to select from drop-down -> if desired option not present, click on the adjacent link to open another form where they can add the option. The link will be dynamic because I want to post some data from the current form using GET (the country and region already selected for example).
How can I do this?
Zend_Controller_Front::getInstance()->getRouter()->assemble($urlOptions, $name, $reset, $encode)
IE:
Zend_Controller_Front::getInstance()->getRouter()->assemble(array('controller' => 'index', 'action' => 'index'), null, true)
Same as in the Zend_View_Helper_Url...
You could do this client-side using javascript/AJAX - detect clicking on the link, collect form data and continue to a different page. If you need a fancy URL of the other page, you'd have to make an AJAX call to the server to get the fancy URL based on the form parameters,
or
make the link a submit button actually, process the form server-side (detecting that the special submit button was clicked; example here) and do a redirect to your other page.
As for rendering the link next to a Zend_Form_Element, you can do this in a few ways, one of them would be placing it in the label or description (setLabel(), setDescription()) while making sure to set the escape parameter of the decorator to false (example here)