write 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -29,6 +29,8 @@ That's all you need.
29
29
 
30
30
  Any github gist under a configured account, with the special file "write.md", will be included in the list of posts.
31
31
 
32
+ To include the default css (and atom feed discovery link), you need to ```yield(:head)``` in your layout
33
+
32
34
  WRITE serves everything from Rails.cache, it hits github only once and then caches everything. If you need to refresh the cached content (without rebooting), you need to enable a login system.
33
35
 
34
36
  On my blog, I am using [this login engine](http://github.com/samerbuna/login), which gives a quick and easy way to activate a ready devise-omniauth configurations. If you login with the configured github account, WRITE will give you a link to refresh all posts.
@@ -9,6 +9,6 @@
9
9
  * compiled file, but it's generally better to create a new file per style scope.
10
10
  *
11
11
  *= require_self
12
- *= require share
12
+ *= require share/icons
13
13
  *= require_tree .
14
14
  */
@@ -5,12 +5,15 @@ module Write
5
5
  layout Write.layout
6
6
  include ApplicationHelper
7
7
  before_filter :fetch
8
+
8
9
  def index
9
10
  @posts = GG.all
10
11
  end
12
+
11
13
  def show
12
14
  @post = GG.find params[:year], params[:code]
13
15
  end
16
+
14
17
  def refresh
15
18
  if write_admin?
16
19
  GG.clear!
@@ -18,6 +21,12 @@ module Write
18
21
  end
19
22
  redirect_to :action => :index
20
23
  end
24
+
25
+ def feed
26
+ @posts = GG.all
27
+ end
28
+
29
+ private
21
30
  def fetch
22
31
  GG.fetch if GG.empty?
23
32
  end
@@ -15,5 +15,14 @@ module Write
15
15
  end
16
16
  words
17
17
  end
18
+
19
+ def head_links
20
+ content_for :head, auto_discovery_link_tag(:atom, feed_url, :title => Write.full_title) +
21
+ stylesheet_link_tag("write/application", :media => "all")
22
+ end
23
+
24
+ def post_snippet post
25
+ truncate_html(Write::MD.render(post.content), :length => 256).html_safe
26
+ end
18
27
  end
19
28
  end
@@ -37,6 +37,10 @@ module Write
37
37
  all.find { |p| p.year == year.to_i && p.code == code }
38
38
  end
39
39
 
40
+ def self.last_update
41
+ all.sort_by(&:updated_date).last.updated_date
42
+ end
43
+
40
44
  attr_reader :code
41
45
 
42
46
  def initialize attributes
@@ -60,6 +64,14 @@ module Write
60
64
  @attributes["created_at"][1..12] != @attributes["updated_at"][1..12]
61
65
  end
62
66
 
67
+ def updated_date
68
+ @attributes["updated_at"].to_date
69
+ end
70
+
71
+ def author_name
72
+ @attributes["user"]["login"]
73
+ end
74
+
63
75
  def content
64
76
  Rails.cache.read "write.post-#{id}"
65
77
  end
@@ -0,0 +1,15 @@
1
+ atom_feed :language => 'en-US' do |feed|
2
+ feed.title Write.full_title
3
+ feed.updated Write::GG.last_update
4
+
5
+ @posts.each do |post|
6
+ feed.entry(post, :url => short_post_url(post.year, post.code)) do |entry|
7
+ entry.title post.description
8
+ entry.content post_snippet(post) + link_to("Read", short_post_url(post.year, post.code)), :type => 'html'
9
+ entry.updated post.updated_at
10
+ entry.author do |author|
11
+ author.name post.author_name
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,6 +1,5 @@
1
- <% content_for :title, Write.title + " - " + Write.tagline %>
2
-
3
- <%= stylesheet_link_tag "write/application", :media => "all" %>
1
+ <% head_links %>
2
+ <% content_for :title, Write.full_title %>
4
3
 
5
4
  <%= content_tag :div, Write.tagline, class: "blog-title" %>
6
5
 
@@ -9,7 +8,7 @@
9
8
  <%= link_to p.description, short_post_path(p.year, p.code), class: "post-title" %>
10
9
  <%= content_tag :div, timestamp_display(p), class: "post-time" %>
11
10
  <div class="post-content">
12
- <%= truncate_html(Write::MD.render(p.content), :length => 256).html_safe %>
11
+ <%= post_snippet p %>
13
12
  <%= link_to "Read", short_post_path(p.year, p.code), class: "post-continue" %>
14
13
  </div>
15
14
  </div>
@@ -1,7 +1,6 @@
1
+ <% head_links %>
1
2
  <% content_for :title, Write.title + " - " + @post.description %>
2
3
 
3
- <%= stylesheet_link_tag "write/application", :media => "all" %>
4
-
5
4
  <%= content_tag :div, link_to(Write.tagline, root_path), class: "blog-title" %>
6
5
 
7
6
  <div id="post-view" data-comments-url="<%= @post.comments_url %>">
@@ -2,5 +2,6 @@ Write::Engine.routes.draw do
2
2
  resources :posts
3
3
  get ":year/:code" => "posts#show", :as => :short_post, :constraints => { :year => /\d{4}/ }
4
4
  get "refresh(/:code)" => "posts#refresh", :as => :posts_refresh
5
+ get "feed" => "posts#feed", :format => :atom
5
6
  root to: "posts#index"
6
7
  end
@@ -25,6 +25,10 @@ module Write
25
25
  config[:tagline] || "Blog using github gists as your data store"
26
26
  end
27
27
 
28
+ def self.full_title
29
+ "#{title} - #{tagline}"
30
+ end
31
+
28
32
  def self.layout
29
33
  config[:layout] || "application"
30
34
  end
@@ -1,3 +1,3 @@
1
1
  module Write
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: write
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-23 00:00:00.000000000 Z
12
+ date: 2012-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -185,6 +185,7 @@ files:
185
185
  - app/models/write/gg.rb
186
186
  - app/views/write/posts/index.html.erb
187
187
  - app/views/write/posts/show.html.erb
188
+ - app/views/write/posts/feed.atom.builder
188
189
  - app/assets/stylesheets/write/application.css
189
190
  - app/assets/stylesheets/write/pygments.css
190
191
  - app/assets/javascripts/write/application.js