Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

107 lines (98 sloc) 3.708 kb
!!!
%html
%head
%meta(http-equiv="Content-Type" content="text/html; charset=utf-8")
%title Twitter → Pinboard username mapper
/[if lt IE 9]
%script(src="http://html5shiv.googlecode.com/svn/trunk/html5.js")
%script(src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js")
:javascript
function checkIfUsernameExists(username, id) {
$.ajax({
url: '/pingboard.json',
data: { username: username, id: id },
success: function(data) {
if (data.status == "NO") {
$("#friend-"+data.id).html("? <span>(name not on Pinboard)</span>");
} else {
var encoded_username = $("<div/>").text(username).html();
$("#friend-"+data.id).html('maybe <a href="http://pinboard.in/u:'+encoded_username+'">'+encoded_username+'</a> <span>(unverified, in use)</span>');
}
}
});
}
%style
:sass
body
font-family: sans-serif
> div
width: 43%
margin-right: 4%
padding: 0 1%
float: left
.friends
span span
color: #AAA
footer
clear: both
padding-top: 20px
%body
%h1 Twitter &rarr; Pinboard username mapper
%div
%h2 Add your usernames for others to find
%form{ :method => 'post', :action => '' }
%p
%label{ :for => "twitter" } Your Twitter username:
%input{ :type => "text", :name => "twitter" }
%p
%label{ :for => "pinboard" } Your Pinboard username:
%input{ :type => "text", :name => "pinboard" }
(can leave empty if identical)
%button Add
%hr
%h2 Recently added
- if @mappings.empty?
%p None yet.
- else
%ul
- @mappings.each do |mapping|
%li
%a{ :href => "http://twitter.com/#{h mapping.twitter}"}=h mapping.twitter
&rarr;
%a{ :href => "http://pinboard.in/u:#{h mapping.pinboard}"}=h mapping.pinboard
%div
%h2 Find your Twitter network on Pinboard
%form{ :method => 'get' }
%label{ :for => "name" } Your Twitter username:
%input{ :type => "text", :name => "name", :value => params[:name] }
%button Search
- if @friends
%hr
%h2 Network of #{h @name}
- if @friends.empty?
%p No friends, sorry!
- else
%ul.friends
- @friends.each_with_index do |friend, index|
- mapping = Mapping[:twitter => friend.downcase]
%li
%a{ :href => "http://twitter.com/#{h friend}"}=h friend
&rarr;
%span{ :id => "friend-#{index}" }
- if mapping && (pinboard = mapping.pinboard)
%a{ :href => "http://pinboard.in/u:#{h pinboard}"}=h pinboard
- else
Unknown, but try
%a{ :href => "http://pinboard.in/u:#{h friend}"}=h friend
:javascript
$(function() {
checkIfUsernameExists(#{friend.to_json}, #{index});
});
%footer
%p
<a href="/export.json">Export all mappings as JSON</a> (<a href="/export.json?different=true">only when usernames differ</a>).
%p
By <a href="http://sjjdev.com">Simon Jefford</a>
(based on <a href="htttp://delpin.heroku.com">Delpin</a>
by <a href="http://henrik.nyh.se/">Henrik Nyh</a>)
<a href="https://github.com/simonjefford/twipin">View source on GitHub</a>.
Jump to Line
Something went wrong with that request. Please try again.