parchemin 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/articles/azerty.markdown +7 -0
- data/bin/articles/curae.markdown +15 -0
- data/bin/articles/lorem.markdown +11 -0
- data/bin/articles/tellus.markdown +13 -0
- data/{app/public → bin/assets}/images/feed-icon.gif +0 -0
- data/{app/public → bin/assets}/images/feed-icon.png +0 -0
- data/{app/public → bin/assets}/images/user.png +0 -0
- data/bin/parchemin +6 -12
- data/bin/{templates → statics}/about.markdown +2 -0
- data/bin/{templates → statics}/abstract.markdown +0 -0
- data/bin/templates/config.ru.haml +1 -1
- data/{app → bin}/views/_base.sass +1 -0
- data/{app → bin}/views/article_details.haml +0 -0
- data/{app → bin}/views/index.haml +0 -0
- data/{app → bin}/views/layout.haml +0 -0
- data/{app → bin}/views/layout.sass +20 -21
- data/{app → bin}/views/new_comment.haml +1 -1
- data/{app → bin}/views/rss.builder +0 -0
- data/{app → bin}/views/show.haml +0 -0
- data/{app → bin}/views/static.haml +0 -0
- data/lib/parchemin/application.rb +7 -5
- data/lib/parchemin/config/config.rb +42 -7
- data/lib/parchemin/config/environment.rb +4 -2
- data/lib/parchemin/models/article.rb +42 -24
- data/lib/parchemin/models/comment.rb +2 -0
- data/lib/parchemin/models/static.rb +4 -0
- data/lib/parchemin/utils.rb +38 -0
- data/spec/parchemin_spec.rb +8 -8
- data/spec/spec_helper.rb +1 -1
- metadata +23 -19
- data/lib/parchemin/config/compass.rb +0 -15
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.0
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<!-- title : "Cillum facilisis" -->
|
2
|
+
<!-- created_at : Date.civil(2010, 3, 26) -->
|
3
|
+
<!-- abstract : "Cillum facilisis metus turpis wisi interdum rutrum, pharetra aenean feugiat velit facilisi penatibus deserunt nonummy praesent blandit. Quisque augue adipiscing penatibus sociosqu eros torquent curabitur, vel praesent consequat aliquet sapien quam adipisicing. A dolore elit luctus scelerisque suspendisse pretium, commodo fringilla mus tellus nulla mollis suspendisse justo enim tempor congue cursus mus." -->
|
4
|
+
<!-- tags : %w(editorial rails) -->
|
5
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
6
|
+
|
7
|
+
Cillum facilisis metus turpis wisi interdum rutrum, pharetra aenean feugiat velit facilisi penatibus deserunt nonummy praesent blandit. Quisque augue adipiscing penatibus sociosqu eros torquent curabitur, vel praesent consequat aliquet sapien quam adipisicing. A dolore elit luctus scelerisque suspendisse pretium, commodo fringilla mus tellus nulla mollis suspendisse justo enim tempor congue cursus mus.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!-- title : "Curae molestie ullamco felis" -->
|
2
|
+
<!-- created_at : Date.civil(2010, 3, 10) -->
|
3
|
+
<!-- abstract : "Curae molestie ullamco felis proin tempor proident, nostra rutrum vitae varius in sapien. Facilisis nullam nam consectetuer netus blandit laboris nonummy nam dolor et, gravida ea ex volutpat non lectus imperdiet nascetur stevirota sociis. Fames velit nunc cupidatat viverra, imperdiet magnis nullam adipiscing imperdiet mi morbi. Vivamus nascetur litora dictumst ad proident facilisi, nullam eros ligula blandit elementum fugiat mollis leo semper. Incididunt etiam interdum eiusmod dolore non lobortis dictum magna odio est, suspendisse laoreet ex sint volutpat bibendum hac reprehenderit." -->
|
4
|
+
<!-- tags : %w(tutorial rdiscount) -->
|
5
|
+
Curae molestie ullamco felis proin tempor proident, nostra rutrum vitae varius in sapien. Facilisis nullam nam consectetuer netus blandit laboris nonummy nam dolor et, gravida ea ex volutpat non lectus imperdiet nascetur stevirota sociis. Fames velit nunc cupidatat viverra, imperdiet magnis nullam adipiscing imperdiet mi morbi. Vivamus nascetur litora dictumst ad proident facilisi, nullam eros ligula blandit elementum fugiat mollis leo semper. Incididunt etiam interdum eiusmod dolore non lobortis dictum magna odio est, suspendisse laoreet ex sint volutpat bibendum hac reprehenderit.
|
6
|
+
|
7
|
+
Adipisicing tellus in wisi culpa aliquam hymenaeos facilisi commodo faucibus potenti quisque sit, vel penatibus dignissim aliquet cras justo non mollis aliquam. Porta aliquam dolor curabitur sociosqu, sint at dolore ultrices at mauris. Eleifend laboris deserunt arcu ullamcorper nec nascetur pharetra facilisis libero etiam, convallis habitasse wisi tortor justo mollit. Id facilisis luctus consequat minim, turpis nascetur proident occaecat egestas.
|
8
|
+
|
9
|
+
Laborum dis aliquip nisl ornare cupidatat justo, venenatis etiam reprehenderit laborum purus duis culpa arcu potenti duis nostra sociis. Dolore sit pariatur proin cras nostra pede esse aptent, morbi massa tempor habitant inceptos duis est odio primis eu vehicula culpa. Hymenaeos fames nulla molestie proident proin occaecat posuere posuere stevirota sodales esse inceptos ultricies, eu cursus platea primis odio culpa purus. Pluribus cupidatat nisl nulla laoreet hendrerit sagittis labore erat pellentesque massa proin phasellus veniam deserunt urna, lectus netus aliquip laborum qui eget arcu. Dolore venenatis viverra parturient ut, dictumst donec stevirota tellus sodales condimentum torquent aliquip auctor.
|
10
|
+
|
11
|
+
Nam in voluptate nam tempus fugiat sit arcu sit fugiat, auctor euismod aptent volutpat ut nunc culpa bibendum. Fermentum consectetuer potenti aute rutrum bibendum, eget blandit inceptos faucibus reprehenderit aliquet dictumst qui consectetur vivamus laoreet luctus. Fermentum class donec vivamus molestie velit wisi varius ligula, convallis interdum proin venenatis dapibus stevirota. Pariatur tortor do ante conubia molestie dignissim, libero do eget malesuada pede laboris ligula parturient venenatis leo ac praesent mus magnis potenti litora. Penatibus porttitor nonummy vulputate nibh curae id fusce penatibus, fusce nibh enim do.
|
12
|
+
|
13
|
+
Eu hac auctor donec proin blandit class consequat fringilla pede tristique tincidunt phasellus, voluptate risus aptent leo dolor nam phasellus porta adipiscing leo nec nec. Luctus incididunt sociis aliqua ullamco magnis nam facilisi, vivamus ante tempor tempus gravida pellentesque voluptate cursus. Amet fusce qui habitant parturient tempus malesuada at, blandit unum iaculis ullamcorper nisi.
|
14
|
+
|
15
|
+
Praesent justo scelerisque convallis quam feugiat, ornare mattis curabitur hendrerit nostra nisi wisi nostrud hac nullam ac gravida litora dui incididunt lectus. Leo ligula pellentesque aenean fringilla cupidatat rhoncus minim conubia fermentum, stevirota do a curabitur. At vehicula officia cupidatat odio dis per feugiat labore mollis officia consequat maecenas sociis pharetra, etiam enim tellus accumsan enim deserunt sem ante velit. Varius adipiscing laborum augue fusce, lectus nascetur pharetra quam pluribus tristique rutrum. Elit augue volutpat cursus metus semper, felis aliqua euismod ac magnis morbi. Cupidatat qui neque blandit torquent dolore elit litora nullam condimentum accumsan hymenaeos ligula, iaculis ligula mattis diam vestibulum lectus hendrerit occaecat dictumst sint.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<!-- title : "Lorem ipsum" -->
|
2
|
+
<!-- created_at : Date.civil(2010, 3, 23) -->
|
3
|
+
<!-- abstract : "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." -->
|
4
|
+
<!-- tags : %w(news sinatra) -->
|
5
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
6
|
+
|
7
|
+
Curae molestie ullamco felis proin tempor proident, nostra rutrum vitae varius in sapien. Facilisis nullam nam consectetuer netus blandit laboris nonummy nam dolor et, gravida ea ex volutpat non lectus imperdiet nascetur stevirota sociis. Fames velit nunc cupidatat viverra, imperdiet magnis nullam adipiscing imperdiet mi morbi. Vivamus nascetur litora dictumst ad proident facilisi, nullam eros ligula blandit elementum fugiat mollis leo semper. Incididunt etiam interdum eiusmod dolore non lobortis dictum magna odio est, suspendisse laoreet ex sint volutpat bibendum hac reprehenderit.
|
8
|
+
|
9
|
+
Adipisicing tellus in wisi culpa aliquam hymenaeos facilisi commodo faucibus potenti quisque sit, vel penatibus dignissim aliquet cras justo non mollis aliquam. Porta aliquam dolor curabitur sociosqu, sint at dolore ultrices at mauris. Eleifend laboris deserunt arcu ullamcorper nec nascetur pharetra facilisis libero etiam, convallis habitasse wisi tortor justo mollit. Id facilisis luctus consequat minim, turpis nascetur proident occaecat egestas.
|
10
|
+
|
11
|
+
Laborum dis aliquip nisl ornare cupidatat justo, venenatis etiam reprehenderit laborum purus duis culpa arcu potenti duis nostra sociis. Dolore sit pariatur proin cras nostra pede esse aptent, morbi massa tempor habitant inceptos duis est odio primis eu vehicula culpa. Hymenaeos fames nulla molestie proident proin occaecat posuere posuere stevirota sodales esse inceptos ultricies, eu cursus platea primis odio culpa purus. Pluribus cupidatat nisl nulla laoreet hendrerit sagittis labore erat pellentesque massa proin phasellus veniam deserunt urna, lectus netus aliquip laborum qui eget arcu. Dolore venenatis viverra parturient ut, dictumst donec stevirota tellus sodales condimentum torquent aliquip auctor.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!-- title : "Adipisicing tellus in wisi culpa" -->
|
2
|
+
<!-- created_at : Date.civil(2010, 2, 2) -->
|
3
|
+
<!-- abstract : "Adipisicing tellus in wisi culpa aliquam hymenaeos facilisi commodo faucibus potenti quisque sit, vel penatibus dignissim aliquet cras justo non mollis aliquam. Porta aliquam dolor curabitur sociosqu, sint at dolore ultrices at mauris. Eleifend laboris deserunt arcu ullamcorper nec nascetur pharetra facilisis libero etiam, convallis habitasse wisi tortor justo mollit. Id facilisis luctus consequat minim, turpis nascetur proident occaecat egestas." -->
|
4
|
+
<!-- tags : %w(tutorial haml) -->
|
5
|
+
Adipisicing tellus in wisi culpa aliquam hymenaeos facilisi commodo faucibus potenti quisque sit, vel penatibus dignissim aliquet cras justo non mollis aliquam. Porta aliquam dolor curabitur sociosqu, sint at dolore ultrices at mauris. Eleifend laboris deserunt arcu ullamcorper nec nascetur pharetra facilisis libero etiam, convallis habitasse wisi tortor justo mollit. Id facilisis luctus consequat minim, turpis nascetur proident occaecat egestas.
|
6
|
+
|
7
|
+
Laborum dis aliquip nisl ornare cupidatat justo, venenatis etiam reprehenderit laborum purus duis culpa arcu potenti duis nostra sociis. Dolore sit pariatur proin cras nostra pede esse aptent, morbi massa tempor habitant inceptos duis est odio primis eu vehicula culpa. Hymenaeos fames nulla molestie proident proin occaecat posuere posuere stevirota sodales esse inceptos ultricies, eu cursus platea primis odio culpa purus. Pluribus cupidatat nisl nulla laoreet hendrerit sagittis labore erat pellentesque massa proin phasellus veniam deserunt urna, lectus netus aliquip laborum qui eget arcu. Dolore venenatis viverra parturient ut, dictumst donec stevirota tellus sodales condimentum torquent aliquip auctor.
|
8
|
+
|
9
|
+
Nam in voluptate nam tempus fugiat sit arcu sit fugiat, auctor euismod aptent volutpat ut nunc culpa bibendum. Fermentum consectetuer potenti aute rutrum bibendum, eget blandit inceptos faucibus reprehenderit aliquet dictumst qui consectetur vivamus laoreet luctus. Fermentum class donec vivamus molestie velit wisi varius ligula, convallis interdum proin venenatis dapibus stevirota. Pariatur tortor do ante conubia molestie dignissim, libero do eget malesuada pede laboris ligula parturient venenatis leo ac praesent mus magnis potenti litora. Penatibus porttitor nonummy vulputate nibh curae id fusce penatibus, fusce nibh enim do.
|
10
|
+
|
11
|
+
Eu hac auctor donec proin blandit class consequat fringilla pede tristique tincidunt phasellus, voluptate risus aptent leo dolor nam phasellus porta adipiscing leo nec nec. Luctus incididunt sociis aliqua ullamco magnis nam facilisi, vivamus ante tempor tempus gravida pellentesque voluptate cursus. Amet fusce qui habitant parturient tempus malesuada at, blandit unum iaculis ullamcorper nisi.
|
12
|
+
|
13
|
+
Praesent justo scelerisque convallis quam feugiat, ornare mattis curabitur hendrerit nostra nisi wisi nostrud hac nullam ac gravida litora dui incididunt lectus. Leo ligula pellentesque aenean fringilla cupidatat rhoncus minim conubia fermentum, stevirota do a curabitur. At vehicula officia cupidatat odio dis per feugiat labore mollis officia consequat maecenas sociis pharetra, etiam enim tellus accumsan enim deserunt sem ante velit. Varius adipiscing laborum augue fusce, lectus nascetur pharetra quam pluribus tristique rutrum. Elit augue volutpat cursus metus semper, felis aliqua euismod ac magnis morbi. Cupidatat qui neque blandit torquent dolore elit litora nullam condimentum accumsan hymenaeos ligula, iaculis ligula mattis diam vestibulum lectus hendrerit occaecat dictumst sint.
|
File without changes
|
File without changes
|
File without changes
|
data/bin/parchemin
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require 'fileutils'
|
3
|
+
require File.join(File.dirname(__FILE__), "../lib/parchemin/utils")
|
5
4
|
|
6
5
|
#############################################
|
7
6
|
# create the parchemin-based blog directory #
|
@@ -16,18 +15,13 @@ end
|
|
16
15
|
blog_name = ARGV[0]
|
17
16
|
author_name = ARGV[1]
|
18
17
|
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
# create the statics
|
25
|
-
FileUtils.cp File.join(File.dirname(__FILE__), "templates/about.markdown"), "#{blog_name}/statics/about.markdown"
|
26
|
-
FileUtils.cp File.join(File.dirname(__FILE__), "templates/abstract.markdown"), "#{blog_name}/statics/abstract.markdown"
|
18
|
+
Parchemin::Utils.mkdir("#{blog_name}/articles")
|
19
|
+
%w(assets statics views).each do |dir|
|
20
|
+
Parchemin::Utils.cpdir(File.expand_path(File.join(File.dirname(__FILE__), dir)), blog_name)
|
21
|
+
end
|
27
22
|
|
28
23
|
# Create the rack file
|
29
24
|
template = File.read(File.join(File.dirname(__FILE__), "templates/config.ru.haml"))
|
30
|
-
haml_engine = Haml::Engine.new(template)
|
31
25
|
File.open("#{blog_name}/config.ru", 'w') do |f|
|
32
|
-
f.write
|
26
|
+
f.write Parchemin::Utils.render(template, :blog_name => blog_name, :author_name => author_name, :dirname => `pwd`)
|
33
27
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# A propos #
|
2
|
+
|
1
3
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
2
4
|
|
3
5
|
Curae molestie ullamco felis proin tempor proident, nostra rutrum vitae varius in sapien. Facilisis nullam nam consectetuer netus blandit laboris nonummy nam dolor et, gravida ea ex volutpat non lectus imperdiet nascetur stevirota sociis. Fames velit nunc cupidatat viverra, imperdiet magnis nullam adipiscing imperdiet mi morbi. Vivamus nascetur litora dictumst ad proident facilisi, nullam eros ligula blandit elementum fugiat mollis leo semper. Incididunt etiam interdum eiusmod dolore non lobortis dictum magna odio est, suspendisse laoreet ex sint volutpat bibendum hac reprehenderit.
|
File without changes
|
@@ -3,7 +3,7 @@ require 'parchemin'
|
|
3
3
|
Parchemin::Config.blog_name = "#{blog_name}"
|
4
4
|
Parchemin::Config.author_name = "#{author_name}"
|
5
5
|
Parchemin::Config.host = "www.#{blog_name}.com"
|
6
|
-
Parchemin::Config.
|
6
|
+
Parchemin::Config.root_path = "#{dirname.strip}/#{blog_name}"
|
7
7
|
Parchemin::Config.db_name = "#{blog_name}"
|
8
8
|
|
9
9
|
run Parchemin::Application
|
File without changes
|
File without changes
|
File without changes
|
@@ -30,15 +30,14 @@ body
|
|
30
30
|
color: $font_color
|
31
31
|
|
32
32
|
#header
|
33
|
-
+columns(
|
34
|
-
+prefix(1)
|
33
|
+
+columns(12)
|
35
34
|
+full
|
36
35
|
+title-family
|
37
36
|
margin-bottom: 2em
|
38
37
|
margin-top: 2em
|
39
38
|
|
40
39
|
.brand
|
41
|
-
font-size:
|
40
|
+
font-size: 3em
|
42
41
|
font-weight: bold
|
43
42
|
a
|
44
43
|
&:hover
|
@@ -65,8 +64,7 @@ body
|
|
65
64
|
margin-top: 1em
|
66
65
|
|
67
66
|
#flash
|
68
|
-
+columns(
|
69
|
-
+prefix(1, 9)
|
67
|
+
+columns(8, 9)
|
70
68
|
margin-top: 1em
|
71
69
|
margin-bottom: 1em
|
72
70
|
.flash
|
@@ -79,8 +77,7 @@ body
|
|
79
77
|
background-color: #bc3739
|
80
78
|
|
81
79
|
.article
|
82
|
-
+columns(
|
83
|
-
+prefix(1, 9)
|
80
|
+
+columns(8, 9)
|
84
81
|
.title
|
85
82
|
+title-family
|
86
83
|
font-size: 2em
|
@@ -108,12 +105,12 @@ body
|
|
108
105
|
color: black
|
109
106
|
|
110
107
|
.comment
|
111
|
-
+columns(
|
108
|
+
+columns(8,8)
|
112
109
|
+full
|
113
110
|
margin-bottom: 1em
|
114
111
|
|
115
112
|
.infos
|
116
|
-
+columns(2,
|
113
|
+
+columns(2,8)
|
117
114
|
text-align: right
|
118
115
|
|
119
116
|
.author
|
@@ -125,18 +122,18 @@ body
|
|
125
122
|
color: #aaaaaa
|
126
123
|
|
127
124
|
.content
|
128
|
-
+columns(
|
129
|
-
+suffix(1,
|
130
|
-
+omega(
|
125
|
+
+columns(5,8)
|
126
|
+
+suffix(1,8)
|
127
|
+
+omega(8)
|
131
128
|
|
132
129
|
.add
|
133
|
-
+columns(
|
130
|
+
+columns(8,8)
|
134
131
|
+full
|
135
132
|
padding-top: 1em
|
136
133
|
|
137
134
|
form
|
138
|
-
+columns(5,
|
139
|
-
+prefix(1,
|
135
|
+
+columns(5,8)
|
136
|
+
+prefix(1,8)
|
140
137
|
label
|
141
138
|
font-weight: bold
|
142
139
|
textarea
|
@@ -147,12 +144,11 @@ body
|
|
147
144
|
text-align: right
|
148
145
|
|
149
146
|
.abstract
|
150
|
-
+columns(
|
151
|
-
+prefix(1, 9)
|
147
|
+
+columns(8, 9)
|
152
148
|
margin-bottom: 2em
|
153
149
|
|
154
150
|
.created_at
|
155
|
-
+columns(1,
|
151
|
+
+columns(1,8)
|
156
152
|
+rounded
|
157
153
|
background-color: black
|
158
154
|
color: white
|
@@ -161,8 +157,8 @@ body
|
|
161
157
|
font-weight: bold
|
162
158
|
|
163
159
|
.content
|
164
|
-
+columns(
|
165
|
-
+omega(
|
160
|
+
+columns(7,8)
|
161
|
+
+omega(8)
|
166
162
|
.title
|
167
163
|
+title-family
|
168
164
|
font-size: 1.5em
|
@@ -176,12 +172,15 @@ body
|
|
176
172
|
#sidebar
|
177
173
|
+columns(3)
|
178
174
|
+omega
|
175
|
+
font-size: 0.9em
|
176
|
+
line-height: 1.4em
|
177
|
+
|
179
178
|
dt
|
180
179
|
margin-bottom: $px2em * 5px
|
181
180
|
img
|
182
181
|
+rounded
|
183
182
|
float: left
|
184
|
-
margin-right: $px2em *
|
183
|
+
margin-right: $px2em * 20px
|
185
184
|
|
186
185
|
#footer
|
187
186
|
+columns(12)
|
@@ -18,6 +18,6 @@
|
|
18
18
|
%textarea{:name => 'comment[body]', :value => @comment.body}
|
19
19
|
.hint (Obligatoire)
|
20
20
|
|
21
|
-
%input{:type => 'hidden', :name => 'comment[article]', :value => @article.
|
21
|
+
%input{:type => 'hidden', :name => 'comment[article]', :value => @article.id}
|
22
22
|
|
23
23
|
%input{:type => 'submit', :value => 'Envoyer'}
|
File without changes
|
data/{app → bin}/views/show.haml
RENAMED
File without changes
|
File without changes
|
@@ -3,10 +3,12 @@
|
|
3
3
|
require File.join(File.dirname(__FILE__), "config/config")
|
4
4
|
|
5
5
|
module Parchemin
|
6
|
+
|
7
|
+
# The entire blog is based on this rack application
|
6
8
|
class Application < Sinatra::Base
|
7
9
|
|
8
|
-
set :public,
|
9
|
-
set :views,
|
10
|
+
set :public, Proc.new { Parchemin::Config.assets_path }
|
11
|
+
set :views, Proc.new { Parchemin::Config.views_path }
|
10
12
|
|
11
13
|
require File.join(File.dirname(__FILE__), "config/environment")
|
12
14
|
|
@@ -26,8 +28,8 @@ module Parchemin
|
|
26
28
|
haml :index
|
27
29
|
end
|
28
30
|
|
29
|
-
get '/articles/:article' do |
|
30
|
-
@article = Parchemin::Article.new(
|
31
|
+
get '/articles/:article' do |article|
|
32
|
+
@article = Parchemin::Article.new(article)
|
31
33
|
@comments = @article.comments
|
32
34
|
@comment = Parchemin::Comment.new
|
33
35
|
haml :show
|
@@ -51,7 +53,7 @@ module Parchemin
|
|
51
53
|
end
|
52
54
|
|
53
55
|
post '/comment' do
|
54
|
-
@article = Parchemin::Article.new("#{params[:comment][:article]}
|
56
|
+
@article = Parchemin::Article.new("#{params[:comment][:article]}")
|
55
57
|
@comments = @article.comments
|
56
58
|
|
57
59
|
@comment = Parchemin::Comment.new(params[:comment])
|
@@ -1,60 +1,95 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
module Parchemin
|
4
|
+
|
5
|
+
# This class holds all the configuration variables of the application
|
4
6
|
module Config
|
5
7
|
|
8
|
+
# sets the blog'a author name
|
6
9
|
def self.author_name=(name)
|
7
10
|
@author_name = name
|
8
11
|
end
|
9
12
|
|
13
|
+
# returns the blog's author name
|
10
14
|
def self.author_name
|
11
15
|
raise "The author_name configuration variable has not been set" if @author_name.nil?
|
12
16
|
@author_name
|
13
17
|
end
|
14
18
|
|
19
|
+
# sets the name of the blog
|
15
20
|
def self.blog_name=(name)
|
16
21
|
@blog_name = name
|
17
22
|
end
|
18
23
|
|
24
|
+
# return the name of the blog
|
19
25
|
def self.blog_name
|
20
26
|
raise "The blog_name configuration variable has not been set" if @blog_name.nil?
|
21
27
|
@blog_name
|
22
28
|
end
|
23
29
|
|
30
|
+
# sets the host of the application. This variable is useful for define the RSS feed
|
24
31
|
def self.host=(host)
|
25
32
|
@host = host
|
26
33
|
end
|
27
34
|
|
35
|
+
# returns the host of the application
|
28
36
|
def self.host
|
29
37
|
raise "The host configuration variable has not been set" if @host.nil?
|
30
38
|
@host
|
31
39
|
end
|
32
40
|
|
33
|
-
|
34
|
-
|
41
|
+
# sets the application's root directory
|
42
|
+
def self.root_path=(path)
|
43
|
+
@root_path = path
|
35
44
|
end
|
36
45
|
|
37
|
-
|
38
|
-
|
39
|
-
@
|
46
|
+
# returns the application's root directory
|
47
|
+
def self.root_path
|
48
|
+
raise "The root_path configuration variable has not been set" if @root_path.nil?
|
49
|
+
@root_path
|
40
50
|
end
|
41
51
|
|
52
|
+
# sets the directory where to find the views. By defaut it is sets to ROOT_PATH/views
|
53
|
+
def self.views_path=(path)
|
54
|
+
@views_path = path
|
55
|
+
end
|
56
|
+
|
57
|
+
# return the directory where to find the views
|
58
|
+
def self.views_path
|
59
|
+
@views_path ||= "#{root_path}/views"
|
60
|
+
end
|
61
|
+
|
62
|
+
# sets the directory where to find the assets. By defaut it is sets to ROOT_PATH/assets
|
63
|
+
def self.assets_path=(path)
|
64
|
+
@assets_path = path
|
65
|
+
end
|
66
|
+
|
67
|
+
# return the directory where to find the assets
|
68
|
+
def self.assets_path
|
69
|
+
@assets_path ||= "#{root_path}/assets"
|
70
|
+
end
|
71
|
+
|
72
|
+
# sets the directory where to find the articles. By defaut it is sets to ROOT_PATH/articles
|
42
73
|
def self.articles_path=(path)
|
43
74
|
@articles_path = path
|
44
75
|
end
|
45
76
|
|
77
|
+
# return the directory where to find the articles
|
46
78
|
def self.articles_path
|
47
|
-
@articles_path ||= "#{
|
79
|
+
@articles_path ||= "#{root_path}/articles"
|
48
80
|
end
|
49
81
|
|
82
|
+
# sets the directory where to find the static content such as about page. By defaut it is sets to ROOT_PATH/statics
|
50
83
|
def self.statics_path=(path)
|
51
84
|
@statics_path = path
|
52
85
|
end
|
53
86
|
|
87
|
+
# returns the directory where to find the static content such as about page.
|
54
88
|
def self.statics_path
|
55
|
-
@statics_path ||= "#{
|
89
|
+
@statics_path ||= "#{root_path}/statics"
|
56
90
|
end
|
57
91
|
|
92
|
+
# sets the name of the MongoDB database where the comments are stored
|
58
93
|
def self.db_name=(name)
|
59
94
|
Mongoid.configure do |config|
|
60
95
|
config.allow_dynamic_fields = false
|
@@ -17,8 +17,8 @@ module Parchemin
|
|
17
17
|
request.params.replace new_params
|
18
18
|
end
|
19
19
|
|
20
|
-
# Partial implementation
|
21
20
|
helpers do
|
21
|
+
# Partial rendering implementation
|
22
22
|
def partial(template, *args)
|
23
23
|
options = args.last.is_a?(::Hash) ? args.pop : {}
|
24
24
|
options.merge!(:layout => false)
|
@@ -32,14 +32,16 @@ module Parchemin
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
|
36
36
|
use Rack::Session::Cookie
|
37
37
|
|
38
38
|
helpers do
|
39
|
+
# Flash implementation
|
39
40
|
def flash
|
40
41
|
@_flash ||= {}
|
41
42
|
end
|
42
43
|
|
44
|
+
# Redefine redirect() to add flash support
|
43
45
|
def redirect(uri, *args)
|
44
46
|
session[:_flash] = flash unless flash.empty?
|
45
47
|
status 302
|
@@ -3,61 +3,59 @@
|
|
3
3
|
require 'date'
|
4
4
|
|
5
5
|
module Parchemin
|
6
|
+
|
7
|
+
# This class represent an article
|
6
8
|
class Article
|
7
|
-
attr_reader :title, :created_at, :abstract, :body, :filename, :tags
|
9
|
+
attr_reader :id, :title, :created_at, :abstract, :body, :filename, :tags
|
8
10
|
|
9
11
|
MONTHS = %w(janv fevr mars avr mai juin juill aout sept oct nov dec)
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
body = ""
|
18
|
-
File.open(filename) do |f|
|
19
|
-
f.lines.each do |line|
|
20
|
-
if line.match /<!--\s(.*)\s-->/
|
21
|
-
$1.match /(.*)\s:\s(.*)/
|
22
|
-
eval "@#{$1} = #{$2}"
|
23
|
-
else
|
24
|
-
body += line
|
25
|
-
end
|
26
|
-
end
|
13
|
+
# initializes the article with its name
|
14
|
+
def initialize(id)
|
15
|
+
if id =~ /(.*)\.markdown$/
|
16
|
+
@id = $1
|
17
|
+
else
|
18
|
+
@id = id
|
27
19
|
end
|
28
|
-
|
29
|
-
@body = RDiscount.new(body).to_html
|
20
|
+
parse_attributes(filename)
|
30
21
|
end
|
31
22
|
|
32
|
-
|
33
|
-
|
23
|
+
# returns the expanded path of the article
|
24
|
+
def filename
|
25
|
+
"#{Parchemin::Config.articles_path}/#{@id}.markdown"
|
34
26
|
end
|
35
27
|
|
28
|
+
# returns the month of the article's creation date
|
36
29
|
def month
|
37
30
|
MONTHS[@created_at.month-1]
|
38
31
|
end
|
39
32
|
|
33
|
+
# returns the day of the article's creation date
|
40
34
|
def day
|
41
35
|
@created_at.day
|
42
36
|
end
|
43
37
|
|
38
|
+
# returns the year of the article's creation date
|
44
39
|
def year
|
45
40
|
@created_at.year
|
46
41
|
end
|
47
42
|
|
43
|
+
# returns a well formatted date
|
48
44
|
def date
|
49
45
|
"#{day} #{month.capitalize} #{year}"
|
50
46
|
end
|
51
47
|
|
48
|
+
# defines the comparison of two articles
|
52
49
|
def <=>(article)
|
53
50
|
created_at <=> article.created_at
|
54
51
|
end
|
55
52
|
|
53
|
+
# returns all the available articles. The articles starting by a '.' are not loaded
|
56
54
|
def self.all(conditions={})
|
57
55
|
articles = []
|
58
56
|
Dir.foreach(Parchemin::Config.articles_path) do |entry|
|
59
57
|
next if entry.match /^\./
|
60
|
-
article = Article.new(
|
58
|
+
article = Article.new(entry)
|
61
59
|
|
62
60
|
if conditions.count == 0
|
63
61
|
articles << article
|
@@ -68,17 +66,37 @@ module Parchemin
|
|
68
66
|
articles.sort.reverse
|
69
67
|
end
|
70
68
|
|
69
|
+
# a rudimentary search engine
|
71
70
|
def self.search(search)
|
72
71
|
output = `grep -Hi '#{search}' #{Parchemin::Config.articles_path}/* | cut -d: -f1`
|
73
|
-
articles = output.split("\n").uniq.map
|
72
|
+
articles = output.split("\n").uniq.map do |filename|
|
73
|
+
Article.new(File.basename(filename))
|
74
|
+
end
|
74
75
|
articles.sort.reverse
|
75
76
|
end
|
76
77
|
|
78
|
+
# returns all the comments available for an article
|
77
79
|
def comments
|
78
|
-
Comment.where(:article => @
|
80
|
+
Comment.where(:article => @id)
|
79
81
|
end
|
80
82
|
|
81
83
|
protected
|
84
|
+
|
85
|
+
def parse_attributes(filename)
|
86
|
+
body = ""
|
87
|
+
File.open(filename) do |f|
|
88
|
+
f.lines.each do |line|
|
89
|
+
if line.match /<!--\s(.*)\s-->/
|
90
|
+
$1.match /(.*)\s:\s(.*)/
|
91
|
+
eval "@#{$1} = #{$2}"
|
92
|
+
else
|
93
|
+
body += line
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
@body = RDiscount.new(body).to_html
|
99
|
+
end
|
82
100
|
|
83
101
|
def self.filtered?(article, conditions)
|
84
102
|
filtered = true
|
@@ -1,14 +1,18 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
module Parchemin
|
4
|
+
|
5
|
+
# This class represents a static content such as an about page
|
4
6
|
class Static
|
5
7
|
attr_reader :filename, :id
|
6
8
|
|
9
|
+
# initializes the static content with its name
|
7
10
|
def initialize(id)
|
8
11
|
@id = id
|
9
12
|
@filename = "#{Parchemin::Config.statics_path}/#{@id}.markdown"
|
10
13
|
end
|
11
14
|
|
15
|
+
# return the body of the static content. It is possible to prevent the markup's interpretation by passing false to the method. It is useful when you only have a paragraph and don't want to see <p></p> around it.
|
12
16
|
def body(interpret_markdown=true)
|
13
17
|
raise "#{@filename} doesn't exist." if not File.exist?(@filename)
|
14
18
|
if interpret_markdown
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'haml'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Parchemin
|
5
|
+
|
6
|
+
# This class contains useful tools.
|
7
|
+
class Utils
|
8
|
+
|
9
|
+
# Creates a directory.
|
10
|
+
def self.mkdir(name)
|
11
|
+
FileUtils.mkdir_p(name)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Copies an entire directory into another.
|
15
|
+
def self.cpdir(src, dest)
|
16
|
+
new_dir = "#{dest}/#{File.basename(src)}"
|
17
|
+
mkdir(new_dir)
|
18
|
+
|
19
|
+
Dir.foreach(src) do |file|
|
20
|
+
next if %w(. ..).include? file
|
21
|
+
filename = "#{src}/#{file}"
|
22
|
+
|
23
|
+
if File.directory?(filename)
|
24
|
+
cpdir(filename, new_dir)
|
25
|
+
else
|
26
|
+
FileUtils.copy filename, new_dir
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Renders an HAML template.
|
32
|
+
def self.render(template, locals = {})
|
33
|
+
haml_engine = Haml::Engine.new(template)
|
34
|
+
haml_engine.render(Object.new, locals)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
data/spec/parchemin_spec.rb
CHANGED
@@ -27,10 +27,10 @@ describe "Parchemin" do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "renders an article" do
|
30
|
-
article = Parchemin::Article.new(
|
31
|
-
Parchemin::Comment.create(:article => article.
|
32
|
-
Parchemin::Comment.create(:article => article.
|
33
|
-
Parchemin::Comment.create(:article => article.
|
30
|
+
article = Parchemin::Article.new('lorem')
|
31
|
+
Parchemin::Comment.create(:article => article.id, :author => 'Rawane', :body => 'test')
|
32
|
+
Parchemin::Comment.create(:article => article.id, :author => 'Rawane', :body => 'test')
|
33
|
+
Parchemin::Comment.create(:article => article.id, :author => 'Rawane', :body => 'test')
|
34
34
|
|
35
35
|
get 'articles/lorem'
|
36
36
|
|
@@ -60,9 +60,9 @@ describe "Parchemin" do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "creates articles comments with valid attributes" do
|
63
|
-
article = Parchemin::Article.new(
|
63
|
+
article = Parchemin::Article.new('azerty')
|
64
64
|
|
65
|
-
post '/comment', {:comment => {:article => article.
|
65
|
+
post '/comment', {:comment => {:article => article.id, :author => 'Rawane', :body => 'test'}}
|
66
66
|
follow_redirect!
|
67
67
|
|
68
68
|
last_request.url.should == "http://example.org/articles/#{article.id}"
|
@@ -77,9 +77,9 @@ describe "Parchemin" do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
it "does not create an article'comment with invalid attributes" do
|
80
|
-
article = Parchemin::Article.new(
|
80
|
+
article = Parchemin::Article.new('tellus')
|
81
81
|
|
82
|
-
post '/comment', {:comment => {:article => article.
|
82
|
+
post '/comment', {:comment => {:article => article.id, :author => 'Rawane'}}
|
83
83
|
|
84
84
|
article.comments.count.should == 0
|
85
85
|
|
data/spec/spec_helper.rb
CHANGED
@@ -18,5 +18,5 @@ end
|
|
18
18
|
Parchemin::Config.blog_name = "Parchemin Test"
|
19
19
|
Parchemin::Config.author_name = "Rawane ZOSSOU"
|
20
20
|
Parchemin::Config.host = "http://example.com"
|
21
|
-
Parchemin::Config.
|
21
|
+
Parchemin::Config.root_path = File.expand_path(File.join(File.dirname(__FILE__), '../bin'))
|
22
22
|
Parchemin::Config.db_name = 'parchemin_test'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parchemin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.0
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rawane ZOSSOU
|
@@ -121,7 +121,7 @@ dependencies:
|
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
hash:
|
124
|
+
hash: 252770848
|
125
125
|
segments:
|
126
126
|
- 0
|
127
127
|
- 7
|
@@ -160,30 +160,34 @@ files:
|
|
160
160
|
- README.markdown
|
161
161
|
- Rakefile
|
162
162
|
- VERSION
|
163
|
-
-
|
164
|
-
-
|
165
|
-
-
|
166
|
-
-
|
167
|
-
-
|
168
|
-
-
|
169
|
-
-
|
170
|
-
- app/views/layout.sass
|
171
|
-
- app/views/new_comment.haml
|
172
|
-
- app/views/rss.builder
|
173
|
-
- app/views/show.haml
|
174
|
-
- app/views/static.haml
|
163
|
+
- bin/articles/azerty.markdown
|
164
|
+
- bin/articles/curae.markdown
|
165
|
+
- bin/articles/lorem.markdown
|
166
|
+
- bin/articles/tellus.markdown
|
167
|
+
- bin/assets/images/feed-icon.gif
|
168
|
+
- bin/assets/images/feed-icon.png
|
169
|
+
- bin/assets/images/user.png
|
175
170
|
- bin/parchemin
|
176
|
-
- bin/
|
177
|
-
- bin/
|
171
|
+
- bin/statics/about.markdown
|
172
|
+
- bin/statics/abstract.markdown
|
178
173
|
- bin/templates/config.ru.haml
|
174
|
+
- bin/views/_base.sass
|
175
|
+
- bin/views/article_details.haml
|
176
|
+
- bin/views/index.haml
|
177
|
+
- bin/views/layout.haml
|
178
|
+
- bin/views/layout.sass
|
179
|
+
- bin/views/new_comment.haml
|
180
|
+
- bin/views/rss.builder
|
181
|
+
- bin/views/show.haml
|
182
|
+
- bin/views/static.haml
|
179
183
|
- lib/parchemin.rb
|
180
184
|
- lib/parchemin/application.rb
|
181
|
-
- lib/parchemin/config/compass.rb
|
182
185
|
- lib/parchemin/config/config.rb
|
183
186
|
- lib/parchemin/config/environment.rb
|
184
187
|
- lib/parchemin/models/article.rb
|
185
188
|
- lib/parchemin/models/comment.rb
|
186
189
|
- lib/parchemin/models/static.rb
|
190
|
+
- lib/parchemin/utils.rb
|
187
191
|
- spec/parchemin_spec.rb
|
188
192
|
- spec/spec_helper.rb
|
189
193
|
has_rdoc: true
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
module Parchemin
|
4
|
-
class Application
|
5
|
-
configure do
|
6
|
-
Compass.configuration do |config|
|
7
|
-
config.project_path = File.dirname(__FILE__)
|
8
|
-
config.sass_dir = 'views'
|
9
|
-
end
|
10
|
-
|
11
|
-
set :haml, { :format => :html5 }
|
12
|
-
set :sass, Compass.sass_engine_options
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|