I know this is crazy simple, but I can't figure it out even after reviewing the HAML docs. How do you return the current page/path (current_page). I want to add a simple share on Twitter link to my app that contains the current path.
%a.twitter{href: "https://twitter.com/intent/tweet?url=CURRENT_PAGE_?????&text=#{blah}"} Tweet
Use request.url. It's available in controllers and views.
Related
I'm hoping this is a pretty simple question to answer. I have a page with 6 recipes on it. I'm being asked to include share buttons for each recipe and they want the shares on FB or Twitter to be formatted to use a specific image and text for each recipe. This is something we would normally handle via Open Graph metatags and the like, but that only works at the page-level.
You must use a separate URL/page for each Like/Share. But you can redirect to the main page, or just use a GET parameter. For example, each Like/Share Button can use the following URL: http://www.yourdomain.com/yourrecipepage.php?recipeid=x
The "x" being dynamic, of course. Now you can check the recipeid parameter and use different OG tags. the rest of the page will be the same. I hope you understand what i mean :)
Okay, i'm extremely new to this sort of thing, so i am probably using incorrect terminology, but i've been trying to find an answer and can't, so i'm asking here!
I have a website made in Tumblr that opens post content inside an iframe. However, that means my parent url doesn't change according to the iframe content. Is there a way i can cause the parent url to change according to the post inside the iframe? On other sites i have just done this manually but it needs to happen automaically here.
Help! Thanks!
I think you could achieve this on a website using a trick to manually modify the address in the URL bar without reloading the page. See this question for more information. Unfortunately I am not familiar with how Tumblr works internally so I wouldn't be able to say if you can actually use this. But it seems like the only way to achieve what you want.
When using FB or Google + I can paste a link of any website into the status update box and it will instant load information about that website with the option of flicking through thumbnail images.
How can I go about achieving this in ruby on rails? All my searches seem to bring up php methods on how to do this.
For grabbing video data info I use the Ruby Open Graph Protocol gem. Is there any thing for grabbing data the way FB and G+ do? If not is there a standard way this is done in rails/ruby, if so.. how is this done?
Kind regards
I think you're looking for something like oembed. I've found a gems for that, so I propose you to take look at it: https://github.com/judofyr/ruby-oembed or https://github.com/embedly/embedly-ruby
You should likely use a gem like http://nokogiri.org/
It allows you to work with a html page just as you would do with jQuery. Very handy.
I'm trying to create a site where, like Digg, a user can submit a link and using ajax it attempts to pull the metadata from the page into a title and description field. The user can change either of these fields then submit the content.
Ideally a module already exists. I tried playing around with Feeds, but I'm not sure if I'm looking in the right place.
I probably have to create my own custom module.
Any suggestions? Can I tap into the Feeds API just to parse the url then take the results and do all the mapping myself? Assuming I want to create my own form and bring in my own ajax.
You could probably do that with Feeds, but I think it might be overkill and could be difficult to configure.
You could do what you're looking for in a relatively small custom module using hook_form_alter to customize the submission form, arg() to determine the URL being submitted, drupal_http_request to retrieve the page, then the Form API's #default_value setting to pre-populate the field(s).
The Prepopulate module does a lot of what you're looking for. If it provides hooks (I'm not sure if it does) all you would need to do is add the drupal_http_request, to handle fetching the metadata.
In Drupal it's called Drigg ;). It is supposed to a nice Drupal module to get the functionality of Digg. It will be worth a try I suppose.
I'm trying to create an ajax-driven gallery where each photo in a sequence is loaded with an Ajax.Actionlink.
The user can get to any given photo by passing a parameter to the action method, eg: Gallery/Index?photo=100
The problem is that when the user is cycling through photos with the Ajax.Actionlink's the URL is no longer being updated (the way it would be during normal post-backs) so they can't copy paste from the address bar to get back to a photo.
My question is: what is the best way to solve this issue in ASP.NET MVC? One thing I was thinking of was updating the address bar with hashtags, but frankly I don't know if this is a good approach.
I could use some best-practice advice on how to solve this problem. Any suggestions would be much appreciated, thank you.
If you really want to update the address bar with each ajax update there are a couple of jquery / javascript libraries you can use as described in this blog post: http://stephenwalther.com/archive/2010/04/08/jquery-asp-net-and-browser-history
However, the best practice solution is usually not to try and fake something like this (its only going to go wrong). If you want to give your users the ability to share or link to a photo is to provide a field with the appropriate url or permalink to the url that they can copy from. Google maps has a good example of this - if you wanted to share a map with someone else.
I would look into rewriting your routes to include the photo ID in the path.
E.g., /Gallery/Index/100 instead of ?photo=100. This would be why your ActionLink methods aren't working how they should, as the querystring isn't part of the route.