Get Pinterest RSS feed for board with special characters - pinterest

Normally, to get the RSS feed for a Pinterest board, you simply add ".rss" to the end of the URL.
For example, for the board at http://www.pinterest.com/philchairez/mega-man-x/, you can get the RSS feed from http://www.pinterest.com/philchairez/mega-man-x.rss.
If a board has a special character in its name, usually, it seems like Pinterest has simply removed the special characters from the assigned URL.
For example, this board is named "film + music + books + games" and its URL is http://www.pinterest.com/claramechelle/film-music-books-games/ (notice that the '+' characters are excluded).
Another example: "Kids diy games + musical instruments", http://www.pinterest.com/sammijjohno/kids-diy-games-musical-instruments/
Getting the RSS feeds for these boards works as expected:
http://www.pinterest.com/claramechelle/film-music-books-games.rss
http://www.pinterest.com/sammijjohno/kids-diy-games-musical-instruments.rss
However, URLs for some boards sometimes include the URL encoding of a special character. For example, this board is named "Dungeons + Dragons":
http://www.pinterest.com/lizardskingirl/dungeons-%2B-dragons/
And this board is named "Game Art + UI/HUD":
http://www.pinterest.com/portableneko/game-art-%2B-uihud/
Adding ".rss" to these URLs does not work:
http://www.pinterest.com/lizardskingirl/dungeons-%2B-dragons.rss
http://www.pinterest.com/portableneko/game-art-%2B-uihud.rss
You'll just get redirected to the user's board list. If you try to simply remove the special character like the other URLs, you'll get a 404.
Does anyone know how to get the RSS feed for boards like this?

Try this
http://pinterest.com/[username]/feed.rss
For example, my username is "sharp", so my RSS feed can be found at:
http://pinterest.com/sharp/feed.rss
Source:
http://www.quora.com/Does-Pinterest-have-plans-to-allow-for-RSS-feeds-for-a-users-specific-pinboards

You can get the rss feed if you replace the character encoding with the actual '+', and then tack '.rss' to the end:
http://www.pinterest.com/portableneko/game-art-%2B-uihud becomes:
http://www.pinterest.com/portableneko/game-art-+-uihud.rss

Renaming a board doesn't change its internal name, so if you have renamed a board see if you can remember its original name and generate the .rss URL from that.

Related

Using url unescape to build a url within a view in a string

I am building a url in a view within my sinatra app
I required the URI module in my app.
<li>Show</li>
Without URI.unescape I do not see %20 when I hover over the link. I just see this:
http://127.0.0.1:9292/blog/Coffee Title/49459
I am hoping for that space to be a -. But when I click on the link it will return in my browser as:
http://127.0.0.1:9292/blog/Coffee%20Title/49459
I tried using URI.unescape in irb. I am having trouble evaluating the Ruby code within the string. I am not sure what the right format is but think I am getting close.
URI.escape replaces characters in a string with their percent-encoded counterpart, which is why a space character becomes %20 (20 is the ASCII character code for space). It does not replace spaces with dashes.
To replace a character with another character in a string, use String#tr:
title = "Coffee Title"
title_with_dashes = title.tr(" ", "-")
puts title_with_dashes
# => Coffee-Title
However, this is only half of the equation. You've changed the URLs in your links but as a consequence your server probably isn't going to recognize the URL when someone clicks on the link, because the path that exists is Coffee Title, not Coffee-Title. That's a topic for another question, though.

Disabling visually ambiguous characters in Google URL-shortener output

Is there a way to say (programmatically, I mean their API) the Google URL shortener not to produce short URL with characters like:
0 O
1 l
Because people often make mistake when reading those characters from displays and typing them elsewhere.
You cannot request the API to use a custom charset, so no.
Not a proper solution, but you could check the url for unwanted characters and request another short URL for the same long URL until you get one you like. Google URL shortner issues a unique short URL for an already shortned URL if you provide an OAuth token with the request. However I am not sure if a user is limited to one unique short URL per a specific long URL in which case this won't work either.
Since you're doing it programmatically, you could swap out those chars for their ascii value, '%6F' for the letter o, for instance. In this case, just warn the users that in doubt, it's a numeral.
Alternatively, use a font that distinguishes ambiguous chars, or better yet, color-code them (or underline numerals, or whatever visual mark)

Processing form input in a Joomla component

I am creating a Joomla component and one of the pages contains a form with a text input for an email address.
When a < character is typed in the input field, that character and everything after is not showing up in the input.
I tried $_POST['field'] and JFactory::getApplication()->input->getCmd('field')
I also tried alternatives for getCmd like getVar, getString, etc. but no success.
E.g. John Doe <j.doe#mail.com> returns only John Doe.
When the < is left out, like John Doe j.doe#mail.com> the value is coming in correctly.
What can I do to also have the < character in the posted variable?
BTW. I had to use & lt; in this question to display it as I want it. This form suffers from the same problem!!
You actually need to set the filtering that you want when you grab the input. Otherwise, you will get some heavy filtering. (Typically, I will also lose # symbols.)
Replace this line:
JFactory::getApplication()->input->getCmd('field');
with this line:
JFactory::getApplication()->input->getRaw('field');
The name after the get part of the function is the filtering that you will use. Cmd strips everything but alphanumeric characters and ., -, and _. String will run through the html clean tags feature of joomla and depending on your settings will clean out <>. (That usually doesn't happen for me, but my settings are generally pretty open to the point of no filtering on super admins and such.
getRaw should definitely work, but note that there is no filtering at all, which can open security holes in your application.
The default text filter trims html from the input for your field. You should set the property
filter="raw"
in your form's manifest (xml) file, and then use getRaw() to retrieve the value. getCmd removes the non-alphanumeric characters.

How does Facebook encode emoji in the json Graph API?

Does anyone know how Facebook encodes emoji with high-surrogate pairs in the Graph API?
Low surrogate pairs seem fine. For example, ❤️ (HEAVY BLACK HEART, though it is red in iOS/OSX, link to image if you can't see the emoji) comes through as \u2764\ufe0f which appears to match the UTF-16 hex codes / "Formal Unicode Notation" shown here at iemoji.com.
And indeed, in Ruby when parsing the JSON output from the API:
ActiveSupport::JSON.decode('"\u2764\ufe0f"')
you correctly get:
"❤️"
However, to pick another emoji, 💤 (SLEEPING SYMBOL, link to image here. Facebook returns \udbba\udf59. This seems to correspond with nothing I can find on any unicode resources, e.g., for example this one at iemoji.com.
And when I attempt to decode in Ruby using the same method above:
ActiveSupport::JSON.decode('"\udbba\udf59"')
I get:
"󾭙"
Any idea what's going on here?
Answering my own question though most of the credit belongs to #bobince for showing me the way in the comments above.
The answer is that Facebook encodes emoji using the "Google" encoding as seen on this Unicode table.
I have created a ruby gem called emojivert that can convert from one encoding to another, including from "Google" to "Unified". It is based on another existing project called rails-emoji.
So the failing example above would be fixed by doing:
string = ActiveSupport::JSON.decode('"\udbba\udf59"')
> "󾭙"
fixed = Emojivert.google_to_unified(string)
> "💤"

ruby: use regex to replace http://anything with http://anything

I've seen a lot of variations on this question, but they usually are trying to either validate the 'anything' portion of the url, or provide different text for the anchor text vs the link.
For a simple blog function for users, I need the application helper that returns the same text except finds any string that starts with http:// (and ends in any whitespace or end of string) and replaces it with a same_string_here
Any tips on how to do this with regex would be appreciated... I figured out bits and pieces (grab a word starting with http) but cannot get the whole thing to work (can't figure out how to put it into the template with quotes around the href, handle the :// in the test, or put the string in a second place before the </a>).
You can try the following approach:
str = "XYZhttp://abc XYZ"
str.gsub!(/(http:\/\/\S+)/, '\1')
puts str
which will give you
XYZhttp://abc XYZ
Note: \S+ captures any non-whitespace, i.e. you have to have at least one such character after http://. It does also not remove the whitespace after http://abc. If you need you can append \s* to the regular expression outside the paranthesis.
I think an answer can be extracted from this answer: Turn URLs and #* into links. It does more than you want because it looks for twitter specific links like "#" but it does have solutions to your href question.
You can use:
body.gsub(/(?<!"|'|>)https?:\/\/[\S]+/, '\0').html_safe
The advantage of this approach is it'll replace the text, but not the html link, for example:
https://www.example.com
http://www.example.com
<a href="https://www.example.com">https://www.example.com</a
# becomes
https://www.example.com
http://www.example.com
https://www.example.com

Resources