georgi-shinmun 0.4.1 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/README.md +23 -31
  2. data/assets/print.css +76 -0
  3. data/assets/styles.css +91 -0
  4. data/bin/shinmun +16 -8
  5. data/config.ru +16 -0
  6. data/lib/shinmun.rb +1 -4
  7. data/lib/shinmun/blog.rb +110 -100
  8. data/lib/shinmun/comment.rb +1 -1
  9. data/lib/shinmun/handlers.rb +19 -0
  10. data/lib/shinmun/helpers.rb +1 -1
  11. data/lib/shinmun/routes.rb +25 -36
  12. data/templates/404.rhtml +4 -0
  13. data/templates/_comment_form.rhtml +21 -0
  14. data/{test/templates → templates}/_comments.rhtml +0 -0
  15. data/{example/templates → templates}/archive.rhtml +0 -1
  16. data/{example/templates → templates}/category.rhtml +1 -2
  17. data/{example/templates → templates}/category.rxml +0 -0
  18. data/{example/templates → templates}/index.rhtml +0 -1
  19. data/{example/templates → templates}/index.rxml +0 -0
  20. data/templates/layout.rhtml +44 -0
  21. data/{example/templates → templates}/page.rhtml +0 -2
  22. data/{example/templates → templates}/post.rhtml +6 -21
  23. data/test/blog_spec.rb +48 -81
  24. metadata +17 -44
  25. data/example/Rakefile +0 -41
  26. data/example/assets/images/favicon.ico +0 -0
  27. data/example/assets/images/loading.gif +0 -0
  28. data/example/assets/javascripts/1-jquery.min.js +0 -32
  29. data/example/assets/javascripts/2-jquery-form.min.js +0 -5
  30. data/example/assets/javascripts/3-comments.js +0 -45
  31. data/example/assets/javascripts/4-coderay.js +0 -13
  32. data/example/assets/print.css +0 -76
  33. data/example/assets/stylesheets/1-reset.css +0 -23
  34. data/example/assets/stylesheets/2-typo.css +0 -40
  35. data/example/assets/stylesheets/3-table.css +0 -23
  36. data/example/assets/stylesheets/4-article.css +0 -15
  37. data/example/assets/stylesheets/5-comments.css +0 -20
  38. data/example/assets/stylesheets/6-diff.css +0 -25
  39. data/example/assets/stylesheets/7-blog.css +0 -33
  40. data/example/config.ru +0 -6
  41. data/example/config/blog.yml +0 -10
  42. data/example/pages/about.md +0 -7
  43. data/example/templates/_comment_form.rhtml +0 -90
  44. data/example/templates/_comments.rhtml +0 -11
  45. data/example/templates/_pagination.rhtml +0 -10
  46. data/example/templates/comments.rhtml +0 -1
  47. data/example/templates/layout.rhtml +0 -82
  48. data/lib/shinmun/aggregations/delicious.rb +0 -57
  49. data/lib/shinmun/aggregations/flickr.rb +0 -81
  50. data/lib/shinmun/post_handler.rb +0 -16
  51. data/test/templates/archive.rhtml +0 -6
  52. data/test/templates/category.rhtml +0 -6
  53. data/test/templates/category.rxml +0 -20
  54. data/test/templates/index.rhtml +0 -4
  55. data/test/templates/index.rxml +0 -21
  56. data/test/templates/layout.rhtml +0 -9
  57. data/test/templates/page.rhtml +0 -2
  58. data/test/templates/post.rhtml +0 -3
@@ -1,25 +0,0 @@
1
-
2
- .diff {
3
- margin: 1em 0;
4
- font-family: monospace;
5
- border: 1px solid #ddd;
6
- background: #eee;
7
- }
8
-
9
- .diff .path {
10
- color: blue;
11
- padding: 1em;
12
- border-bottom: 1px solid #ddd;
13
- }
14
-
15
- .diff .line {
16
- padding-left: 1em;
17
- }
18
-
19
- .diff .added {
20
- background: #dfd;
21
- }
22
-
23
- .diff .deleted {
24
- background: #fdd;
25
- }
@@ -1,33 +0,0 @@
1
- body {
2
- padding:1em;
3
- }
4
-
5
- .container {
6
- width: 600px;
7
- margin: 0 auto;
8
- }
9
-
10
- hr {
11
- border: 0;
12
- color: #ccc;
13
- background-color: #ccc;
14
- height: 1px;
15
- margin-top: 2em;
16
- margin-bottom: 2em;
17
- }
18
-
19
- blockquote {
20
- border-top: 3px double #69c;
21
- border-bottom: 3px double #69c;
22
- padding: 5px;
23
- font-style: oblique;
24
- margin-left: 5%;
25
- margin-right: 5%;
26
- }
27
-
28
- .pagination {
29
- text-align: right;
30
- margin-top: 1em;
31
- font-weight: bold;
32
- }
33
-
data/example/config.ru DELETED
@@ -1,6 +0,0 @@
1
- require 'shinmun'
2
-
3
- use Rack::Session::Cookie
4
- use Rack::Reloader
5
-
6
- run Shinmun::Blog.new(File.dirname(__FILE__))
@@ -1,10 +0,0 @@
1
- ---
2
- language: en
3
- title: Blog Title
4
- repository: root@my-blog-url.com:/var/www/
5
- url: http://www.my-blog-url.com
6
- author: The Author
7
- categories:
8
- - Ruby
9
- - Javascript
10
- description: Blog description
@@ -1,7 +0,0 @@
1
- ---
2
- title: About
3
- ---
4
-
5
- This is the blog of Heinz Heinzmann.
6
-
7
- He is also known as _Heinzi_ or _Hein_.
@@ -1,90 +0,0 @@
1
- <div class="comment-form">
2
-
3
- <div class="loading" style="display:none">
4
- <img src="/assets/images/loading.gif" />
5
- Posting Comment...
6
- </div>
7
-
8
- <h4 class="preview-header" style="display:none">Comment Preview</h4>
9
-
10
- <div class="preview">
11
- </div>
12
-
13
- <form>
14
- <input type="hidden" name="path" value="<%= @post.path %>"/>
15
- <p>
16
- <label>Name</label><br/>
17
- <input type="text" name="name" size="40"/>
18
- </p>
19
- <p>
20
- <label>Website</label><br/>
21
- <input type="text" name="website" size="40"/>
22
- </p>
23
- <p>
24
- <label>Comment (Use Markdown for formatting) <a href="#markdown-help" onclick="$('#markdown-help').show(); return false">show help</a></label><br/>
25
- <textarea name="text" cols="60" rows="10"></textarea>
26
- </p>
27
- <p>
28
- <input type="submit" value="Post comment"/>
29
- <input type="button" value="Preview comment" class="preview-button"/>
30
- </p>
31
- </form>
32
-
33
- <a name="markdown-help"></a>
34
-
35
- <div id="markdown-help" style="display:none; margin-top:2em">
36
- <h2>Comment Formatting</h2>
37
-
38
- <ul>
39
- <li>Comments may be formatted with Markdown.</li>
40
- <li>Syntax highlighting is available (see below).</li>
41
- <li>Errors will be shown after your comment, so please check with preview.</li>
42
- <li>HTML code is filtered out for security reasons.</li>
43
- </ul>
44
-
45
- <h4>Emphasis</h4>
46
- <pre>_italic_ __bold__ or *italic* **bold**</pre>
47
-
48
- <h4>Links</h4>
49
- <pre>[Link text](http://example.com)</pre>
50
-
51
- <h4>Lists</h4>
52
- <pre>
53
- 1. Lines with beginning cardinal numbers will turn into ordered lists.
54
- 2. This is the second item.
55
-
56
- * Lines with beginning stars will turn into unordered lists.
57
- * This is the second item.
58
- </pre>
59
-
60
- <h4>Block quotes</h4>
61
- <pre>
62
- &gt; Lines with beginning brackets will turn into block quotes.
63
- &gt; Block quotes may be nested. </pre>
64
-
65
- <h4>Code blocks</h4>
66
- Code blocks are indented with 4 spaces and surrounded by blank lines:
67
- <pre>
68
-
69
- $ git commit -m "added markdown help"
70
- </pre>
71
-
72
- <h4>Syntax highlighting</h4>
73
-
74
- Following languages are supported:
75
- <strong>c, diff, javascript, scheme, css, html, xml, java, json, rhtml, yaml, delphi</strong>.
76
-
77
- You have to declare the language like this:
78
- <pre>
79
-
80
- @@ruby
81
-
82
- def method_missing(id, *args, &block)
83
- puts "#{id} was called with #{args.inspect}"
84
- end
85
-
86
- </pre>
87
-
88
- </div>
89
-
90
- </div>
@@ -1,11 +0,0 @@
1
- <% for comment in @comments %>
2
- <div class="comment">
3
- <div class="top">
4
- <%= comment.website.empty? ? comment.name : link_to(comment.name, comment.website) %> said
5
- <%= distance_of_time_in_words(comment.time, Time.now, true) %> ago:
6
- </div>
7
- <div class="body">
8
- <%= markdown(comment.text, :filter_html, :filter_styles) %>
9
- </div>
10
- </div>
11
- <% end %>
@@ -1,10 +0,0 @@
1
-
2
- <div class="pagination">
3
- <% if @page > 0 %>
4
- <%= link_to 'Previous page', "#{@path}/#{@page - 1}" %>
5
- <% end %>
6
-
7
- <% if @page < (@list.size - 1) / @page_size %>
8
- <%= link_to 'Next page', "#{path}/#{@page + 1}" %>
9
- <% end %>
10
- </div>
@@ -1 +0,0 @@
1
- <%= render '_comments.rhtml', :comments => @comments %>
@@ -1,82 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <title><%= @blog.title %></title>
5
- <meta http-equiv="Content-Language" content="English" />
6
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
7
- <link rel="shortcut icon" type="image/x-icon" href="/assets/images/favicon.ico">
8
- <link rel="alternate" type="application/rss+xml" title="RSS" href="/index.rss" />
9
- <link rel="stylesheet" media="screen" type="text/css" href="/assets/stylesheets.css" />
10
- <link rel="stylesheet" media="print" type="text/css" href="/assets/print.css" />
11
- </head>
12
- <body>
13
- <div class="container">
14
- <h3><a href="/"><%= @blog.title %></a> - <%= @blog.description %></h3>
15
-
16
- <span>
17
- <%= link_to 'Home', '/' %> -
18
- <%= link_to 'About', '/about' %> -
19
- <%= link_to 'Subscribe RSS', '/index.rss' %>
20
- </span>
21
-
22
- <span style="margin-left:1em">
23
- Categories:
24
- <%= link_to 'Ruby', '/categories/ruby' %> -
25
- <%= link_to 'Javascript', '/categories/javascript' %>
26
- </span>
27
-
28
- <% if session[:admin] %>
29
- <hr/>
30
- <div>
31
- Admin:
32
- <%= link_to 'Posts', '/admin/posts/' %> -
33
- <%= link_to 'Pages', '/admin/pages' %> -
34
- <%= link_to 'Commits', '/admin/commits' %>
35
- <% if @post %> - <%= link_to 'Edit post', "/admin/edit/#{@post.path}" %><% end %>
36
- </div>
37
- <% end %>
38
-
39
- <hr/>
40
-
41
- <%= @content %>
42
-
43
- <p>
44
- Archive:
45
- <% for year, month in @blog.archives %>
46
- <%= archive_link year, month %>
47
- <% end %>
48
- </p>
49
-
50
- <% if @blog.aggregations['flickr'] %>
51
-
52
- <h4>Interesting Art @ Flickr</h4>
53
-
54
- <p>
55
- <% for pic in @blog.aggregations['flickr'].pics %>
56
- <a href="<%= pic.link %>">
57
- <img alt="<%= pic.title %>" src="<%= pic.thumbnail %>" width="45" height="45" />
58
- </a>
59
- <% end %>
60
- </p>
61
-
62
- <% end %>
63
-
64
- <% if @blog.aggregations['delicious'] %>
65
-
66
- <h4>Ruby @ Delicious</h4>
67
-
68
- <ul>
69
- <% for item in @blog.aggregations['delicious'].items %>
70
- <li>
71
- <%= link_to item.title, item.link %>
72
- </li>
73
- <% end %>
74
- </ul>
75
-
76
- <% end %>
77
-
78
- <script type="text/javascript" src="/assets/javascripts.js"></script>
79
-
80
- </div>
81
- </body>
82
- </html>
@@ -1,57 +0,0 @@
1
- require 'open-uri'
2
- require 'time'
3
- require 'rexml/document'
4
-
5
- class Delicious
6
- include REXML
7
-
8
- attr_accessor :url, :items, :link, :title, :days
9
-
10
- # This object holds given information of an item
11
- class DeliciousItem < Struct.new(:link, :title, :description, :description_link, :date)
12
- def to_s; title end
13
- end
14
-
15
- # Pass the url to the RSS feed you would like to keep tabs on
16
- # by default this will request the rss from the server right away and
17
- # fill the items array
18
- def initialize(url, refresh = true)
19
- self.items = []
20
- self.url = url
21
- self.days = {}
22
- self.refresh if refresh
23
- end
24
-
25
- # This method lets you refresh the items in the items array
26
- # useful if you keep the object cached in memory and
27
- def refresh
28
- open(@url) do |http|
29
- parse(http.read)
30
- end
31
- end
32
-
33
- private
34
-
35
- def parse(body)
36
-
37
- xml = Document.new(body)
38
-
39
- self.items = []
40
- self.link = XPath.match(xml, "//channel/link/text()").first.value rescue ""
41
- self.title = XPath.match(xml, "//channel/title/text()").first.value rescue ""
42
-
43
- XPath.each(xml, "//item/") do |elem|
44
- item = DeliciousItem.new
45
- item.title = XPath.match(elem, "title/text()").first.value rescue ""
46
- item.link = XPath.match(elem, "link/text()").first.value rescue ""
47
- item.description = XPath.match(elem, "description/text()").first.value rescue ""
48
- item.date = Time.mktime(*ParseDate.parsedate(XPath.match(elem, "dc:date/text()").first.value)) rescue Time.now
49
-
50
- item.description_link = item.description
51
- item.description.gsub!(/<\/?a\b.*?>/, "") # remove all <a> tags
52
- items << item
53
- end
54
-
55
- self.items = items.sort_by { |item| item.date }.reverse
56
- end
57
- end
@@ -1,81 +0,0 @@
1
- require 'open-uri'
2
- require 'time'
3
- require 'rexml/document'
4
-
5
- # Example:
6
- #
7
- # flickr = Flickr.new('http://www.flickr.com/services/feeds/photos_public.gne?id=40235412@N00&format=rss_200')
8
- # flickr.pics.each do |pic|
9
- # puts "#{pic.title} @ #{pic.link} updated at #{pic.date}"
10
- # end
11
- #
12
- class FlickrAggregation
13
- include REXML
14
-
15
- def choose(num)
16
- return pics unless pics.size > num
17
- bag = []
18
- set = pics.dup
19
- num.times {|x| bag << set.delete_at(rand(set.size))}
20
- bag
21
- end
22
-
23
- attr_accessor :url, :pics, :link, :title, :description
24
-
25
- # This object holds given information of a picture
26
- class Picture
27
- attr_accessor :link, :title, :date, :description, :thumbnail
28
-
29
- def to_s
30
- title
31
- end
32
-
33
- def date=(value)
34
- @date = Time.parse(value)
35
- end
36
-
37
- end
38
-
39
- # Pass the url to the RSS feed you would like to keep tabs on
40
- # by default this will request the rss from the server right away and
41
- # fill the tasks array
42
- def initialize(url, refresh = true)
43
- self.pics = []
44
- self.url = url
45
- self.refresh if refresh
46
- end
47
-
48
- # This method lets you refresh the tasks int the tasks array
49
- # useful if you keep the object cached in memory and
50
- def refresh
51
- open(@url) do |http|
52
- parse(http.read)
53
- end
54
- end
55
-
56
- private
57
-
58
- def parse(body)
59
-
60
- xml = Document.new(body)
61
-
62
- self.pics = []
63
- self.link = XPath.match(xml, "//channel/link/text()").to_s
64
- self.title = XPath.match(xml, "//channel/title/text()").to_s
65
- self.description = XPath.match(xml, "//channel/description/text()").to_s
66
-
67
- XPath.each(xml, "//item/") do |elem|
68
-
69
- picture = Picture.new
70
- picture.title = XPath.match(elem, "title/text()").to_s
71
- picture.date = XPath.match(elem, "pubDate/text()").to_s
72
- picture.link = XPath.match(elem, "link/text()").to_s
73
- picture.description = XPath.match(elem, "description/text()").to_s
74
- picture.thumbnail = XPath.match(elem, "media:thumbnail/@url").to_s
75
-
76
- pics << picture
77
- end
78
- end
79
- end
80
-
81
-
@@ -1,16 +0,0 @@
1
- module Shinmun
2
-
3
- class PostHandler
4
- def read(path, data)
5
- Post.new(:path => path, :src => data)
6
- end
7
-
8
- def write(path, post)
9
- post.dump
10
- end
11
- end
12
-
13
- end
14
-
15
- GitStore::Handler['md'] = Shinmun::PostHandler.new
16
- GitStore::Handler['html'] = Shinmun::PostHandler.new