jogger 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.markdown +45 -0
- data/Rakefile +58 -0
- data/bin/jogger +6 -0
- data/lib/content.yml.sample +80 -0
- data/lib/jogger.rb +174 -0
- data/lib/new_entry.html.sample +1 -0
- data/lib/server.ru +367 -0
- metadata +91 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009-2010 Tymon Tobolski
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
Edytor szablonów Joggera
|
2
|
+
===============
|
3
|
+
|
4
|
+
Wymagania
|
5
|
+
---------
|
6
|
+
ruby ;]
|
7
|
+
|
8
|
+
Instalacja
|
9
|
+
----------
|
10
|
+
sudo gem install teamon-rubber
|
11
|
+
|
12
|
+
|
13
|
+
Konfiguracja
|
14
|
+
------------
|
15
|
+
mkdir my_jogger
|
16
|
+
cd my_jogger
|
17
|
+
rubber configure
|
18
|
+
|
19
|
+
|
20
|
+
Pobranie plików z Joggera
|
21
|
+
-------------------------
|
22
|
+
rubber download
|
23
|
+
|
24
|
+
|
25
|
+
Wysłanie zmodyfikowanych plików na Joggera
|
26
|
+
------------------------------------------
|
27
|
+
rubber upload files/my_file.html
|
28
|
+
|
29
|
+
|
30
|
+
Wysłanie wszystkich plików na Joggera
|
31
|
+
-------------------------------------
|
32
|
+
rubber upload files/*
|
33
|
+
|
34
|
+
|
35
|
+
Uruchomienie serwera
|
36
|
+
--------------------
|
37
|
+
rubber server
|
38
|
+
|
39
|
+
|
40
|
+
Twój jogger jest dostępny pod adresem http://localhost:1337
|
41
|
+
Przykładowe treści można zmienić w pliku content.yml
|
42
|
+
|
43
|
+
Podgląd nowego wpisu
|
44
|
+
--------------------
|
45
|
+
Dodając plik do folderu posty o nazwie np. "nowy post.html" będzie on dostępny pod adresem http://localhost:1337/nowy%20post
|
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
|
6
|
+
GEM_NAME = "jogger"
|
7
|
+
GEM_VERSION = "0.1.0"
|
8
|
+
AUTHOR = "Tymon Tobolski"
|
9
|
+
EMAIL = "i@teamon.eu"
|
10
|
+
HOMEPAGE = "http://blog.teamon.eu/projekty/"
|
11
|
+
SUMMARY = "Edytor szablonów Joggera"
|
12
|
+
|
13
|
+
spec = Gem::Specification.new do |s|
|
14
|
+
s.name = GEM_NAME
|
15
|
+
s.version = GEM_VERSION
|
16
|
+
s.has_rdoc = false
|
17
|
+
s.summary = SUMMARY
|
18
|
+
s.description = s.summary
|
19
|
+
s.author = AUTHOR
|
20
|
+
s.email = EMAIL
|
21
|
+
s.homepage = HOMEPAGE
|
22
|
+
s.require_path = 'lib'
|
23
|
+
s.bindir = 'bin'
|
24
|
+
s.executables = %w( jogger )
|
25
|
+
s.files = %w( LICENSE README.markdown Rakefile ) + Dir.glob("{bin,lib}/**/*")
|
26
|
+
s.add_dependency('mechanize', '>= 0.9.0')
|
27
|
+
s.add_dependency('thin')
|
28
|
+
s.add_dependency('ezcrypto', '>= 0.7.0')
|
29
|
+
end
|
30
|
+
|
31
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
32
|
+
pkg.gem_spec = spec
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Create a gemspec file"
|
36
|
+
task :gemspec do
|
37
|
+
File.open("#{GEM_NAME}.gemspec", "w") do |file|
|
38
|
+
file.puts spec.to_ruby
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# development
|
43
|
+
|
44
|
+
desc 'Strip trailing whitespace from source files'
|
45
|
+
task :strip do
|
46
|
+
Dir["#{File.dirname(__FILE__)}/**/*.rb"].each do |path|
|
47
|
+
content = File.open(path, 'r') do |f|
|
48
|
+
f.map { |line| line.gsub(/\G\s/, ' ').rstrip + "\n" }.join.rstrip
|
49
|
+
end + "\n"
|
50
|
+
|
51
|
+
if File.read(path) != content
|
52
|
+
puts "Stripping whitepsace from #{path}"
|
53
|
+
File.open(path, 'w') {|f| f.write content}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
data/bin/jogger
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
---
|
2
|
+
:entries:
|
3
|
+
- :subject: Lorem ipsum dolor sit amet
|
4
|
+
: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>
|
5
|
+
:date: 2009-05-08 22:19:41.282848 +02:00
|
6
|
+
:categories: [One, Two, Three]
|
7
|
+
:tags: [Ruby, Merb, Awesome]
|
8
|
+
:comments_allowed: true
|
9
|
+
:comments:
|
10
|
+
- :nick: teamon
|
11
|
+
:date: 2009-05-08 23:19:16.282848 +02:00
|
12
|
+
: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.
|
13
|
+
:favicon: http://blog.teamon.eu/files/favicon.png
|
14
|
+
:edit: true
|
15
|
+
:class: owner # owner, jogger, guest, trackback
|
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
|
+
|
32
|
+
- :subject: Consectetur adipisicing elit
|
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>
|
34
|
+
:date: 2009-05-08 22:19:41.282848 +02:00
|
35
|
+
:categories: [One, Two, Three]
|
36
|
+
:tags: [Ruby, Merb, Awesome]
|
37
|
+
:comments_allowed: true
|
38
|
+
:comments:
|
39
|
+
- :nick: teamon
|
40
|
+
:date: 2009-05-08 23:19:16.282848 +02:00
|
41
|
+
: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.
|
42
|
+
:favicon: http://blog.teamon.eu/files/favicon.png
|
43
|
+
:edit: true
|
44
|
+
:class: owner # owner, jogger, guest, trackback
|
45
|
+
- :nick: ivyl
|
46
|
+
:date: 2009-05-08 23:19:16.282848 +02:00
|
47
|
+
: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.
|
48
|
+
:favicon: http://blog.teamon.eu/files/favicon.png
|
49
|
+
:edit: false
|
50
|
+
:class: jogger # owner, jogger, guest, trackback
|
51
|
+
|
52
|
+
:archive:
|
53
|
+
- :name: Maj 2009
|
54
|
+
:entries: 10
|
55
|
+
- :name: Kwiecień 2009
|
56
|
+
:entries: 5
|
57
|
+
|
58
|
+
:categories:
|
59
|
+
- :name: Ruby
|
60
|
+
:entries: 10
|
61
|
+
:sub_level: 0
|
62
|
+
- :name: Merb
|
63
|
+
:entries: 5
|
64
|
+
:sub_level: 1
|
65
|
+
|
66
|
+
:links:
|
67
|
+
- :name: Friends
|
68
|
+
:links: [Dmilith, Ivyl]
|
69
|
+
- :name: Stuff
|
70
|
+
:links: ["Ruby on Rails", "Merb"]
|
71
|
+
|
72
|
+
:pages:
|
73
|
+
- :subject: Consectetur adipisicing elit
|
74
|
+
: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>
|
75
|
+
- :subject: Lorem ipsum dolor sit amet
|
76
|
+
: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>
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
data/lib/jogger.rb
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'mechanize'
|
4
|
+
require 'ezcrypto'
|
5
|
+
|
6
|
+
class Jogger
|
7
|
+
def initialize(args)
|
8
|
+
@args = args
|
9
|
+
@agent = WWW::Mechanize.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
case @args[0]
|
14
|
+
when 'configure'
|
15
|
+
configure
|
16
|
+
when 'download'
|
17
|
+
download
|
18
|
+
when 'upload'
|
19
|
+
@args.shift
|
20
|
+
upload(@args)
|
21
|
+
when 'server'
|
22
|
+
server
|
23
|
+
else
|
24
|
+
usage
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def ez
|
31
|
+
EzCrypto::Key.with_password "password", (RUBY_PLATFORM =~ /mswin32/ ? `hostname` : `uname -a`)
|
32
|
+
end
|
33
|
+
|
34
|
+
def load_config_file
|
35
|
+
if File.exists?("config.yml")
|
36
|
+
@config = YAML.load(File.read("config.yml"))
|
37
|
+
@config[:password] = ez.decrypt64 @config[:password]
|
38
|
+
else
|
39
|
+
puts "Brak pliku config.yml. Uruchom 'rubber configure'"
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def configure
|
45
|
+
print "jabber id: "
|
46
|
+
id = STDIN.gets.chomp
|
47
|
+
print "hasło: "
|
48
|
+
system "stty -echo"
|
49
|
+
pass = ez.encrypt64 STDIN.gets.chomp
|
50
|
+
system "stty echo"
|
51
|
+
puts
|
52
|
+
|
53
|
+
File.open("config.yml", "w") {|f| f.write YAML.dump({:jabber_id => id, :password => pass}) }
|
54
|
+
File.open("content.yml", "w") {|f| f.write File.read(File.join(File.dirname(__FILE__), "content.yml.sample")) } unless File.exists?("content.yml")
|
55
|
+
puts "Plik config.yml został utworzony."
|
56
|
+
end
|
57
|
+
|
58
|
+
def server
|
59
|
+
system("thin start -R #{File.join(File.dirname(__FILE__), "server.ru")} -p 1337")
|
60
|
+
end
|
61
|
+
|
62
|
+
def download
|
63
|
+
login
|
64
|
+
get_filemap
|
65
|
+
get_pagesmap
|
66
|
+
|
67
|
+
# files
|
68
|
+
Dir.mkdir("files") unless File.exists?("files")
|
69
|
+
@filemap.each do |filename, url|
|
70
|
+
puts "Pobieranie #{filename}"
|
71
|
+
|
72
|
+
if confirm(filename)
|
73
|
+
File.open(filename, 'wb') {|f| f.write @agent.get(url).body }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# strony
|
78
|
+
Dir.mkdir("strony") unless File.exists?("strony")
|
79
|
+
@pagesmap.each do |filename, url|
|
80
|
+
puts "Pobieranie #{filename}"
|
81
|
+
|
82
|
+
if confirm(filename)
|
83
|
+
File.open(filename, 'w') {|f| f.write @agent.get("https://login.jogger.pl#{url}").forms.first.templatesContent }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# posty
|
88
|
+
Dir.mkdir("posty") unless File.exists?("posty")
|
89
|
+
File.open(File.join("posty", "new_one.html"), 'w') {|f| f.write File.read(File.join(File.dirname(__FILE__), "new_entry.html.sample"))} unless File.exists?(File.join("posty", "new_one.html"))
|
90
|
+
end
|
91
|
+
|
92
|
+
def upload(files = [])
|
93
|
+
login
|
94
|
+
get_filemap
|
95
|
+
get_pagesmap
|
96
|
+
|
97
|
+
files.each do |file|
|
98
|
+
if url = @pagesmap[file]
|
99
|
+
form = @agent.get(url).forms.first
|
100
|
+
form.templatesContent = File.read(file)
|
101
|
+
form.submit
|
102
|
+
puts "Plik #{file} został zaktualizowany"
|
103
|
+
elsif url = @filemap[file] || file =~ %r[^files/]
|
104
|
+
form = @agent.get('https://login.jogger.pl/templates/files/').forms.first
|
105
|
+
form.file_uploads.first.file_name = file
|
106
|
+
form.submit
|
107
|
+
puts "Plik #{file} został zaktualizowany"
|
108
|
+
else
|
109
|
+
puts "Plik #{file} nie istnieje"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def confirm(filename)
|
115
|
+
if File.exists?(filename) && @args[1] != '--force'
|
116
|
+
puts "Plik #{filename} istnieje. Nadpisac? [T/N]"
|
117
|
+
|
118
|
+
loop do
|
119
|
+
print "> "
|
120
|
+
res = STDIN.gets.chomp.upcase
|
121
|
+
|
122
|
+
if res == "T"
|
123
|
+
return true
|
124
|
+
elsif res == "N"
|
125
|
+
return false
|
126
|
+
else
|
127
|
+
puts "Nie czaje..."
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
return true
|
134
|
+
end
|
135
|
+
|
136
|
+
def get_pagesmap
|
137
|
+
@pagesmap = Hash[*@agent.get('https://login.jogger.pl/templates/edit/').links.select{|e| e.href =~ %r[/templates/edit/\?page_id] }.map {|e| ["strony/#{e.text}.html", e.href]}.flatten]
|
138
|
+
@pagesmap["Szablon_wpisow.html"] ='/templates/edit/?file=entries'
|
139
|
+
@pagesmap["Szablon_komentarzy.html"] ='/templates/edit/?file=comments'
|
140
|
+
@pagesmap["Szablon_logowania.html"] ='/templates/edit/?file=login'
|
141
|
+
end
|
142
|
+
|
143
|
+
def get_filemap
|
144
|
+
@filemap = Hash[*@agent.get('https://login.jogger.pl/templates/files/').parser.css("td > a").map {|e| ["files/#{e.text}", e[:href]] }.flatten]
|
145
|
+
end
|
146
|
+
|
147
|
+
def login
|
148
|
+
load_config_file
|
149
|
+
form = @agent.get('https://login.jogger.pl/login/').forms.first
|
150
|
+
form.login_jabberid = @config[:jabber_id]
|
151
|
+
form.login_jabberpass = @config[:password]
|
152
|
+
page = form.submit
|
153
|
+
|
154
|
+
if page.uri.to_s == 'https://login.jogger.pl/login/'
|
155
|
+
puts "Identyfikator jabbera lub hasło jest nieporawne"
|
156
|
+
exit
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def usage
|
161
|
+
puts <<-USAGE
|
162
|
+
jogger [action]
|
163
|
+
|
164
|
+
actions:
|
165
|
+
configure - Konfiguracja loginu
|
166
|
+
download - Pobierz szablon z joggera
|
167
|
+
--force nadpisuje lokalne pliki bez pytania
|
168
|
+
upload [file] - Wyślij plik na serwer
|
169
|
+
server - Uruchom webserwer http://0.0.0.0:1337
|
170
|
+
USAGE
|
171
|
+
exit
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<p>Blah blah blah</p>
|
data/lib/server.ru
ADDED
@@ -0,0 +1,367 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rack/response'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
MONTHS = %w(stycznia lutego marca kwietnia maja czerwca lipa sierpnia września pażdziernika listopada grudnia)
|
7
|
+
|
8
|
+
def colorize!(content)
|
9
|
+
content.gsub!(%r|\{geshi +lang=(.+?)\}(.+?)\{/geshi\}|m) { "<pre>#{$2}</pre>" }
|
10
|
+
end
|
11
|
+
|
12
|
+
def tag(body, pattern, replacement)
|
13
|
+
body.gsub! %r|<#{pattern}/>|, replacement.to_s
|
14
|
+
body.gsub! %r|&#{pattern};|, replacement.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse_with_comment(body, comment, counter = 0)
|
18
|
+
tag body, "COMMENT_CLASS", "comment#{(counter % 2)+1}"
|
19
|
+
tag body, "COMMENT_EDIT_HREF", "/edit_me_please"
|
20
|
+
tag body, "COMMENT_NICK", comment[:nick]
|
21
|
+
tag body, "COMMENT_DATE", "#{comment[:date].day} #{MONTHS[comment[:date].month]} #{comment[:date].hour}"
|
22
|
+
tag body, "COMMENT_DATE_DAY", comment[:date].day
|
23
|
+
tag body, "COMMENT_DATE_MONTH", MONTHS[comment[:date].month]
|
24
|
+
tag body, "COMMENT_DATE_YEAR", comment[:date].year
|
25
|
+
tag body, "COMMENT_HOUR", comment[:date].hour
|
26
|
+
tag body, "COMMENT_NUMBER", counter+1
|
27
|
+
tag body, "COMMENT_CONTENT", comment[:content]
|
28
|
+
tag body, "COMMENT_FAVICON", comment[:favicon]
|
29
|
+
tag body, "COMMENT_FAVICON2", comment[:favicon]
|
30
|
+
tag body, "COMMENT_ID", rand(100)
|
31
|
+
tag body, "COMMENT_NICK_CLASS", comment[:class]
|
32
|
+
|
33
|
+
body.gsub!(%r|<COMMENT_FAVICON_EXIST>(.+?)</COMMENT_FAVICON_EXIST>|m) { comment[:favicon] ? parse_with_comment($1, comment, counter) : "" }
|
34
|
+
body.gsub!(%r|<COMMENT_FAVICON_NOT_EXIST>(.+?)</COMMENT_FAVICON_NOT_EXIST>|m) { comment[:favicon] ? "" : parse_with_comment($1, comment, counter) }
|
35
|
+
body.gsub!(%r|<COMMENT_EDIT_EXIST>(.+?)</COMMENT_EDIT_EXIST>|m) { comment[:edit] ? parse_with_comment($1, comment, counter) : "" }
|
36
|
+
end
|
37
|
+
|
38
|
+
def parse_with_entry(body, entry, counter = 0)
|
39
|
+
tag body, "ENTRY_SUBJECT", entry[:subject]
|
40
|
+
tag body, "ENTRY_TITLE", entry[:subject]
|
41
|
+
|
42
|
+
tag body, "ENTRY_DATE", "#{entry[:date].day} #{MONTHS[entry[:date].month]} #{entry[:date].hour}"
|
43
|
+
tag body, "ENTRY_DATE_DAY", entry[:date].day
|
44
|
+
tag body, "ENTRY_DATE_MONTH", MONTHS[entry[:date].month]
|
45
|
+
tag body, "ENTRY_DATE_YEAR", entry[:date].year
|
46
|
+
tag body, "ENTRY_HOUR", entry[:date].hour
|
47
|
+
|
48
|
+
tag body, "ENTRY_ID", rand(100)
|
49
|
+
tag body, "ENTRY_LEVEL", rand(3)
|
50
|
+
|
51
|
+
colorize!(entry[:content])
|
52
|
+
|
53
|
+
tag body, "ENTRY_CONTENT", entry[:content].sub(%r|<EXCERPT>|, "")
|
54
|
+
tag body, "ENTRY_CONTENT_LONG", entry[:content].split(%r|<EXCERPT>|).last
|
55
|
+
tag body, "ENTRY_CONTENT_SHORT", entry[:content].split(%r|<EXCERPT>|).first
|
56
|
+
body.gsub!(%r|<ENTRY_CONTENT_SHORT_EXIST>(.+?)</ENTRY_CONTENT_SHORT_EXIST>|m) { entry[:content]["<EXCERPT>"] ? parse_with_entry($1, entry) : "" }
|
57
|
+
body.gsub!(%r|<ENTRY_CONTENT_SHORT_NOT_EXIST>(.+?)</ENTRY_CONTENT_SHORT_NOT_EXIST>|m) { entry[:content]["<EXCERPT>"] ? "" : parse_with_entry($1, entry) }
|
58
|
+
|
59
|
+
tag body, "ENTRY_COMMENT_HREF", "/entry"
|
60
|
+
tag body, "ENTRY_COMMENT_HREF_DESCR", entry[:comments] ? "#{entry[:comments].size} komentarzy" : "Brak komentarzy"
|
61
|
+
tag body, "ENTRY_CLASS", "entry#{(counter % 2)+1}"
|
62
|
+
entry_counter = 0 if body["ENTRY_CLASS_RESET"]
|
63
|
+
|
64
|
+
body.gsub!(%r|<ENTRY_CATEGORY_BLOCK>(.+?)</ENTRY_CATEGORY_BLOCK>|m) do
|
65
|
+
category_block = $1
|
66
|
+
category_counter = -1
|
67
|
+
entry[:categories].map do |category|
|
68
|
+
catbody = category_block.dup
|
69
|
+
category_counter += 1
|
70
|
+
|
71
|
+
tag catbody, "ENTRY_CATEGORY_CLASS", "entrycategory#{(category_counter % 2)+1}"
|
72
|
+
tag catbody, "ENTRY_CATEGORY_HREF", "/za_duzo_bys_chcial"
|
73
|
+
tag catbody, "ENTRY_CATEGORY_HREF_DESCR", category
|
74
|
+
tag catbody, "ENTRY_CATEGORY_TITLE", category
|
75
|
+
catbody.gsub!(%r|<ENTRY_CATEGORY_NOT_LAST>(.+?)</ENTRY_CATEGORY_NOT_LAST>|m) { category_counter == entry[:categories].size-1 ? "" : $1 }
|
76
|
+
catbody
|
77
|
+
end.join
|
78
|
+
end
|
79
|
+
|
80
|
+
body.gsub!(%r|<ENTRY_TAG_BLOCK_EXIST>(.+?)</ENTRY_TAG_BLOCK_EXIST>|m) { entry[:tags] ? parse_with_entry($1, entry) : "" }
|
81
|
+
body.gsub!(%r|<ENTRY_TAG_BLOCK>(.+?)</ENTRY_TAG_BLOCK>|m) do
|
82
|
+
tag_block = $1
|
83
|
+
entry[:tags].map do |t|
|
84
|
+
tagbody = tag_block.dup
|
85
|
+
tag tagbody, "ENTRY_TAG_DESCR", t
|
86
|
+
tagbody
|
87
|
+
end.join
|
88
|
+
end
|
89
|
+
|
90
|
+
tag body, "ENTRY_TRACKBACK_HREF", entry[:trackback]
|
91
|
+
body.gsub!(%r|<ENTRY_TRACKBACK_EXIST>(.+?)</ENTRY_TRACKBACK_EXIST>|m) { entry[:trackback] ? parse_with_entry($1, entry) : "" }
|
92
|
+
body.gsub!(%r|<ENTRY_TRACKBACK_NOT_EXIST>(.+?)</ENTRY_TRACKBACK_NOT_EXIST>|m) { entry[:trackback] ? "" : parse_with_entry($1, entry) }
|
93
|
+
|
94
|
+
["PREV", "NEXT"].each do |type|
|
95
|
+
p = entry[type.downcase.to_sym]
|
96
|
+
|
97
|
+
body.gsub!(%r|<ENTRY_#{type}_EXIST>(.+?)</ENTRY_#{type}_EXIST>|m) { p ? parse_with_entry($1, entry) : "" }
|
98
|
+
body.gsub!(%r|<ENTRY_#{type}_NOT_EXIST>(.+?)</ENTRY_#{type}_NOT_EXIST>|m) { p ? "" : parse_with_entry($1, entry) }
|
99
|
+
|
100
|
+
if p
|
101
|
+
tag body, "ENTRY_#{type}_SUBJECT", p[:subject]
|
102
|
+
tag body, "ENTRY_#{type}_TITLE", p[:subject]
|
103
|
+
tag body, "ENTRY_#{type}_CONTENT", p[:content].sub(%r|<EXCERPT>|, "")
|
104
|
+
tag body, "ENTRY_#{type}_CONTENT_SHORT", p[:content].split(%r|<EXCERPT>|).first
|
105
|
+
tag body, "ENTRY_#{type}_DATE", "#{p[:date].day} #{MONTHS[p[:date].month]} #{p[:date].hour}"
|
106
|
+
tag body, "ENTRY_#{type}_HREF", "/entry"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
body.gsub!(%r|<ENTRY_IS_MINIBLOG>(.+?)</ENTRY_IS_MINIBLOG>|m) { entry[:miniblog] ? parse_with_entry($1, entry) : "" }
|
111
|
+
|
112
|
+
body
|
113
|
+
end
|
114
|
+
|
115
|
+
def parse(type, body)
|
116
|
+
body.gsub!(%r|<INCLUDE>(.+?)</INCLUDE>|) { parse nil, File.read("files/#{$1}") }
|
117
|
+
|
118
|
+
body.gsub!(%r|<ARCHIVE_BLOCK>(.+?)</ARCHIVE_BLOCK>|m) do
|
119
|
+
archive_block = $1
|
120
|
+
archive_counter = -1
|
121
|
+
@Jogger[:archive].map do |archive|
|
122
|
+
archive_counter += 1
|
123
|
+
archbody = archive_block.dup
|
124
|
+
|
125
|
+
tag archbody, "ARCHIVE_ENTRIES", archive[:entries]
|
126
|
+
tag archbody, "ARCHIVE_HREF", "/za_duzo_bys_chcial"
|
127
|
+
tag archbody, "ARCHIVE_HREF_DESCR", archive[:name]
|
128
|
+
tag archbody, "ARCHIVE_CLASS", "archive#{(archive_counter % 2)+1}"
|
129
|
+
tag archbody, "ARCHIVE_CURRENT_DESCR", "Maj 2009"
|
130
|
+
archbody.gsub!(%r|<ARCHIVE_NOT_LAST>(.+?)</ARCHIVE_NOT_LAST>|m) { archive_counter == @Jogger[:archive].size-1 ? "" : $1 }
|
131
|
+
archbody
|
132
|
+
end.join
|
133
|
+
end
|
134
|
+
|
135
|
+
body.gsub!(%r|<CATEGORY_BLOCK>(.+?)</CATEGORY_BLOCK>|m) do
|
136
|
+
category_block = $1
|
137
|
+
category_counter = -1
|
138
|
+
@Jogger[:categories].map do |category|
|
139
|
+
catbody = category_block.dup
|
140
|
+
category_counter += 1
|
141
|
+
|
142
|
+
tag catbody, "CATEGORY_CLASS", "category#{(category_counter % 2)+1}"
|
143
|
+
tag catbody, "CATEGORY_ENTRIES", category[:entries]
|
144
|
+
tag catbody, "CATEGORY_HREF", "/za_duzo_bys_chcial"
|
145
|
+
tag catbody, "CATEGORY_HREF_DESCR", category[:name]
|
146
|
+
tag catbody, "CATEGORY_TITLE", category[:name]
|
147
|
+
tag catbody, "CATEGORY_ID", category_counter
|
148
|
+
tag catbody, "CATEGORY_LEVEL", rand(6)
|
149
|
+
tag catbody, "CATEGORY_SUB_CLASS", "subcategory#{category[:sub]}"
|
150
|
+
catbody.gsub!(%r|<CATEGORY_NOT_LAST>(.+?)</CATEGORY_NOT_LAST>|m) { category_counter == @Jogger[:categories].size-1 ? "" : $1 }
|
151
|
+
catbody
|
152
|
+
end.join
|
153
|
+
end
|
154
|
+
|
155
|
+
body.gsub!(%r|<LINK_BLOCK_EXIST>(.+?)</LINK_BLOCK_EXIST>|m) { @Jogger[:links] ? parse(nil, $1) : "" }
|
156
|
+
|
157
|
+
body.gsub!(%r|<LINK_GROUP_BLOCK>(.+?)</LINK_GROUP_BLOCK>|m) do
|
158
|
+
link_group_block = $1
|
159
|
+
link_counter = -1
|
160
|
+
@Jogger[:links].map do |link_group|
|
161
|
+
grobody = link_group_block.dup
|
162
|
+
tag grobody, "LINK_GROUP_DESCR", link_group[:name]
|
163
|
+
|
164
|
+
grobody.gsub!(%r|<LINK_BLOCK>(.+?)</LINK_BLOCK>|m) do
|
165
|
+
link_block = $1
|
166
|
+
link_group[:links].map do |link|
|
167
|
+
link_counter += 1
|
168
|
+
linkbody = link_block.dup
|
169
|
+
|
170
|
+
tag linkbody, "LINK_HREF", "/za_duzo_bys_chcial"
|
171
|
+
tag linkbody, "LINK_HREF_DESCR", link
|
172
|
+
tag linkbody, "LINK_TITLE", link
|
173
|
+
tag linkbody, "LINK_CLASS", "link#{(link_counter % 2)+1}"
|
174
|
+
link_counter = -1 if linkbody["LINK_CLASS_RESET"]
|
175
|
+
|
176
|
+
linkbody
|
177
|
+
end.join
|
178
|
+
end
|
179
|
+
|
180
|
+
grobody
|
181
|
+
end.join
|
182
|
+
end
|
183
|
+
|
184
|
+
tag body, "JID", "me@jabber.foo"
|
185
|
+
tag body, "JOG_TITLE", "My super awesome jogger"
|
186
|
+
tag body, "JOG", "teamon"
|
187
|
+
tag body, "HOME", "/"
|
188
|
+
tag body, "RSS", "/rss"
|
189
|
+
tag body, "ALL_ENTRIES_HREF", "/"
|
190
|
+
tag body, "CURRENT_PAGE_HREF", "/entry"
|
191
|
+
|
192
|
+
tag body, "HEADER", <<-HEADER
|
193
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
194
|
+
<html lang="pl">
|
195
|
+
<head>
|
196
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
197
|
+
<meta name="robots" content="noindex, nofollow">
|
198
|
+
<title>Jogger :: teamon</title>
|
199
|
+
<link rel="StyleSheet" href="/files/style.css" type="text/css">
|
200
|
+
</head>
|
201
|
+
<body>
|
202
|
+
HEADER
|
203
|
+
|
204
|
+
tag body, "FOOTER", <<-FOOTER
|
205
|
+
</body>
|
206
|
+
</html>
|
207
|
+
FOOTER
|
208
|
+
|
209
|
+
case type
|
210
|
+
when :entries
|
211
|
+
body.gsub!(%r|<MINIBLOG_BLOCK>(.+?)</MINIBLOG_BLOCK>|m) do
|
212
|
+
$1.gsub!(%r|<ENTRY_BLOCK>(.+?)</ENTRY_BLOCK>|m) do
|
213
|
+
entry_block = $1
|
214
|
+
entry_counter = -1
|
215
|
+
@Jogger[:entries].select {|e| e[:miniblog] }.map {|entry| parse_with_entry(entry_block.dup, entry, entry_counter += 1) }.join
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
body.gsub!(%r|<ENTRY_BLOCK>(.+?)</ENTRY_BLOCK>|m) do
|
220
|
+
entry_block = $1
|
221
|
+
entry_counter = -1
|
222
|
+
@Jogger[:entries].reject {|e| e[:miniblog] }.map {|entry| parse_with_entry(entry_block.dup, entry, entry_counter += 1) }.join
|
223
|
+
end
|
224
|
+
|
225
|
+
body.gsub!(%r|<PAGE_BLOCK_EXIST>(.+?)</PAGE_BLOCK_EXIST>|) { parse(:entries, $1) }
|
226
|
+
body.gsub!(%r|<PAGE_PREV_EXIST>(.+?)</PAGE_PREV_EXIST>|) { parse(:entries, $1) }
|
227
|
+
body.gsub!(%r|<PAGE_NEXT_EXIST>(.+?)</PAGE_NEXT_EXIST>|) { parse(:entries, $1) }
|
228
|
+
tag body, "PAGE_PREV_HREF", "/prev"
|
229
|
+
tag body, "PAGE_NEXT_HREF", "/next"
|
230
|
+
|
231
|
+
|
232
|
+
when :comments
|
233
|
+
entry = @Jogger[:entries].first
|
234
|
+
parse_with_entry(body, entry)
|
235
|
+
|
236
|
+
body.gsub!(%r|<COMMENT_BLOCK>(.+?)</COMMENT_BLOCK>|m) do
|
237
|
+
comment_block = $1
|
238
|
+
comment_counter = -1
|
239
|
+
entry[:comments].map do |comment|
|
240
|
+
parse_with_comment(comment_block.dup, comment, comment_counter += 1)
|
241
|
+
end.join
|
242
|
+
end
|
243
|
+
|
244
|
+
body.gsub!(%r|<COMMENT_BLOCK_EXIST>(.+?)</COMMENT_BLOCK_EXIST>|m) { entry[:comments] ? parse(:comments, $1) : "" }
|
245
|
+
body.gsub!(%r|<COMMENT_BLOCK_NOT_EXIST>(.+?)</COMMENT_BLOCK_NOT_EXIST>|m) { entry[:comments] ? "" : parse(:comments, $1) }
|
246
|
+
body.gsub!(%r|<COMMENT_ALLOWED_BLOCK>(.+?)</COMMENT_ALLOWED_BLOCK>|m) { entry[:comments_allowed] ? parse(:comments, $1) : "" }
|
247
|
+
body.gsub!(%r|<COMMENT_NONE_BLOCK>(.+?)</COMMENT_NONE_BLOCK>|m) { entry[:comments_allowed] ? "" : parse(:comments, $1) }
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
tag body, "COMMENT_FORM", <<-FORM
|
252
|
+
<form action="[adres_wpisu]?op=addcomm" method="post" id="formcomment">
|
253
|
+
<fieldset>
|
254
|
+
<legend id="formname">Dodaj komentarz</legend>
|
255
|
+
<div class="commrow1">
|
256
|
+
<label id="commnicklab" for="commnickid">Podpis</label>
|
257
|
+
<input type="text" name="commnickid" id="commnickid" value="[Twój_jid]" />
|
258
|
+
</div>
|
259
|
+
<div class="commrow2">
|
260
|
+
<label id="commbodylab" for="commbody">Treść</label>
|
261
|
+
<textarea name="commbody" id="commbody" cols="60" rows="6"></textarea>
|
262
|
+
</div>
|
263
|
+
<div>
|
264
|
+
<input type="submit" name="submit" id="submitcomm" value="Wyślij komentarz " />
|
265
|
+
</div>
|
266
|
+
</fieldset>
|
267
|
+
</form>
|
268
|
+
FORM
|
269
|
+
|
270
|
+
tag body, "COMMENT_FORM2", <<-FORM
|
271
|
+
<form action="/comment.php" method="post">
|
272
|
+
<div>
|
273
|
+
<input type="hidden" name="jid" value="[jid_komentowanego]" />
|
274
|
+
<input type="hidden" name="eid" value="[id_wpisu]" />
|
275
|
+
<input type="hidden" name="startid" value="0" />
|
276
|
+
<input type="hidden" name="op" value="addcomm" />
|
277
|
+
</div>
|
278
|
+
<table>
|
279
|
+
<tr>
|
280
|
+
<td>Podpis:</td>
|
281
|
+
<td><input type="text" name="commnickid" id="commnickid" value="[Twój_jid]" /></td>
|
282
|
+
</tr>
|
283
|
+
<tr>
|
284
|
+
<td>Treść:</td>
|
285
|
+
<td><textarea name="commbody" id="commbody" cols="60" rows="6"></textarea></td>
|
286
|
+
</tr>
|
287
|
+
<tr>
|
288
|
+
<td> </td>
|
289
|
+
<td>
|
290
|
+
<input type="checkbox" name="notifyentry" value="notify" />Śledź ten wątek i powiadom mnie o nowych komentarzach
|
291
|
+
</td>
|
292
|
+
</tr>
|
293
|
+
<tr>
|
294
|
+
<td> </td>
|
295
|
+
<td><input type='submit' name="submit" id="submitcomm" value='Wyślij' /></td>
|
296
|
+
</tr>
|
297
|
+
</table>
|
298
|
+
</form>
|
299
|
+
FORM
|
300
|
+
|
301
|
+
|
302
|
+
body.gsub!(%r|<COMMENT_FORM_BLOCK>(.+?)</COMMENT_FORM_BLOCK>|m) { $1 }
|
303
|
+
|
304
|
+
tag body, "COMMENT_FORM_ACTION", "/lawl"
|
305
|
+
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."
|
306
|
+
tag body, "COMMENT_FORM_CODE", "..."
|
307
|
+
tag body, "COMMENT_FORM_NICKID", "teamon"
|
308
|
+
tag body, "COMMENT_FORM_NICKURL", "http://blog.teamon.eu"
|
309
|
+
|
310
|
+
body.gsub!(%r|<COMMENT_FORM_NOTIFY_START_BLOCK>(.+?)</COMMENT_FORM_NOTIFY_START_BLOCK>|m) { $1 }
|
311
|
+
body.gsub!(%r|<COMMENT_FORM_NOTIFY_STOP_BLOCK>(.+?)</COMMENT_FORM_NOTIFY_STOP_BLOCK>|m) { $1 }
|
312
|
+
body.gsub!(%r|<COMMENT_FORM_NOUSER_BLOCK>(.+?)</COMMENT_FORM_NOUSER_BLOCK>|m) { $1 }
|
313
|
+
body.gsub!(%r|<COMMENT_LOGGED_BLOCK>(.+?)</COMMENT_LOGGED_BLOCK>|) { "" }
|
314
|
+
body.gsub!(%r|<COMMENT_NONE_BLOCK>(.+?)</COMMENT_NONE_BLOCK>|m) { entry[:allowed_comments] ? "" : $1 }
|
315
|
+
|
316
|
+
when :login
|
317
|
+
|
318
|
+
when :page
|
319
|
+
tag body, "PAGE_SUBJECT", @Jogger[:pages].first[:subject]
|
320
|
+
tag body, "PAGE_TITLE", @Jogger[:pages].first[:subject]
|
321
|
+
tag body, "PAGE_CONTENT", @Jogger[:pages].first[:content]
|
322
|
+
else
|
323
|
+
|
324
|
+
end
|
325
|
+
|
326
|
+
body
|
327
|
+
end
|
328
|
+
|
329
|
+
app = Proc.new do |env|
|
330
|
+
path = env["REQUEST_URI"]
|
331
|
+
|
332
|
+
if path =~ %r[/files/]
|
333
|
+
Rack::File.new(Dir.pwd).call(env)
|
334
|
+
else
|
335
|
+
@Jogger = YAML.load(::File.read("content.yml"))
|
336
|
+
|
337
|
+
content = case path
|
338
|
+
when "/"
|
339
|
+
parse :entries, ::File.read("Szablon_wpisow.html")
|
340
|
+
when "/entry"
|
341
|
+
parse :comments, ::File.read("Szablon_komentarzy.html")
|
342
|
+
when "/login"
|
343
|
+
parse :login, ::File.read("Szablon_logowanie.html")
|
344
|
+
else
|
345
|
+
page_path = "strony/#{path.gsub('-', ' ').gsub('/', '').capitalize}.html"
|
346
|
+
title = URI.unescape(path.gsub('/', ''))
|
347
|
+
entry_path = "posty/#{title}.html"
|
348
|
+
|
349
|
+
if ::File.exists?(page_path)
|
350
|
+
parse :page, ::File.read(page_path)
|
351
|
+
elsif ::File.exists?(entry_path)
|
352
|
+
@Jogger[:entries][0][:subject] = title
|
353
|
+
@Jogger[:entries][0][:content] = ::File.read(entry_path)
|
354
|
+
parse :comments, ::File.read("Szablon_komentarzy.html")
|
355
|
+
|
356
|
+
else
|
357
|
+
["NotFound"]
|
358
|
+
end
|
359
|
+
|
360
|
+
end
|
361
|
+
|
362
|
+
[200, {"Content-type" => "text/html"}, content || ""]
|
363
|
+
end
|
364
|
+
|
365
|
+
end
|
366
|
+
|
367
|
+
run app
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jogger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tymon Tobolski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-05 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mechanize
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.9.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: thin
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
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:
|
45
|
+
description: "Edytor szablon\xC3\xB3w Joggera"
|
46
|
+
email: i@teamon.eu
|
47
|
+
executables:
|
48
|
+
- jogger
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files: []
|
52
|
+
|
53
|
+
files:
|
54
|
+
- LICENSE
|
55
|
+
- README.markdown
|
56
|
+
- Rakefile
|
57
|
+
- bin/jogger
|
58
|
+
- lib/content.yml.sample
|
59
|
+
- lib/jogger.rb
|
60
|
+
- lib/new_entry.html.sample
|
61
|
+
- lib/server.ru
|
62
|
+
has_rdoc: true
|
63
|
+
homepage: http://blog.teamon.eu/projekty/
|
64
|
+
licenses: []
|
65
|
+
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
version:
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.3.5
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: "Edytor szablon\xC3\xB3w Joggera"
|
90
|
+
test_files: []
|
91
|
+
|