write 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,5 +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
13
  *= require_tree .
13
14
  */
@@ -4,12 +4,12 @@ module Write
4
4
  class PostsController < ApplicationController
5
5
  layout Write.layout
6
6
  include ApplicationHelper
7
+ before_filter :fetch
7
8
  def index
8
- GG.fetch if GG.empty?
9
9
  @posts = GG.all
10
10
  end
11
11
  def show
12
- @post = GG.find params[:code]
12
+ @post = GG.find params[:year], params[:code]
13
13
  end
14
14
  def refresh
15
15
  if write_admin?
@@ -18,5 +18,8 @@ module Write
18
18
  end
19
19
  redirect_to :action => :index
20
20
  end
21
+ def fetch
22
+ GG.fetch if GG.empty?
23
+ end
21
24
  end
22
25
  end
@@ -1,7 +1,19 @@
1
1
  module Write
2
2
  module ApplicationHelper
3
3
  def write_admin?
4
- current_user && Write.admin?(current_user.github)
4
+ login_user && Write.admin?(login_user.github)
5
+ end
6
+
7
+ def login_user
8
+ defined?(current_user) && current_user
9
+ end
10
+
11
+ def timestamp_display post
12
+ words = time_ago_in_words(post.created_at) + " ago"
13
+ if post.updated?
14
+ words << " (Updated #{time_ago_in_words(post.updated_at)} ago)"
15
+ end
16
+ words
5
17
  end
6
18
  end
7
19
  end
@@ -33,8 +33,8 @@ module Write
33
33
  Rails.cache.write "write.posts", []
34
34
  end
35
35
 
36
- def self.find code
37
- all.find { |p| p.code == code }
36
+ def self.find year, code
37
+ all.find { |p| p.year == year.to_i && p.code == code }
38
38
  end
39
39
 
40
40
  attr_reader :code
@@ -56,6 +56,10 @@ module Write
56
56
  @attributes["created_at"].to_date.year
57
57
  end
58
58
 
59
+ def updated?
60
+ @attributes["created_at"][1..12] != @attributes["updated_at"][1..12]
61
+ end
62
+
59
63
  def content
60
64
  Rails.cache.read "write.post-#{id}"
61
65
  end
@@ -7,7 +7,7 @@
7
7
  <% @posts.each do |p| %>
8
8
  <div class="post-container">
9
9
  <%= link_to p.description, short_post_path(p.year, p.code), class: "post-title" %>
10
- <%= content_tag :div, time_ago_in_words(p.updated_at) + " ago", class: "post-time" %>
10
+ <%= content_tag :div, timestamp_display(p), class: "post-time" %>
11
11
  <div class="post-content">
12
12
  <%= truncate_html(Write::MD.render(p.content), :length => 256).html_safe %>
13
13
  <%= link_to "Read", short_post_path(p.year, p.code), class: "post-continue" %>
@@ -6,10 +6,15 @@
6
6
 
7
7
  <div id="post-view" data-comments-url="<%= @post.comments_url %>">
8
8
  <%= content_tag :div, @post.description, class: "post-title" %>
9
- <%= content_tag :div, time_ago_in_words(@post.updated_at) + " ago", class: "post-time" %>
9
+ <%= content_tag :div, timestamp_display(@post), class: "post-time" %>
10
10
 
11
11
  <%= content_tag :div, Write::MD.render(@post.content).html_safe, class: "post-content" %>
12
- <%= content_tag :div, link_to("Write a comment (requires a github account)", @post.html_url, :class => "btn"), class: "github-link" %>
12
+
13
+ <%= content_tag :div, :class => "post-footer" do %>
14
+ <%= share_links(@post.description) %>
15
+ <%= content_tag :div, link_to("Write a comment (requires a github account)", @post.html_url, :class => "btn"), class: "github-link" %>
16
+ <% end %>
17
+
13
18
  <div id="comments"></div>
14
19
  </div>
15
20
 
@@ -1,6 +1,6 @@
1
1
  Write::Engine.routes.draw do
2
2
  resources :posts
3
- get ":year/:code" => "posts#show", :as => :short_post
3
+ get ":year/:code" => "posts#show", :as => :short_post, :constraints => { :year => /\d{4}/ }
4
4
  get "refresh(/:code)" => "posts#refresh", :as => :posts_refresh
5
5
  root to: "posts#index"
6
6
  end
@@ -3,6 +3,7 @@ require "pygmentize"
3
3
  require "redcarpet"
4
4
  require "open-uri"
5
5
  require "truncate_html"
6
+ require "share"
6
7
 
7
8
  module Write
8
9
  mattr_accessor :config
@@ -1,3 +1,3 @@
1
1
  module Write
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
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.0
4
+ version: 0.2.1
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-17 00:00:00.000000000 Z
12
+ date: 2012-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -107,6 +107,22 @@ dependencies:
107
107
  - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: share
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
110
126
  - !ruby/object:Gem::Dependency
111
127
  name: jquery-rails
112
128
  requirement: !ruby/object:Gem::Requirement