I implementing my own Twitter button in my page. The url I'm passing is the url of the page + a selector "#" to scroll the page at the exact location.
Everything works perfectly if I pass the url of the page. But if I add for example "#idName" at the end of the url twitter forward me to the user "idName".
So in other words, Twitter thinks #idName is referring to its user and not a specific html element in my page.
How to solve this ?
thanks
Instead of passing "#", I pass the code "%23"
Related
I am trying to click on a link in products.aspx and redirect to another page categories.aspx. When i use {*id} in routing to handle querystring on products.aspx link is not working well. Sending same products.aspx page.
My Routes:
routes.MapPageRoute("productsgroup", "products/{groupname}/{*id}", "~/products.aspx");
routes.MapPageRoute("productscat", "products/brand/{bname}", "~/categories.aspx");
Hyperlink in products.aspx page:
<asp:Hyperlink ID="hyper_link" runat="server" NavigateUrl='<% GetRouteUrl("productscat", new {bname=Eval("brand-name").ToString()})%>' Text="Category1"></asp:Hyperlink>
Hyperlink is in a asp:Repeater and Eval() is working fine on a link and link is seems normal, when i click on the hyperlink, url changes but not sending categories.aspx page.
If i delete querystring {*id} and not use than hyperlink works fine.
I am trying to understand why it's happening and what we can do about it.
There is a simple solution. Change route order and your target url and link will work.
routes.MapPageRoute("productscat", "products/brand/{bname}", "~/categories.aspx");
routes.MapPageRoute("productsgroup", "products/{groupname}/{*id}", "~/products.aspx");
Routing thinks target url is "productsgroup" because it knows the url and target url starts like that. Routing waits for the variable and second route like it doesn't exist for routing.
I hope it helps. Cheers.
I am developing a test where I need to validate the URL while its navigating to the retailer's site
For instance, when I click the Product, it navigates to retailer's page. I need to capture the URL when it is navigating to the retailer's page but it should not be of the previous page & even not of the retailer's page.
Is there any method in Ruby or Capybara to get that URL? I have tried to implement this method but it's not giving the correct URL.
url = URI.parse(current_url)
def validate_url(url)
browser= Capybara.current_session.driver.browser
puts "current URL = #{browser.current_url}" if #verbose
assert_includes browser.current_url, url
end
#Actual Output url =http://www.shopstyleqa.com/browse/womens-clothes
#Expected Output url=http://www.shopstyleqa.com/action/loadRetailerProductPage
Since Capybara is designed to emulate a users use of a browser it doesn't report on redirects so there is no way to get the intermediate url if the browser is being redirected to a different one. You could verify the original URL that is going to be requested if it's in a links href attribute or a data attribute on whatever element represents the project, etc.
On a side note comparing current_url with eq or includes is a recipe for flaky tests. Instead you should use the assert_current_path assertion which uses Capybaras waiting/retrying behavior - In your case it would be something like
assert_current_path("http://www.expected.com/expected_url", url: true)
I'd like to have a link in an email (opened on an iOS devise) open an iOS app.
I have Rails mailer template that contains a link, which opens the app 'myapp' on an iOS device:
<%= link_to 'Reset my password', "myapp://?password_reset_token=#{#token}" %>
This link is rendered properly when used in a regular view, displayed in a browser.
The problem is when the link is used in a mailer template it displays without the href:
<a href>Reset My password</a>
I get the same results when I put the <a> tag manually in the template instead of using link_to. Still results in blank href.
It seems that using any protocol other than http or https yields the same results.
Is there any way to make this non http link display properly
The way I got around this was to adjust my url like this:
"myapp://myapp.com?password_reset_token=#{#token}"
The addition of the 'myapp.com' part made it work, and I can just ignore that part, and parse out the query params that I need.
Above solution do not work as
when I check mail in gmail the href remove from mail, it looks like <a href>Reset My password</a>
So I have done a workaround for it
I have redirected to a route and in that I embed script as below
<script>
$(function(){
window.location = "myapp://myapp.com"+window.location.search
})()
</script>
so it will redirects with all parameters to the URI
I want to point my Page Tab to a URL with querystring arguments like this:
http://domain.com/page.php?arg=CONSTANT
arg's value is a constant so I'm not trying to pass any dynamic data from the facebook page to my PHP page. It's just supposed to be a constant URL, with a constant querystring parameter.
I'm having problems getting this to work (nothing is shown on the facebook page tab), however when I use an URL without querystring parameters like this:
http://domain.com/page.php
it works right.
I couldn't find any information in the documentation saying that it's impossible to use URLs with querystring arguments. Is it? or am I doing something wrong?
Your answer lives in the something facebook calls app_data in the signed_request specifically made for page tab apps. See http://developers.facebook.com/docs/authentication/signed_request/
Update:
It turns out that Twitter doesn't know single tweet ID from URL fragment segment. What it does is have "lastest tweet of last viewed twitter" in the inline JavaScript. If you view somebody's profile and then go to his/her last tweet single page. The inline JavaScript has text of the last tweet by the author.
Original Question:
Each tweet has a single URL such as http://twitter.com/#!/DeliciousHot/status/23189589820702720. The tweet identification (/DeliciousHot/status/23189589820702720) is in the URL fragment segment which is not actually sent to server.
Originally, I thought it works this way:
The URL response doesn't have this tweet specific info. It is JavaScript module that extracts tweet id from current browser URL and fetch tweet payload with AJAX. The page content is then updated with the tweet payload.
To my surprise, it doesn't work this way!
With Firebug, you can view that response of http://twitter.com/#!/DeliciousHot/status/23189589820702720 has tweet payload "10 Signs of a True Gentleman" text in inline JavaScript. The tweet payload is not fetched by another AJAX.
So, how does Twitter server get to know the expected tweet ID even it is in URL fragment segment?
Two methods:
When you’re not logged in, it has a redirect:
(function(g){var a=location.href.split("#!")[1];if(a){window.location.hash =
"";g.location.pathname = g.HBR = a.replace(/^([^/])/,"/$1");}})(window);
When you are logged in, it makes a call to api.twitter.com:
http://api.twitter.com/1/statuses/show.json?include_entities=true&contributor_details=true&id=23189589820702720
I have no idea where in the code this happens, but the developer tools logged it.
It's doing it through JavaScript. The JavaScript is scanning the location for the URL fragment and redirecting the page. Here's the line that does it in the twitter.com URL:
(function(g){var a=location.href.split("#!")[1];if(a){window.location.hash = "";g.location.pathname = g.HBR = a.replace(/^([^/])/,"/$1");}})(window);