This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
tamanegi / tamanegi.rb
| e4cf55a3 » | zh | 2008-04-02 | 1 | #!/usr/bin/env ruby | |
| 2 | |||||
| 9e39d910 » | zh | 2008-04-02 | 3 | # OS X speedup | |
| 4 | require 'resolv-replace' | ||||
| 5 | |||||
| e4cf55a3 » | zh | 2008-04-02 | 6 | require 'rubygems' | |
| 7 | require 'sequel' | ||||
| 8 | require 'validatable' | ||||
| 9e39d910 » | zh | 2008-04-02 | 9 | require 'ramaze' | |
| 84953da6 » | zh | 2008-04-21 | 10 | require 'atom/pub' | |
| e4cf55a3 » | zh | 2008-04-02 | 11 | ||
| c8914885 » | zh | 2008-06-22 | 12 | Sequel.use_parse_tree = false | |
| 13 | |||||
| 30090393 » | zh | 2008-06-13 | 14 | DB_FILE = __DIR__/'db/tamanegi.db' | |
| 15 | DB = Sequel.connect("sqlite://#{DB_FILE}") | ||||
| e4cf55a3 » | zh | 2008-04-02 | 16 | ||
| 17 | acquire __DIR__/:lib/'*' | ||||
| e000c176 » | zh | 2008-04-04 | 18 | Kernel.load 'config.rb' | |
| e4cf55a3 » | zh | 2008-04-02 | 19 | ||
| 20 | # require all controllers and models | ||||
| 21 | acquire __DIR__/:model/'*' | ||||
| 9e39d910 » | zh | 2008-04-02 | 22 | acquire __DIR__/:controller/'*' | |
| e4cf55a3 » | zh | 2008-04-02 | 23 | ||
| e000c176 » | zh | 2008-04-04 | 24 | module Ramaze | |
| 25 | class Pager | ||||
| 26 | def navigation | ||||
| 27 | url=Request.current.env['PATH_INFO'] | ||||
| 28 | nav = "" | ||||
| 29 | unless first_page? | ||||
| 30 | nav << %{ | ||||
| 31 | <a href="#{url}?_page=#{prev_page}"><Prev</a> | ||||
| a4a0432a » | zh | 2008-04-07 | 32 | <a href="#{url}?_page=#{first_page}"><<First</a> | |
| e000c176 » | zh | 2008-04-04 | 33 | } | |
| 34 | end | ||||
| 35 | for i in nav_range() | ||||
| 36 | if i == @page | ||||
| 37 | nav << %{<span class="active">#{i}</span> } | ||||
| 38 | else | ||||
| 39 | nav << %{<a href="#{url}?_page=#{i}">#{i}</a> } | ||||
| 40 | end | ||||
| 41 | end | ||||
| 42 | unless last_page? | ||||
| 43 | nav << %{ | ||||
| 081ea96f » | zh | 2008-04-04 | 44 | <a href="#{url}?_page=#{last_page}">Last>></a> | |
| a4a0432a » | zh | 2008-04-07 | 45 | <a href="#{url}?_page=#{next_page}">Next></a> | |
| e000c176 » | zh | 2008-04-04 | 46 | } | |
| 47 | end | ||||
| 48 | return nav | ||||
| 49 | end | ||||
| 50 | end | ||||
| 51 | end | ||||
| 52 | |||||
| e4cf55a3 » | zh | 2008-04-02 | 53 | module Tamanegi | |
| 54 | def self.sync!(forceUpdate = false, debug = false) | ||||
| 55 | Feed.all.each { |f| | ||||
| 56 | status = f.sync!(forceUpdate) | ||||
| 57 | puts "#{Time.now.iso8601} #{f.url} [#{status}]" if (status && debug) | ||||
| 58 | } | ||||
| 158ac06f » | zh | 2008-04-16 | 59 | Item.vacuum! | |
| e4cf55a3 » | zh | 2008-04-02 | 60 | end | |
| 84953da6 » | zh | 2008-04-21 | 61 | ||
| 29719ae2 » | zh | 2009-01-08 | 62 | # Go to http://friendfeed.com/api/public-sup to get a SUP-ID | |
| 4f47a1b3 » | zh | 2008-04-21 | 63 | def self.to_atom(base_url = Configuration.for('app').base_url) | |
| 84953da6 » | zh | 2008-04-21 | 64 | cfg = Configuration.for('app') | |
| a1aaeeae » | zh | 2008-05-09 | 65 | @items = Item.order(:created.desc).limit(cfg.rss_page) | |
| 84953da6 » | zh | 2008-04-21 | 66 | Atom::Feed.new do |feed| | |
| 67 | feed.title = cfg.title | ||||
| c18d283a » | zh | 2008-05-09 | 68 | feed.id = "urn:uuid:"+Digest::SHA1.hexdigest("--#{base_url}--myBIGsecret") | |
| 84953da6 » | zh | 2008-04-21 | 69 | feed.updated = Item.order(:id).last.created.iso8601 | |
| a1aaeeae » | zh | 2008-05-09 | 70 | feed.authors << Atom::Person.new(:name => 'Aggregated Feed') | |
| 29719ae2 » | zh | 2009-01-08 | 71 | feed.links << Atom::Link.new(:rel => "self", | |
| 72 | :href => "#{base_url}/atom", | ||||
| 73 | :type => "application/atom+xml") | ||||
| 74 | feed.links << Atom::Link.new(:rel => "http://api.friendfeed.com/2008/03#sup", | ||||
| 75 | :href => "http://friendfeed.com/api/public-sup.json##{cfg.sup_id}", | ||||
| 76 | :xmlns => "http://www.w3.org/2005/Atom", | ||||
| 77 | :type => "application/json") | ||||
| 84953da6 » | zh | 2008-04-21 | 78 | feed.links << Atom::Link.new(:rel => 'alternate', | |
| 29719ae2 » | zh | 2009-01-08 | 79 | :href => "#{base_url}/") | |
| 84953da6 » | zh | 2008-04-21 | 80 | ||
| 81 | @items.each do |item| | ||||
| 4f47a1b3 » | zh | 2008-04-21 | 82 | feed.entries << item.to_atom(base_url) | |
| 84953da6 » | zh | 2008-04-21 | 83 | end | |
| 84 | end | ||||
| 85 | end | ||||
| e4cf55a3 » | zh | 2008-04-02 | 86 | end | |
| 87 | |||||
| 88 | Tamanegi::sync!(true) if Item.empty? && Configuration.for('app').bootstrap | ||||
| 89 | |||||
| 90 | if __FILE__ == $0 | ||||
| d0b79eb4 » | zh | 2008-04-02 | 91 | Tamanegi::sync!(false,true) | |
| e4cf55a3 » | zh | 2008-04-02 | 92 | end | |








