rog 0.1.0

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.
Files changed (66) hide show
  1. data/LICENSE +340 -0
  2. data/README +44 -0
  3. data/Rakefile +123 -0
  4. data/bin/rog +53 -0
  5. data/lib/rog.rb +66 -0
  6. data/lib/rog/app.rb +121 -0
  7. data/lib/rog/blog.rb +283 -0
  8. data/lib/rog/builtin.rf +67 -0
  9. data/lib/rog/page.rb +31 -0
  10. data/lib/rog/post.rb +80 -0
  11. data/lib/rog/project/README +49 -0
  12. data/lib/rog/project/Rakefile +26 -0
  13. data/lib/rog/project/blog/blog.yaml +20 -0
  14. data/lib/rog/project/blog/layouts/post_mini.thtml +14 -0
  15. data/lib/rog/project/blog/layouts/soft_green.thtml +80 -0
  16. data/lib/rog/project/blog/layouts/soft_green_archive.thtml +17 -0
  17. data/lib/rog/project/blog/layouts/soft_green_post.thtml +14 -0
  18. data/lib/rog/project/blog/layouts/soft_green_static.thtml +87 -0
  19. data/lib/rog/project/blog/pages/COMMON.rb +11 -0
  20. data/lib/rog/project/blog/pages/about.rb +7 -0
  21. data/lib/rog/project/blog/pages/about.thtml +3 -0
  22. data/lib/rog/project/blog/pages/archives/README +1 -0
  23. data/lib/rog/project/blog/pages/index.rb +12 -0
  24. data/lib/rog/project/blog/pages/index.thtml +0 -0
  25. data/lib/rog/project/blog/pages/posts/COMMON.rb +1 -0
  26. data/lib/rog/project/blog/pages/posts/README +1 -0
  27. data/lib/rog/project/blog/res/images/cc_powered.png +0 -0
  28. data/lib/rog/project/blog/res/images/copyleft_powered.png +0 -0
  29. data/lib/rog/project/blog/res/images/emacs_powered.png +0 -0
  30. data/lib/rog/project/blog/res/images/gnulinux_powered.png +0 -0
  31. data/lib/rog/project/blog/res/images/header.jpg +0 -0
  32. data/lib/rog/project/blog/res/images/rog_powered.png +0 -0
  33. data/lib/rog/project/blog/res/images/rote-tiny.png +0 -0
  34. data/lib/rog/project/blog/res/images/ruby_powered.png +0 -0
  35. data/lib/rog/project/blog/res/styles.css +171 -0
  36. data/lib/rog/project/blog/templates/archive-month.rb.tpl +9 -0
  37. data/lib/rog/project/blog/templates/archive-month.thtml.tpl +0 -0
  38. data/lib/rog/project/blog/templates/archive-tag.rb.tpl +9 -0
  39. data/lib/rog/project/blog/templates/archive-tag.thtml.tpl +0 -0
  40. data/lib/rog/project/blog/templates/post.rb.tpl +7 -0
  41. data/lib/rog/project/blog/templates/post.thtml.tpl +1 -0
  42. data/lib/rog/rogtasks.rb +143 -0
  43. data/tests/data/blog.yaml +21 -0
  44. data/tests/data/layouts/post_mini.thtml +14 -0
  45. data/tests/data/layouts/soft_green.thtml +87 -0
  46. data/tests/data/layouts/soft_green_archive.thtml +17 -0
  47. data/tests/data/layouts/soft_green_post.thtml +14 -0
  48. data/tests/data/layouts/soft_green_static.thtml +87 -0
  49. data/tests/data/pages/COMMON.rb +11 -0
  50. data/tests/data/pages/about.rb +7 -0
  51. data/tests/data/pages/about.thtml +3 -0
  52. data/tests/data/pages/index.rb +12 -0
  53. data/tests/data/pages/index.thtml +0 -0
  54. data/tests/data/pages/posts/20050603-prova123.rb +3 -0
  55. data/tests/data/pages/posts/20050603-prova123.thtml +0 -0
  56. data/tests/data/templates/archive-month.rb.tpl +9 -0
  57. data/tests/data/templates/archive-month.thtml.tpl +0 -0
  58. data/tests/data/templates/archive-tag.rb.tpl +9 -0
  59. data/tests/data/templates/archive-tag.thtml.tpl +0 -0
  60. data/tests/data/templates/post.rb.tpl +7 -0
  61. data/tests/data/templates/post.thtml.tpl +1 -0
  62. data/tests/tc_rogblog.rb +52 -0
  63. data/tests/tc_rogpost.rb +44 -0
  64. data/tests/tc_rogtasks.rb +35 -0
  65. data/tests/ts_rog.rb +9 -0
  66. metadata +142 -0
@@ -0,0 +1,67 @@
1
+ # Built-in Rog rakefile
2
+ #
3
+ # This is effectively a copy of the template rakefile,
4
+ # but with extra tasks for the command-line wrapper.
5
+ #
6
+ # Rog - Static Blog Engine.
7
+ #
8
+ # Copyright (C) 2006 Luca Greco a.k.a. "ripley"
9
+ #
10
+ # This program is free software; you can redistribute it and/or modify
11
+ # it under the terms of the GNU General Public License as published by
12
+ # the Free Software Foundation; either version 2 of the License, or
13
+ # (at your option) any later version.
14
+ #
15
+ # This program is distributed in the hope that it will be useful,
16
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ # GNU General Public License for more details.
19
+ #
20
+ # You should have received a copy of the GNU General Public License
21
+ # along with this program; if not, write to the Free Software
22
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
+ #
24
+
25
+ begin
26
+ require 'rubygems'
27
+ rescue LoadError
28
+ nil # optional
29
+ end
30
+ require 'rake'
31
+ require 'rake/clean'
32
+ require 'rog'
33
+
34
+ # Import the standard doc task
35
+ #import File.join(File.dirname(__FILE__),('/project/Rakefile'))
36
+
37
+ #################### CREATE NEW PROJECT FROM TEMPLATE ###############
38
+ #
39
+ # This works in a slightly odd way. The 'create' task simply sets up
40
+ # a rule that catches anything. This rule will then be triggered by
41
+ # the task that follows on the command-line, and taken as the
42
+ # target directory name.
43
+ #
44
+ # So instead of 'rog create NAME=foo' we have 'rog create foo'
45
+ #
46
+ # Note that this does preclude having other tasks on the same
47
+ # invocation (after the create at least) but does also allow
48
+ # multiple projects to be created at once.
49
+ #
50
+ # Also need a way to display error message if the rule isn't
51
+ # invoked at least once...
52
+ desc "Bootstrap a new blog project"
53
+ task :create do
54
+ rule '' do |t|
55
+ fail "'#{t.name}' already exists" if File.exists?(t.name)
56
+
57
+ src = 'rog/project'
58
+ src_dir = $:.detect { |it| File.exists?(File.join(it,src)) }
59
+ fail "Cannot locate blog template" unless src_dir
60
+
61
+ # For now, just copy. Later, maybe we'll do some transformation on the
62
+ # sources as they're copied.
63
+ cp_r File.join(src_dir, src), t.name
64
+ end
65
+ end
66
+
67
+ ## import 'publish.rf' if File.exists?('publish.rf')
@@ -0,0 +1,31 @@
1
+ # Rog - Static Blog Engine.
2
+ #
3
+ # Copyright (C) 2006 Luca Greco a.k.a. "ripley"
4
+ #
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 2 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ module Rote
20
+
21
+ class Page
22
+ def tags
23
+ @page_tags
24
+ end
25
+
26
+ def title
27
+ @page_title
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,80 @@
1
+ # Rog - Static Blog Engine.
2
+ #
3
+ # Copyright (C) 2006 Luca Greco a.k.a. "ripley"
4
+ #
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 2 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ require 'rote'
20
+ require 'rote/format'
21
+
22
+ module Rog
23
+
24
+ class Post < Rote::Page
25
+ include Comparable
26
+ attr_reader :year, :month, :day
27
+
28
+ def initialize(path, blog_path='blog', pages_path="#{blog_path}/pages", posts_path="#{pages_path}/posts")
29
+ path =~ /(\d\d\d\d)(\d\d)(\d\d)[-].*\.thtml$/
30
+ @year, @month, @day = $1, $2, $3
31
+ @page_path = path
32
+
33
+ super(path, posts_path, "#{blog_path}/layouts") do |page|
34
+ relpath = path.sub(/\..*$/,'.html') # genera il nome della pagina formattata
35
+ @page_url = relpath
36
+ page.instance_eval("@page_name = '#{relpath}'") # e istanzia una variabile di pagina
37
+ page.instance_eval("@post_date = '#{@year}-#{@month}-#{@day}'")
38
+ end
39
+
40
+ extend Rote::Format::HTML
41
+ @page_filters.insert(0, Rote::Filters::RedCloth.new)
42
+ layout('post_mini')
43
+ end
44
+
45
+ def tags
46
+ @page_tags
47
+ end
48
+
49
+ def path
50
+ @page_path
51
+ end
52
+
53
+ def url
54
+ @page_url
55
+ end
56
+
57
+ def date
58
+ "#{@year}-#{@month}-#{@day}"
59
+ end
60
+
61
+ def <=>(other)
62
+ if (year_compare = @year <=> other.year) != 0 then
63
+ year_compare
64
+ end
65
+
66
+
67
+ if (month_compare = @month <=> other.month) != 0 then
68
+ month_compare
69
+ end
70
+
71
+ if (day_compare = @day <=> other.day) != 0 then
72
+ day_compare
73
+ end
74
+
75
+ return 0
76
+ end
77
+
78
+ end
79
+
80
+ end
@@ -0,0 +1,49 @@
1
+ This is the auto-generated Rog Blog source.
2
+
3
+ To render it using Rog's command-line wrapper (ignoring the included
4
+ Rakefile), type:
5
+
6
+ rog blog
7
+
8
+ from the top-level directory (this one).
9
+
10
+ To render using the included Rakefile (the result is the same in either
11
+ case) type instead:
12
+
13
+ rake doc
14
+
15
+ If you prefer, you can omit the 'doc' task, since it is configured
16
+ as the default.
17
+
18
+ In either case, you should see some output as the pages are rendered
19
+ and resources copied, and get output in a (created) 'html' directory.
20
+ Once you have rendered the site, running the command again will appear
21
+ to do nothing, because only changed resources are re-rendered. To
22
+ start over:
23
+
24
+ (rog|rake) clobber
25
+
26
+ Alternatively, modify the page or resource files, and rerun the first
27
+ command to transform only the modified resource.
28
+
29
+ WHAT NEXT?
30
+
31
+ + See what else you can do by typing:
32
+
33
+ (rog|rake) --tasks
34
+
35
+ rog --usage ( with the command-line wrapper )
36
+
37
+ + Modify the included page template and layout to suit your needs.
38
+
39
+ + Edit the included Rakefile to add or change tasks, or delete it
40
+ if you're sticking with the command-line wrapper.
41
+
42
+ + Add more pages and layouts.
43
+
44
+ + Start Rog in monitor mode, and have your changes rendered as
45
+ you work:
46
+
47
+ (rog|rake) doc_monitor
48
+
49
+
@@ -0,0 +1,26 @@
1
+ # Standard Rakefile for custom Rog build
2
+ #
3
+ begin
4
+ require 'rubygems'
5
+ rescue LoadError
6
+ nil # optional
7
+ end
8
+
9
+ require 'rake'
10
+ require 'rake/clean'
11
+
12
+ require 'rog'
13
+
14
+ ws = Rog::BlogTask.new(:blog) do |blog|
15
+ blog.blog_path = 'blog'
16
+ end
17
+
18
+ task :default => [:blog]
19
+
20
+ # import user-level tasks
21
+ import "#{ENV['HOME']}/.rogtasks.rf" if File.exists?("#{ENV['HOME']}/.rogtasks.rf")
22
+ import 'local.rf' if File.exists?('local.rf')
23
+
24
+ # TODO Define your custom tasks here
25
+
26
+
@@ -0,0 +1,20 @@
1
+ blogurl: http://myblogurl/
2
+ publish_url : myuser@myblogurl:/home/myurl/public_html
3
+
4
+ pages:
5
+ - About: about.html
6
+ - Blog: index.html
7
+
8
+ buttons:
9
+ - rog_powered.png: http://www.salug.it/~ripley/projects/rog.html
10
+ - ruby_powered.png: http://www.ruby-lang.it
11
+ - emacs_powered.png: http://www.gnu.org/software/emacs
12
+ - gnulinux_powered.png: http://www.gnu.org
13
+
14
+ projects:
15
+ - your project: http://projecturl
16
+
17
+ links:
18
+ - yourlink1: http://yourlink1url
19
+ - yourlink2: http://yourlink2url
20
+
@@ -0,0 +1,14 @@
1
+ <!--a href='<%= "#{@blogurl}/posts/#{@page_name}" %>'>
2
+ <h2 style="display: inline;" ><%= @page_title %> </h2> (<%= @post_date %>)
3
+ </a-->
4
+
5
+ <%# Insert page content #%>
6
+ <%= @content_for_layout %>
7
+
8
+ <div class='post_tags'>
9
+ <b>Tags</b>: <%= @page_tags.join(', ') %>
10
+ </div>
11
+
12
+ <p align='center'><hr width='20%'></p>
13
+
14
+
@@ -0,0 +1,80 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+
3
+ <html>
4
+ <head>
5
+ <title><%= @page_title + ' - ' + @site_title %></title>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
7
+ <link rel="stylesheet" href="<%= link_rel("/styles.css") %>" />
8
+ </head>
9
+
10
+ <body>
11
+ <div class="conteneur">
12
+
13
+ <div class="menu">
14
+ <ul class="menu-list">
15
+ <li>
16
+ <% $blog.pages.each do |name,url| %>
17
+ <a href='<%= link_rel("/#{url}") %>'> <%= name %> </a>
18
+ <% end %>
19
+ </li>
20
+ <li>
21
+ <span class="menu-section-title"><b>Projects:</b></span>
22
+ <% $blog.projects.each do |key, value| %>
23
+ <a href='<%= link_rel("/projects/#{value}/") %>'>
24
+ <%= key %>
25
+ </a>
26
+ <% end %>
27
+ </li>
28
+ <li><span class="menu-section-title"><b>Tags:</b></span>
29
+ <% $blog.tags.each do |key, value| %>
30
+ <a href='<%= link_rel("/archives/archive-#{key}.html") %>'>
31
+ <%= key %> <b>(<%= value.length %>)</b></a>
32
+ <% end %>
33
+ </li>
34
+ <li><span class="menu-section-title"><b>Archives:</b></span>
35
+ <% $blog.each_month do |month_posts| %>
36
+ <a href='
37
+ <%= link_rel("/archives/archive-#{month_posts[0].year + month_posts[0].month}.html")%>
38
+ '>
39
+ <%= month_posts[0].year + "/" + month_posts[0].month %>
40
+ <b>(<%= month_posts.length %>)</b>
41
+ </a>
42
+ <% end if $blog.posts? %>
43
+ </li>
44
+ <li><span class="menu-section-title"><b>Links:</b></span>
45
+ <% $blog.links.each do |name,url| %>
46
+ <a href='<%= url %>'> <%= name %> </a>
47
+ <% end %>
48
+ </li>
49
+ </ul>
50
+ </div>
51
+
52
+ <div class="buttons">
53
+ <% $blog.buttons.each do |img,url| %>
54
+ <a href='<%= url %>'> <img src='<%= link_rel("/images/#{img}") %>'/></a>
55
+ <% end %>
56
+ </div>
57
+
58
+ <div class="header">
59
+ <span class="header-title">MY BLOG NAME</span><br />
60
+ <span class="header-title-two">my blog subtitle</span>
61
+ </div>
62
+
63
+ <div class="centre">
64
+ <%= @content_for_layout %>
65
+ <!-- %= @blog_posts %-->
66
+ </div>
67
+
68
+ <div class="pied">
69
+ <div align='right'>
70
+ <span>Generate with</span>
71
+ <%# use the link_rel helper to make absolute links relative to current page #%>
72
+ <a href='http://rote.rubyforge.org/' target='_blank'>
73
+ <img src='<%= link_rel '/images/rote-tiny.png' %>' alt='Rote'/>
74
+ </a>
75
+ </div>
76
+ </div>
77
+
78
+ </div>
79
+ </body>
80
+ </html>
@@ -0,0 +1,17 @@
1
+ <% layout "soft_green" %>
2
+
3
+ <h1><%= @page_title %></h1>
4
+
5
+ <%= @content_for_layout %>
6
+
7
+ <% @blog_posts.each do |post| %>
8
+
9
+ <a href='<%= link_rel("/posts/#{post.url}") %>'>
10
+ <h2 style="display: inline;" ><%= post.title %> </h2> (<%= post.date %>)
11
+ </a>
12
+
13
+ <%= post.to_s %>
14
+
15
+ <% end %>
16
+
17
+
@@ -0,0 +1,14 @@
1
+ <% layout "soft_green_static" %>
2
+
3
+ <div style="color: white;">
4
+ <h1 style="display: inline;" ><%= @page_title %> </h1>
5
+ (<%= template_filename.delete(base_path)[1..8].insert(4,'/').insert(7,'/') %>)
6
+ </div>
7
+
8
+ <%= @content_for_layout %>
9
+
10
+ <div class='post_tags'>
11
+ <b>Tags</b>: <%= @page_tags.join(', ') %>
12
+ </div>
13
+
14
+ <p align='center'><hr width='20%'></p>
@@ -0,0 +1,87 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+
3
+ <html>
4
+ <head>
5
+ <title><%= @page_title + ' - ' + @site_title %></title>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
7
+ <link rel="stylesheet" href="<%= link_rel("/styles.css") %>" />
8
+ </head>
9
+
10
+ <body>
11
+ <div class="conteneur">
12
+
13
+ <div class="menu">
14
+ <ul class="menu-list">
15
+ <li>
16
+ <% $blog.pages.each do |name,url| %>
17
+ <a href='<%= link_rel("/#{url}") %>'> <%= name %> </a>
18
+ <% end %>
19
+ </li>
20
+ <li>
21
+ <span class="menu-section-title"><b>Projects:</b></span>
22
+ <% $blog.projects.each do |key, value| %>
23
+ <a href='<%= link_rel("/projects/#{value}/") %>'>
24
+ <%= key %>
25
+ </a>
26
+ <% end %>
27
+ </li>
28
+ <!-- li><span class="menu-section-title"><b>Tags:</b></span>
29
+ <% $blog.tags.each do |key, value| %>
30
+ <a href='<%= link_rel("/archives/archive-#{key}.html") %>'>
31
+ <%= key %> <b>(<%= value.length %>)</b></a>
32
+ <% end %>
33
+ </li>
34
+ <li><span class="menu-section-title"><b>Archives:</b></span>
35
+ <% $blog.each_month do |month_posts| %>
36
+ <a href='
37
+ <%= link_rel("/archives/archive-#{month_posts[0].year + month_posts[0].month}.html")%>
38
+ '>
39
+ <%= month_posts[0].year + "/" + month_posts[0].month %>
40
+ <b>(<%= month_posts.length %>)</b>
41
+ </a>
42
+ <% end if $blog.posts? %>
43
+ </li -->
44
+ <li><span class="menu-section-title"><b>Links:</b></span>
45
+ <% $blog.links.each do |name,url| %>
46
+ <a href='<%= url %>'> <%= name %> </a>
47
+ <% end %>
48
+ </li>
49
+ </ul>
50
+ </div>
51
+
52
+ <div class="buttons">
53
+ <% $blog.buttons.each do |img,url| %>
54
+ <a href='<%= url %>'> <img src='<%= link_rel("/images/#{img}") %>'/></a>
55
+ <% end %>
56
+ </div>
57
+
58
+ <div class="header">
59
+ <span class="header-title">$ cat /dev/random</span><br />
60
+ <span class="header-title-two">ripley's miscellanous debris</span>
61
+ </div>
62
+
63
+ <div class="centre">
64
+ <%= @content_for_layout %>
65
+ <!-- %= @blog_posts %-->
66
+ </div>
67
+
68
+ <div class="pied">
69
+ <div>
70
+ Full of CC licensed <a href="mailto:ripley_at_NOSPAMNOFLAME_salug.it">ripley</a>'s debris
71
+ </div>
72
+ <div>
73
+ HTML and CSS Design by
74
+ <a href="http://nicolas.freezee.org" target="_BLANK">Nicolas Fafchamps</a>
75
+ </div>
76
+ <div align='right'>
77
+ <span>Generate with</span>
78
+ <%# use the link_rel helper to make absolute links relative to current page #%>
79
+ <a href='http://rote.rubyforge.org/' target='_blank'>
80
+ <img src='<%= link_rel '/images/rote-tiny.png' %>' alt='Rote'/>
81
+ </a>
82
+ </div>
83
+ </div>
84
+
85
+ </div>
86
+ </body>
87
+ </html>