teamon-rubber 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +2 -2
- data/Rakefile +2 -1
- data/lib/content.yml.sample +16 -1
- data/lib/rubber.rb +34 -15
- data/lib/server.ru +76 -43
- metadata +12 -2
data/README.textile
CHANGED
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
|
|
3
3
|
|
4
4
|
PLUGIN = "rubber"
|
5
5
|
GEM_NAME = "rubber"
|
6
|
-
GEM_VERSION = "0.0.
|
6
|
+
GEM_VERSION = "0.0.5"
|
7
7
|
AUTHOR = "Tymon Tobolski"
|
8
8
|
EMAIL = "i@teamon.eu"
|
9
9
|
HOMEPAGE = "http://teamon.eu/projekty/"
|
@@ -24,6 +24,7 @@ spec = Gem::Specification.new do |s|
|
|
24
24
|
s.files = %w( LICENSE README.textile Rakefile ) + Dir.glob("{bin,lib}/**/*")
|
25
25
|
s.add_dependency('mechanize', '>= 0.9.0')
|
26
26
|
s.add_dependency('thin')
|
27
|
+
s.add_dependency('ezcrypto', '>= 0.7.0')
|
27
28
|
end
|
28
29
|
|
29
30
|
Rake::GemPackageTask.new(spec) do |pkg|
|
data/lib/content.yml.sample
CHANGED
@@ -13,7 +13,22 @@
|
|
13
13
|
:favicon: http://blog.teamon.eu/files/favicon.png
|
14
14
|
:edit: true
|
15
15
|
:class: owner # owner, jogger, guest, trackback
|
16
|
-
|
16
|
+
|
17
|
+
- :subject: Lorem ipsum dolor sit amet
|
18
|
+
:content: <p>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.</p><EXCERPT><p>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.</p>
|
19
|
+
:date: 2009-05-08 22:19:41.282848 +02:00
|
20
|
+
:categories: [One, Two, Three]
|
21
|
+
:tags: [Ruby, Merb, Awesome]
|
22
|
+
:comments_allowed: true
|
23
|
+
:miniblog: true
|
24
|
+
:comments:
|
25
|
+
- :nick: teamon
|
26
|
+
:date: 2009-05-08 23:19:16.282848 +02:00
|
27
|
+
:content: 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.
|
28
|
+
:favicon: http://blog.teamon.eu/files/favicon.png
|
29
|
+
:edit: true
|
30
|
+
:class: owner # owner, jogger, guest, trackback
|
31
|
+
|
17
32
|
- :subject: Consectetur adipisicing elit
|
18
33
|
:content: <p>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.</p><EXCERPT><p>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.</p>
|
19
34
|
:date: 2009-05-08 22:19:41.282848 +02:00
|
data/lib/rubber.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mechanize'
|
2
|
+
require 'ezcrypto'
|
2
3
|
|
3
4
|
class Rubber
|
4
5
|
def initialize(args)
|
@@ -7,22 +8,9 @@ class Rubber
|
|
7
8
|
end
|
8
9
|
|
9
10
|
def run
|
10
|
-
load_config_file
|
11
|
-
end
|
12
|
-
|
13
|
-
protected
|
14
|
-
|
15
|
-
def load_config_file
|
16
|
-
if File.exists?("config.yml")
|
17
|
-
@config = YAML.load(File.read("config.yml"))
|
18
|
-
else
|
19
|
-
File.open("config.yml", "w") {|f| f.write YAML.dump({:jabber_id => "your@jabber.id", :password => "secret"}) }
|
20
|
-
File.open("content.yml", "w") {|f| f.write File.read(File.join(File.dirname(__FILE__), "content.yml.sample")) } unless File.exists?("content.yml")
|
21
|
-
puts "Brak pliku config.yml. Przykładowy plik został utworzony."
|
22
|
-
exit
|
23
|
-
end
|
24
|
-
|
25
11
|
case @args[0]
|
12
|
+
when 'configure'
|
13
|
+
configure
|
26
14
|
when 'download'
|
27
15
|
download
|
28
16
|
when 'upload'
|
@@ -35,6 +23,36 @@ class Rubber
|
|
35
23
|
end
|
36
24
|
end
|
37
25
|
|
26
|
+
protected
|
27
|
+
|
28
|
+
def ez
|
29
|
+
EzCrypto::Key.with_password "password", (RUBY_PLATFORM =~ /mswin32/ ? `hostname` : `uname -a`)
|
30
|
+
end
|
31
|
+
|
32
|
+
def load_config_file
|
33
|
+
if File.exists?("config.yml")
|
34
|
+
@config = YAML.load(File.read("config.yml"))
|
35
|
+
@config[:password] = ez.decrypt64 @config[:password]
|
36
|
+
else
|
37
|
+
puts "Brak pliku config.yml. Uruchom 'rubber configure'"
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def configure
|
43
|
+
print "jabber id: "
|
44
|
+
id = STDIN.gets.chomp
|
45
|
+
print "hasło: "
|
46
|
+
system "stty -echo"
|
47
|
+
pass = ez.encrypt64 STDIN.gets.chomp
|
48
|
+
system "stty echo"
|
49
|
+
puts
|
50
|
+
|
51
|
+
File.open("config.yml", "w") {|f| f.write YAML.dump({:jabber_id => id, :password => pass}) }
|
52
|
+
File.open("content.yml", "w") {|f| f.write File.read(File.join(File.dirname(__FILE__), "content.yml.sample")) } unless File.exists?("content.yml")
|
53
|
+
puts "Plik config.yml został utworzony."
|
54
|
+
end
|
55
|
+
|
38
56
|
def server
|
39
57
|
system("thin start -R #{File.join(File.dirname(__FILE__), "server.ru")} -p 1337")
|
40
58
|
end
|
@@ -121,6 +139,7 @@ class Rubber
|
|
121
139
|
end
|
122
140
|
|
123
141
|
def login
|
142
|
+
load_config_file
|
124
143
|
form = @agent.get('https://login.jogger.pl/login/').forms.first
|
125
144
|
form.login_jabberid = @config[:jabber_id]
|
126
145
|
form.login_jabberpass = @config[:password]
|
data/lib/server.ru
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'rack/response'
|
2
2
|
|
3
3
|
|
4
|
-
J = YAML.load(File.read("content.yml"))
|
5
|
-
|
6
4
|
MONTHS = %w(stycznia lutego marca kwietnia maja czerwca lipa sierpnia września pażdziernika listopada grudnia)
|
7
5
|
|
8
6
|
def tag(body, pattern, replacement)
|
@@ -26,9 +24,9 @@ def parse_with_comment(body, comment, counter = 0)
|
|
26
24
|
tag body, "COMMENT_ID", rand(100)
|
27
25
|
tag body, "COMMENT_NICK_CLASS", comment[:class]
|
28
26
|
|
29
|
-
body.gsub!(%r|<COMMENT_FAVICON_EXIST>(
|
30
|
-
body.gsub!(%r|<COMMENT_FAVICON_NOT_EXIST>(
|
31
|
-
body.gsub!(%r|<COMMENT_EDIT_EXIST>(
|
27
|
+
body.gsub!(%r|<COMMENT_FAVICON_EXIST>(.+?)</COMMENT_FAVICON_EXIST>|m) { comment[:favicon] ? parse_with_comment($1, comment, counter) : "" }
|
28
|
+
body.gsub!(%r|<COMMENT_FAVICON_NOT_EXIST>(.+?)</COMMENT_FAVICON_NOT_EXIST>|m) { comment[:favicon] ? "" : parse_with_comment($1, comment, counter) }
|
29
|
+
body.gsub!(%r|<COMMENT_EDIT_EXIST>(.+?)</COMMENT_EDIT_EXIST>|m) { comment[:edit] ? parse_with_comment($1, comment, counter) : "" }
|
32
30
|
end
|
33
31
|
|
34
32
|
def parse_with_entry(body, entry, counter = 0)
|
@@ -47,15 +45,15 @@ def parse_with_entry(body, entry, counter = 0)
|
|
47
45
|
tag body, "ENTRY_CONTENT", entry[:content].sub(%r|<EXCERPT>|, "")
|
48
46
|
tag body, "ENTRY_CONTENT_LONG", entry[:content].split(%r|<EXCERPT>|).last
|
49
47
|
tag body, "ENTRY_CONTENT_SHORT", entry[:content].split(%r|<EXCERPT>|).first
|
50
|
-
body.gsub!(%r|<ENTRY_CONTENT_SHORT_EXIST>(
|
51
|
-
body.gsub!(%r|<ENTRY_CONTENT_SHORT_NOT_EXIST>(
|
48
|
+
body.gsub!(%r|<ENTRY_CONTENT_SHORT_EXIST>(.+?)</ENTRY_CONTENT_SHORT_EXIST>|m) { entry[:content]["<EXCERPT>"] ? parse_with_entry($1, entry) : "" }
|
49
|
+
body.gsub!(%r|<ENTRY_CONTENT_SHORT_NOT_EXIST>(.+?)</ENTRY_CONTENT_SHORT_NOT_EXIST>|m) { entry[:content]["<EXCERPT>"] ? "" : parse_with_entry($1, entry) }
|
52
50
|
|
53
51
|
tag body, "ENTRY_COMMENT_HREF", "/entry"
|
54
52
|
tag body, "ENTRY_COMMENT_HREF_DESCR", entry[:comments] ? "#{entry[:comments].size} komentarzy" : "Brak komentarzy"
|
55
53
|
tag body, "ENTRY_CLASS", "entry#{(counter % 2)+1}"
|
56
54
|
entry_counter = 0 if body["ENTRY_CLASS_RESET"]
|
57
55
|
|
58
|
-
body.gsub!(%r|<ENTRY_CATEGORY_BLOCK>(
|
56
|
+
body.gsub!(%r|<ENTRY_CATEGORY_BLOCK>(.+?)</ENTRY_CATEGORY_BLOCK>|m) do
|
59
57
|
category_block = $1
|
60
58
|
category_counter = -1
|
61
59
|
entry[:categories].map do |category|
|
@@ -66,13 +64,13 @@ def parse_with_entry(body, entry, counter = 0)
|
|
66
64
|
tag catbody, "ENTRY_CATEGORY_HREF", "/za_duzo_bys_chcial"
|
67
65
|
tag catbody, "ENTRY_CATEGORY_HREF_DESCR", category
|
68
66
|
tag catbody, "ENTRY_CATEGORY_TITLE", category
|
69
|
-
catbody.gsub!(%r|<ENTRY_CATEGORY_NOT_LAST>(
|
67
|
+
catbody.gsub!(%r|<ENTRY_CATEGORY_NOT_LAST>(.+?)</ENTRY_CATEGORY_NOT_LAST>|m) { category_counter == entry[:categories].size-1 ? "" : $1 }
|
70
68
|
catbody
|
71
69
|
end.join
|
72
70
|
end
|
73
71
|
|
74
|
-
body.gsub!(%r|<ENTRY_TAG_BLOCK_EXIST>(
|
75
|
-
body.gsub!(%r|<ENTRY_TAG_BLOCK>(
|
72
|
+
body.gsub!(%r|<ENTRY_TAG_BLOCK_EXIST>(.+?)</ENTRY_TAG_BLOCK_EXIST>|m) { entry[:tags] ? parse_with_entry($1, entry) : "" }
|
73
|
+
body.gsub!(%r|<ENTRY_TAG_BLOCK>(.+?)</ENTRY_TAG_BLOCK>|m) do
|
76
74
|
tag_block = $1
|
77
75
|
entry[:tags].map do |t|
|
78
76
|
tagbody = tag_block.dup
|
@@ -82,14 +80,14 @@ def parse_with_entry(body, entry, counter = 0)
|
|
82
80
|
end
|
83
81
|
|
84
82
|
tag body, "ENTRY_TRACKBACK_HREF", entry[:trackback]
|
85
|
-
body.gsub!(%r|<ENTRY_TRACKBACK_EXIST>(
|
86
|
-
body.gsub!(%r|<ENTRY_TRACKBACK_NOT_EXIST>(
|
83
|
+
body.gsub!(%r|<ENTRY_TRACKBACK_EXIST>(.+?)</ENTRY_TRACKBACK_EXIST>|m) { entry[:trackback] ? parse_with_entry($1, entry) : "" }
|
84
|
+
body.gsub!(%r|<ENTRY_TRACKBACK_NOT_EXIST>(.+?)</ENTRY_TRACKBACK_NOT_EXIST>|m) { entry[:trackback] ? "" : parse_with_entry($1, entry) }
|
87
85
|
|
88
86
|
["PREV", "NEXT"].each do |type|
|
89
87
|
p = entry[type.downcase.to_sym]
|
90
88
|
|
91
|
-
body.gsub!(%r|<ENTRY_#{type}_EXIST>(
|
92
|
-
body.gsub!(%r|<ENTRY_#{type}_NOT_EXIST>(
|
89
|
+
body.gsub!(%r|<ENTRY_#{type}_EXIST>(.+?)</ENTRY_#{type}_EXIST>|m) { p ? parse_with_entry($1, entry) : "" }
|
90
|
+
body.gsub!(%r|<ENTRY_#{type}_NOT_EXIST>(.+?)</ENTRY_#{type}_NOT_EXIST>|m) { p ? "" : parse_with_entry($1, entry) }
|
93
91
|
|
94
92
|
if p
|
95
93
|
tag body, "ENTRY_#{type}_SUBJECT", p[:subject]
|
@@ -101,18 +99,18 @@ def parse_with_entry(body, entry, counter = 0)
|
|
101
99
|
end
|
102
100
|
end
|
103
101
|
|
104
|
-
body.gsub!(%r|<ENTRY_IS_MINIBLOG>(
|
102
|
+
body.gsub!(%r|<ENTRY_IS_MINIBLOG>(.+?)</ENTRY_IS_MINIBLOG>|m) { entry[:miniblog] ? parse_with_entry($1, entry) : "" }
|
105
103
|
|
106
104
|
body
|
107
105
|
end
|
108
106
|
|
109
|
-
def parse(type, body)
|
110
|
-
body.gsub!(%r|<INCLUDE>(
|
107
|
+
def parse(type, body)
|
108
|
+
body.gsub!(%r|<INCLUDE>(.+?)</INCLUDE>|) { parse nil, File.read("files/#{$1}") }
|
111
109
|
|
112
|
-
body.gsub!(%r|<ARCHIVE_BLOCK>(
|
110
|
+
body.gsub!(%r|<ARCHIVE_BLOCK>(.+?)</ARCHIVE_BLOCK>|m) do
|
113
111
|
archive_block = $1
|
114
112
|
archive_counter = -1
|
115
|
-
|
113
|
+
@Jogger[:archive].map do |archive|
|
116
114
|
archive_counter += 1
|
117
115
|
archbody = archive_block.dup
|
118
116
|
|
@@ -121,15 +119,15 @@ def parse(type, body)
|
|
121
119
|
tag archbody, "ARCHIVE_HREF_DESCR", archive[:name]
|
122
120
|
tag archbody, "ARCHIVE_CLASS", "archive#{(archive_counter % 2)+1}"
|
123
121
|
tag archbody, "ARCHIVE_CURRENT_DESCR", "Maj 2009"
|
124
|
-
archbody.gsub!(%r|<ARCHIVE_NOT_LAST>(
|
122
|
+
archbody.gsub!(%r|<ARCHIVE_NOT_LAST>(.+?)</ARCHIVE_NOT_LAST>|m) { archive_counter == @Jogger[:archive].size-1 ? "" : $1 }
|
125
123
|
archbody
|
126
124
|
end.join
|
127
125
|
end
|
128
126
|
|
129
|
-
body.gsub!(%r|<CATEGORY_BLOCK>(
|
127
|
+
body.gsub!(%r|<CATEGORY_BLOCK>(.+?)</CATEGORY_BLOCK>|m) do
|
130
128
|
category_block = $1
|
131
129
|
category_counter = -1
|
132
|
-
|
130
|
+
@Jogger[:categories].map do |category|
|
133
131
|
catbody = category_block.dup
|
134
132
|
category_counter += 1
|
135
133
|
|
@@ -141,21 +139,21 @@ def parse(type, body)
|
|
141
139
|
tag catbody, "CATEGORY_ID", category_counter
|
142
140
|
tag catbody, "CATEGORY_LEVEL", rand(6)
|
143
141
|
tag catbody, "CATEGORY_SUB_CLASS", "subcategory#{category[:sub]}"
|
144
|
-
catbody.gsub!(%r|<CATEGORY_NOT_LAST>(
|
142
|
+
catbody.gsub!(%r|<CATEGORY_NOT_LAST>(.+?)</CATEGORY_NOT_LAST>|m) { category_counter == @Jogger[:categories].size-1 ? "" : $1 }
|
145
143
|
catbody
|
146
144
|
end.join
|
147
145
|
end
|
148
146
|
|
149
|
-
body.gsub!(%r|<LINK_BLOCK_EXIST>(
|
147
|
+
body.gsub!(%r|<LINK_BLOCK_EXIST>(.+?)</LINK_BLOCK_EXIST>|m) { @Jogger[:links] ? parse(nil, $1) : "" }
|
150
148
|
|
151
|
-
body.gsub!(%r|<LINK_GROUP_BLOCK>(
|
149
|
+
body.gsub!(%r|<LINK_GROUP_BLOCK>(.+?)</LINK_GROUP_BLOCK>|m) do
|
152
150
|
link_group_block = $1
|
153
151
|
link_counter = -1
|
154
|
-
|
152
|
+
@Jogger[:links].map do |link_group|
|
155
153
|
grobody = link_group_block.dup
|
156
154
|
tag grobody, "LINK_GROUP_DESCR", link_group[:name]
|
157
155
|
|
158
|
-
grobody.gsub!(%r|<LINK_BLOCK>(
|
156
|
+
grobody.gsub!(%r|<LINK_BLOCK>(.+?)</LINK_BLOCK>|m) do
|
159
157
|
link_block = $1
|
160
158
|
link_group[:links].map do |link|
|
161
159
|
link_counter += 1
|
@@ -175,26 +173,59 @@ def parse(type, body)
|
|
175
173
|
end.join
|
176
174
|
end
|
177
175
|
|
176
|
+
tag body, "JID", "me@jabber.foo"
|
177
|
+
tag body, "JOG_TITLE", "My super awesome jogger"
|
178
|
+
tag body, "JOG", "teamon"
|
179
|
+
tag body, "HOME", "/"
|
180
|
+
tag body, "RSS", "/rss"
|
181
|
+
tag body, "ALL_ENTRIES_HREF", "/"
|
182
|
+
tag body, "CURRENT_PAGE_HREF", "/entry"
|
183
|
+
|
184
|
+
tag body, "HEADER", <<-HEADER
|
185
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
186
|
+
<html lang="pl">
|
187
|
+
<head>
|
188
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
189
|
+
<meta name="robots" content="noindex, nofollow">
|
190
|
+
<title>Jogger :: teamon</title>
|
191
|
+
<link rel="StyleSheet" href="/files/style.css" type="text/css">
|
192
|
+
</head>
|
193
|
+
<body>
|
194
|
+
HEADER
|
195
|
+
|
196
|
+
tag body, "FOOTER", <<-FOOTER
|
197
|
+
</body>
|
198
|
+
</html>
|
199
|
+
FOOTER
|
200
|
+
|
178
201
|
case type
|
179
202
|
when :entries
|
180
|
-
body.gsub!(%r|<
|
203
|
+
body.gsub!(%r|<MINIBLOG_BLOCK>(.+?)</MINIBLOG_BLOCK>|m) do
|
204
|
+
$1.gsub!(%r|<ENTRY_BLOCK>(.+?)</ENTRY_BLOCK>|m) do
|
205
|
+
entry_block = $1
|
206
|
+
entry_counter = -1
|
207
|
+
@Jogger[:entries].select {|e| e[:miniblog] }.map {|entry| parse_with_entry(entry_block.dup, entry, entry_counter += 1) }.join
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
body.gsub!(%r|<ENTRY_BLOCK>(.+?)</ENTRY_BLOCK>|m) do
|
181
212
|
entry_block = $1
|
182
213
|
entry_counter = -1
|
183
|
-
|
214
|
+
@Jogger[:entries].reject {|e| e[:miniblog] }.map {|entry| parse_with_entry(entry_block.dup, entry, entry_counter += 1) }.join
|
184
215
|
end
|
185
216
|
|
186
|
-
body.gsub!(%r|<PAGE_BLOCK_EXIST>(
|
187
|
-
body.gsub!(%r|<PAGE_PREV_EXIST>(
|
188
|
-
body.gsub!(%r|<PAGE_NEXT_EXIST>(
|
217
|
+
body.gsub!(%r|<PAGE_BLOCK_EXIST>(.+?)</PAGE_BLOCK_EXIST>|) { parse(:entries, $1) }
|
218
|
+
body.gsub!(%r|<PAGE_PREV_EXIST>(.+?)</PAGE_PREV_EXIST>|) { parse(:entries, $1) }
|
219
|
+
body.gsub!(%r|<PAGE_NEXT_EXIST>(.+?)</PAGE_NEXT_EXIST>|) { parse(:entries, $1) }
|
189
220
|
tag body, "PAGE_PREV_HREF", "/prev"
|
190
221
|
tag body, "PAGE_NEXT_HREF", "/next"
|
191
222
|
|
192
223
|
|
193
224
|
when :comments
|
194
|
-
entry =
|
225
|
+
entry = @Jogger[:entries].first
|
195
226
|
parse_with_entry(body, entry)
|
196
227
|
|
197
|
-
body.gsub!(%r|<COMMENT_BLOCK>(
|
228
|
+
body.gsub!(%r|<COMMENT_BLOCK>(.+?)</COMMENT_BLOCK>|m) do
|
198
229
|
comment_block = $1
|
199
230
|
comment_counter = -1
|
200
231
|
entry[:comments].map do |comment|
|
@@ -202,10 +233,10 @@ def parse(type, body)
|
|
202
233
|
end.join
|
203
234
|
end
|
204
235
|
|
205
|
-
body.gsub!(%r|<COMMENT_BLOCK_EXIST>(
|
206
|
-
body.gsub!(%r|<COMMENT_BLOCK_NOT_EXIST>(
|
207
|
-
body.gsub!(%r|<COMMENT_ALLOWED_BLOCK>(
|
208
|
-
body.gsub!(%r|<COMMENT_NONE_BLOCK>(
|
236
|
+
body.gsub!(%r|<COMMENT_BLOCK_EXIST>(.+?)</COMMENT_BLOCK_EXIST>|m) { entry[:comments] ? parse(:comments, $1) : "" }
|
237
|
+
body.gsub!(%r|<COMMENT_BLOCK_NOT_EXIST>(.+?)</COMMENT_BLOCK_NOT_EXIST>|m) { entry[:comments] ? "" : parse(:comments, $1) }
|
238
|
+
body.gsub!(%r|<COMMENT_ALLOWED_BLOCK>(.+?)</COMMENT_ALLOWED_BLOCK>|m) { entry[:comments_allowed] ? parse(:comments, $1) : "" }
|
239
|
+
body.gsub!(%r|<COMMENT_NONE_BLOCK>(.+?)</COMMENT_NONE_BLOCK>|m) { entry[:comments_allowed] ? "" : parse(:comments, $1) }
|
209
240
|
|
210
241
|
|
211
242
|
|
@@ -260,7 +291,7 @@ def parse(type, body)
|
|
260
291
|
FORM
|
261
292
|
|
262
293
|
|
263
|
-
body.gsub!(%r|<COMMENT_FORM_BLOCK>(
|
294
|
+
body.gsub!(%r|<COMMENT_FORM_BLOCK>(.+?)</COMMENT_FORM_BLOCK>|m) { $1 }
|
264
295
|
|
265
296
|
tag body, "COMMENT_FORM_ACTION", "/lawl"
|
266
297
|
tag body, "COMMENT_FORM_BODY", "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."
|
@@ -277,9 +308,9 @@ def parse(type, body)
|
|
277
308
|
when :login
|
278
309
|
|
279
310
|
when :page
|
280
|
-
tag body, "PAGE_SUBJECT",
|
281
|
-
tag body, "PAGE_TITLE",
|
282
|
-
tag body, "PAGE_CONTENT",
|
311
|
+
tag body, "PAGE_SUBJECT", @Jogger[:pages].first[:subject]
|
312
|
+
tag body, "PAGE_TITLE", @Jogger[:pages].first[:subject]
|
313
|
+
tag body, "PAGE_CONTENT", @Jogger[:pages].first[:content]
|
283
314
|
else
|
284
315
|
|
285
316
|
end
|
@@ -293,6 +324,8 @@ app = Proc.new do |env|
|
|
293
324
|
if path =~ %r[/files/]
|
294
325
|
Rack::File.new(Dir.pwd).call(env)
|
295
326
|
else
|
327
|
+
@Jogger = YAML.load(File.read("content.yml"))
|
328
|
+
|
296
329
|
content = case path
|
297
330
|
when "/"
|
298
331
|
parse :entries, File.read("Szablon wpisów.html")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teamon-rubber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tymon Tobolski
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-16 00:00:00 -07:00
|
13
13
|
default_executable: rubber
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,6 +32,16 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: "0"
|
34
34
|
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: ezcrypto
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.7.0
|
44
|
+
version:
|
35
45
|
description: "Edytor szablon\xC3\xB3w Joggera"
|
36
46
|
email: i@teamon.eu
|
37
47
|
executables:
|