Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit f89eb6a4c88eb67163c23aa5cb6a66010decd1f3 0 parents
@josephholsten authored
Showing with 96 additions and 0 deletions.
  1. +26 −0 links.rb
  2. +50 −0 public/style.css
  3. +20 −0 views/index.haml
26 links.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+require 'rubygems'
+require 'sinatra'
+require 'nokogiri'
+require 'haml'
+require 'open-uri'
+
+set :haml, {:format => :html5 }
+
+get '/' do
+ resource = open('http://pinboard.in/u:josephholsten/')
+ doc = Nokogiri::HTML(resource)
+ marks = doc.css('.bookmark')
+ @bookmarks = marks.collect {|b| bookmark_to_hash(b) }
+ haml :index
+end
+
+def bookmark_to_hash(b)
+ {
+ :title => b.css('.bookmark_title').text,
+ :uri => b.css('.bookmark_title').attr('href').slice(/url=(.*)$/,1),
+ :entry_content => b.css('.description').text,
+ :tags => b.css('.tag').collect{|e|e.text},
+ :date => b.css('.when').text
+ }
+end
50 public/style.css
@@ -0,0 +1,50 @@
+html {
+ background-color: black;
+ font-family: "Lucida Grande", Lucida, Verdana, sans-serif;
+}
+
+h1 {
+ color: black;
+ background-color: lime;
+ text-align: center;
+ font-size: 2em;
+}
+
+h2 a, h1 {
+ font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
+}
+
+#links {
+ margin: 1em 3em;
+}
+
+#links > li {
+ margin-bottom: 1em;
+}
+
+h2 a {
+ font-size: 150%;
+ color: fuchsia;
+ text-decoration: none;
+}
+
+.entry-content {
+ color: lime;
+}
+
+.updated {
+ color: green;
+ float: left;
+}
+
+.entry-content, .tags, h2 {
+ margin-left: 8em;
+}
+
+.tags li {
+ display: inline;
+}
+
+.tags li a {
+ color: aqua;
+}
20 views/index.haml
@@ -0,0 +1,20 @@
+<!doctype html>
+%html{html_attrs}
+ %head
+ %meta{'http-equiv'=>"Content-Type", :content=>"text/html; charset=utf-8"}
+ %title Links
+ %link(rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/reset/reset-min.css")
+ %link(rel="stylesheet" type="text/css" media="screen" charset="utf-8" href="style.css")
+ %body
+ %h1 Links
+ %ul.hfeed
+ - @bookmarks.each do |b|
+ %li.hentry
+ %h2
+ %a(rel="bookmark"){:href=>b[:uri]}= b[:title]
+ %abbr.updated= b[:date]
+ %p.entry-content= b[:entry_content]
+ %ul.tags
+ - b[:tags].each do |tag|
+ %li
+ %a(rel="tag"){:href=>"http://pinboard.in/u:josephholsten/t:#{tag}"}= tag
Please sign in to comment.
Something went wrong with that request. Please try again.