georgi-shinmun 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/.gitignore +3 -0
  2. data/LICENSE +18 -0
  3. data/README.md +361 -0
  4. data/Rakefile +17 -0
  5. data/bin/shinmun +12 -0
  6. data/example/Rakefile +41 -0
  7. data/example/assets/images/favicon.ico +0 -0
  8. data/example/assets/images/loading.gif +0 -0
  9. data/example/assets/javascripts/coderay.js +13 -0
  10. data/example/assets/javascripts/comments.js +45 -0
  11. data/example/assets/javascripts/jquery-form.min.js +5 -0
  12. data/example/assets/javascripts/jquery.min.js +32 -0
  13. data/example/assets/stylesheets/article.css +15 -0
  14. data/example/assets/stylesheets/coderay.css +100 -0
  15. data/example/assets/stylesheets/comments.css +20 -0
  16. data/example/assets/stylesheets/form.css +12 -0
  17. data/example/assets/stylesheets/list.css +13 -0
  18. data/example/assets/stylesheets/print.css +76 -0
  19. data/example/assets/stylesheets/reset.css +23 -0
  20. data/example/assets/stylesheets/style.css +83 -0
  21. data/example/assets/stylesheets/table.css +24 -0
  22. data/example/assets/stylesheets/typo.css +40 -0
  23. data/example/assets/wmd/images/bg-fill.png +0 -0
  24. data/example/assets/wmd/images/bg.png +0 -0
  25. data/example/assets/wmd/images/blockquote.png +0 -0
  26. data/example/assets/wmd/images/bold.png +0 -0
  27. data/example/assets/wmd/images/code.png +0 -0
  28. data/example/assets/wmd/images/h1.png +0 -0
  29. data/example/assets/wmd/images/hr.png +0 -0
  30. data/example/assets/wmd/images/img.png +0 -0
  31. data/example/assets/wmd/images/italic.png +0 -0
  32. data/example/assets/wmd/images/link.png +0 -0
  33. data/example/assets/wmd/images/ol.png +0 -0
  34. data/example/assets/wmd/images/redo.png +0 -0
  35. data/example/assets/wmd/images/separator.png +0 -0
  36. data/example/assets/wmd/images/ul.png +0 -0
  37. data/example/assets/wmd/images/undo.png +0 -0
  38. data/example/assets/wmd/images/wmd-on.png +0 -0
  39. data/example/assets/wmd/images/wmd.png +0 -0
  40. data/example/assets/wmd/showdown.js +421 -0
  41. data/example/assets/wmd/wmd-base.js +1799 -0
  42. data/example/assets/wmd/wmd-plus.js +311 -0
  43. data/example/assets/wmd/wmd.js +73 -0
  44. data/example/config.ru +8 -0
  45. data/example/config/aggregations.yml +1 -0
  46. data/example/config/assets.yml +13 -0
  47. data/example/config/blog.yml +10 -0
  48. data/example/map.rb +100 -0
  49. data/example/pages/about.md +6 -0
  50. data/example/password +1 -0
  51. data/example/templates/_comment_form.rhtml +90 -0
  52. data/example/templates/_comments.rhtml +11 -0
  53. data/example/templates/_pagination.rhtml +10 -0
  54. data/example/templates/admin/commit.rhtml +27 -0
  55. data/example/templates/admin/commits.rhtml +9 -0
  56. data/example/templates/admin/edit.rhtml +17 -0
  57. data/example/templates/admin/pages.rhtml +19 -0
  58. data/example/templates/admin/posts.rhtml +24 -0
  59. data/example/templates/category.rhtml +12 -0
  60. data/example/templates/category.rxml +20 -0
  61. data/example/templates/index.rhtml +12 -0
  62. data/example/templates/index.rxml +21 -0
  63. data/example/templates/layout.rhtml +82 -0
  64. data/example/templates/page.rhtml +7 -0
  65. data/example/templates/post.rhtml +48 -0
  66. data/lib/shinmun.rb +21 -0
  67. data/lib/shinmun/aggregations/delicious.rb +57 -0
  68. data/lib/shinmun/aggregations/flickr.rb +81 -0
  69. data/lib/shinmun/blog.rb +165 -0
  70. data/lib/shinmun/bluecloth_coderay.rb +21 -0
  71. data/lib/shinmun/comment.rb +17 -0
  72. data/lib/shinmun/helpers.rb +64 -0
  73. data/lib/shinmun/post.rb +161 -0
  74. data/lib/shinmun/post_handler.rb +17 -0
  75. data/templates/_comments.rhtml +11 -0
  76. data/templates/archive.rhtml +6 -0
  77. data/templates/category.rhtml +6 -0
  78. data/templates/category.rxml +20 -0
  79. data/templates/index.rhtml +4 -0
  80. data/templates/index.rxml +21 -0
  81. data/templates/layout.rhtml +9 -0
  82. data/templates/page.rhtml +2 -0
  83. data/templates/post.rhtml +3 -0
  84. data/test/blog_spec.rb +177 -0
  85. data/test/map.rb +51 -0
  86. metadata +172 -0
@@ -0,0 +1,311 @@
1
+ var Attacklab=Attacklab||{};
2
+ Attacklab.wmdPlus=function(){
3
+ this.symboltable;
4
+ var _1=top;
5
+ var _2=_1["Attacklab"];
6
+ var _3=_1["document"];
7
+ var _4=_1["RegExp"];
8
+ var _5=_1["navigator"];
9
+ var _6=_2.Util;
10
+ var _7=_2.Position;
11
+ var _8=_2.Command;
12
+ _8.doAutoindent=function(_9){
13
+ _9.before=_9.before.replace(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]*\n$/,"\n\n");
14
+ _9.before=_9.before.replace(/(\n|^)[ ]{0,3}>[ \t]*\n$/,"\n\n");
15
+ _9.before=_9.before.replace(/(\n|^)[ \t]+\n$/,"\n\n");
16
+ if(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]+.*\n$/.test(_9.before)){
17
+ if(_8.doList){
18
+ _8.doList(_9);
19
+ }
20
+ }
21
+ if(/(\n|^)[ ]{0,3}>[ \t]+.*\n$/.test(_9.before)){
22
+ if(_8.doBlockquote){
23
+ _8.doBlockquote(_9);
24
+ }
25
+ }
26
+ if(/(\n|^)(\t|[ ]{4,}).*\n$/.test(_9.before)){
27
+ if(_8.doCode){
28
+ _8.doCode(_9);
29
+ }
30
+ }
31
+ };
32
+ _8.doBlockquote=function(_a){
33
+ _a.selection=_a.selection.replace(/^(\n*)([^\r]+?)(\n*)$/,function(_b,_c,_d,_e){
34
+ _a.before+=_c;
35
+ _a.after=_e+_a.after;
36
+ return _d;
37
+ });
38
+ _a.before=_a.before.replace(/(>[ \t]*)$/,function(_f,_10){
39
+ _a.selection=_10+_a.selection;
40
+ return "";
41
+ });
42
+ _a.selection=_a.selection.replace(/^(\s|>)+$/,"");
43
+ _a.selection=_a.selection||"Blockquote";
44
+ if(_a.before){
45
+ _a.before=_a.before.replace(/\n?$/,"\n");
46
+ }
47
+ if(_a.after){
48
+ _a.after=_a.after.replace(/^\n?/,"\n");
49
+ }
50
+ _a.before=_a.before.replace(/(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*$)/,function(_11){
51
+ _a.startTag=_11;
52
+ return "";
53
+ });
54
+ _a.after=_a.after.replace(/^(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*)/,function(_12){
55
+ _a.endTag=_12;
56
+ return "";
57
+ });
58
+ var _13=function(_14){
59
+ var _15=_14?"> ":"";
60
+ if(_a.startTag){
61
+ _a.startTag=_a.startTag.replace(/\n((>|\s)*)\n$/,function(_16,_17){
62
+ return "\n"+_17.replace(/^[ ]{0,3}>?[ \t]*$/gm,_15)+"\n";
63
+ });
64
+ }
65
+ if(_a.endTag){
66
+ _a.endTag=_a.endTag.replace(/^\n((>|\s)*)\n/,function(_18,_19){
67
+ return "\n"+_19.replace(/^[ ]{0,3}>?[ \t]*$/gm,_15)+"\n";
68
+ });
69
+ }
70
+ };
71
+ if(/^(?![ ]{0,3}>)/m.test(_a.selection)){
72
+ _8.wrap(_a,_2.wmd_env.lineLength-2);
73
+ _a.selection=_a.selection.replace(/^/gm,"> ");
74
+ _13(true);
75
+ _a.skipLines();
76
+ }else{
77
+ _a.selection=_a.selection.replace(/^[ ]{0,3}> ?/gm,"");
78
+ _8.unwrap(_a);
79
+ _13(false);
80
+ if(!/^(\n|^)[ ]{0,3}>/.test(_a.selection)){
81
+ if(_a.startTag){
82
+ _a.startTag=_a.startTag.replace(/\n{0,2}$/,"\n\n");
83
+ }
84
+ }
85
+ if(!/(\n|^)[ ]{0,3}>.*$/.test(_a.selection)){
86
+ if(_a.endTag){
87
+ _a.endTag=_a.endTag.replace(/^\n{0,2}/,"\n\n");
88
+ }
89
+ }
90
+ }
91
+ if(!/\n/.test(_a.selection)){
92
+ _a.selection=_a.selection.replace(/^(> *)/,function(_1a,_1b){
93
+ _a.startTag+=_1b;
94
+ return "";
95
+ });
96
+ }
97
+ };
98
+ _8.doCode=function(_1c){
99
+ var _1d=/\S[ ]*$/.test(_1c.before);
100
+ var _1e=/^[ ]*\S/.test(_1c.after);
101
+ if((!_1e&&!_1d)||/\n/.test(_1c.selection)){
102
+ _1c.before=_1c.before.replace(/[ ]{4}$/,function(_1f){
103
+ _1c.selection=_1f+_1c.selection;
104
+ return "";
105
+ });
106
+ var _20=1;
107
+ var _21=1;
108
+ if(/\n(\t|[ ]{4,}).*\n$/.test(_1c.before)){
109
+ _20=0;
110
+ }
111
+ if(/^\n(\t|[ ]{4,})/.test(_1c.after)){
112
+ _21=0;
113
+ }
114
+ _1c.skipLines(_20,_21);
115
+ if(!_1c.selection){
116
+ _1c.startTag=" ";
117
+ _1c.selection="print(\"code sample\");";
118
+ return;
119
+ }
120
+ if(/^[ ]{0,3}\S/m.test(_1c.selection)){
121
+ _1c.selection=_1c.selection.replace(/^/gm," ");
122
+ }else{
123
+ _1c.selection=_1c.selection.replace(/^[ ]{4}/gm,"");
124
+ }
125
+ }else{
126
+ _1c.trimWhitespace();
127
+ _1c.findTags(/`/,/`/);
128
+ if(!_1c.startTag&&!_1c.endTag){
129
+ _1c.startTag=_1c.endTag="`";
130
+ if(!_1c.selection){
131
+ _1c.selection="print(\"code sample\");";
132
+ }
133
+ }else{
134
+ if(_1c.endTag&&!_1c.startTag){
135
+ _1c.before+=_1c.endTag;
136
+ _1c.endTag="";
137
+ }else{
138
+ _1c.startTag=_1c.endTag="";
139
+ }
140
+ }
141
+ }
142
+ };
143
+ _8.autoindent={};
144
+ _8.autoindent.textOp=_8.doAutoindent;
145
+ _8.blockquote={};
146
+ _8.blockquote.description="Blockquote <blockquote>";
147
+ _8.blockquote.image="images/blockquote.png";
148
+ _8.blockquote.key=".";
149
+ _8.blockquote.keyCode=190;
150
+ _8.blockquote.textOp=function(_22){
151
+ return _8.doBlockquote(_22);
152
+ };
153
+ _8.code={};
154
+ _8.code.description="Code Sample <pre><code>";
155
+ _8.code.image="images/code.png";
156
+ _8.code.key="k";
157
+ _8.code.textOp=_8.doCode;
158
+ _8.img={};
159
+ _8.img.description="Image <img>";
160
+ _8.img.image="images/img.png";
161
+ _8.img.key="g";
162
+ _8.img.textOp=function(_23,_24){
163
+ return _8.doLinkOrImage(_23,true,_24);
164
+ };
165
+ _8.doList=function(_25,_26){
166
+ var _27=/(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*/;
167
+ var _28="";
168
+ var _29=1;
169
+ var _2a=function(){
170
+ if(_26){
171
+ var _2b=" "+_29+". ";
172
+ _29++;
173
+ return _2b;
174
+ }
175
+ var _2c=_28||"-";
176
+ return " "+_2c+" ";
177
+ };
178
+ var _2d=function(_2e){
179
+ if(_26==undefined){
180
+ _26=/^\s*\d/.test(_2e);
181
+ }
182
+ _2e=_2e.replace(/^[ ]{0,3}([*+-]|\d+[.])\s/gm,function(_2f){
183
+ return _2a();
184
+ });
185
+ return _2e;
186
+ };
187
+ var _30=function(){
188
+ _31=_6.regexToString(_27);
189
+ _31.expression="^\n*"+_31.expression;
190
+ var _32=_6.stringToRegex(_31);
191
+ _25.after=_25.after.replace(_32,_2d);
192
+ };
193
+ _25.findTags(/(\n|^)*[ ]{0,3}([*+-]|\d+[.])\s+/,null);
194
+ var _33=/^\n/;
195
+ if(_25.before&&!/\n$/.test(_25.before)&&!_33.test(_25.startTag)){
196
+ _25.before+=_25.startTag;
197
+ _25.startTag="";
198
+ }
199
+ if(_25.startTag){
200
+ var _34=/\d+[.]/.test(_25.startTag);
201
+ _25.startTag="";
202
+ _25.selection=_25.selection.replace(/\n[ ]{4}/g,"\n");
203
+ _8.unwrap(_25);
204
+ _25.skipLines();
205
+ if(_34){
206
+ _30();
207
+ }
208
+ if(_26==_34){
209
+ return;
210
+ }
211
+ }
212
+ var _35=1;
213
+ var _31=_6.regexToString(_27);
214
+ _31.expression="(\\n|^)"+_31.expression+"$";
215
+ var _36=_6.stringToRegex(_31);
216
+ _25.before=_25.before.replace(_36,function(_37){
217
+ if(/^\s*([*+-])/.test(_37)){
218
+ _28=_4.$1;
219
+ }
220
+ _35=/[^\n]\n\n[^\n]/.test(_37)?1:0;
221
+ return _2d(_37);
222
+ });
223
+ if(!_25.selection){
224
+ _25.selection="List item";
225
+ }
226
+ var _38=_2a();
227
+ var _39=1;
228
+ _31=_6.regexToString(_27);
229
+ _31.expression="^\n*"+_31.expression;
230
+ _36=_6.stringToRegex(_31);
231
+ _25.after=_25.after.replace(_36,function(_3a){
232
+ _39=/[^\n]\n\n[^\n]/.test(_3a)?1:0;
233
+ return _2d(_3a);
234
+ });
235
+ _25.trimWhitespace(true);
236
+ _25.skipLines(_35,_39,true);
237
+ _25.startTag=_38;
238
+ var _3b=_38.replace(/./g," ");
239
+ _8.wrap(_25,_2.wmd_env.lineLength-_3b.length);
240
+ _25.selection=_25.selection.replace(/\n/g,"\n"+_3b);
241
+ };
242
+ _8.doHeading=function(_3c){
243
+ _3c.selection=_3c.selection.replace(/\s+/g," ");
244
+ _3c.selection=_3c.selection.replace(/(^\s+|\s+$)/g,"");
245
+ var _3d=0;
246
+ _3c.findTags(/#+[ ]*/,/[ ]*#+/);
247
+ if(/#+/.test(_3c.startTag)){
248
+ _3d=_4.lastMatch.length;
249
+ }
250
+ _3c.startTag=_3c.endTag="";
251
+ _3c.findTags(null,/\s?(-+|=+)/);
252
+ if(/=+/.test(_3c.endTag)){
253
+ _3d=1;
254
+ }
255
+ if(/-+/.test(_3c.endTag)){
256
+ _3d=2;
257
+ }
258
+ _3c.startTag=_3c.endTag="";
259
+ _3c.skipLines(1,1);
260
+ if(!_3c.selection){
261
+ _3c.startTag="## ";
262
+ _3c.selection="Heading";
263
+ _3c.endTag=" ##";
264
+ return;
265
+ }
266
+ var _3e=_3d==0?2:_3d-1;
267
+ if(_3e){
268
+ var _3f=_3e>=2?"-":"=";
269
+ var _40=_3c.selection.length;
270
+ if(_40>_2.wmd_env.lineLength){
271
+ _40=_2.wmd_env.lineLength;
272
+ }
273
+ _3c.endTag="\n";
274
+ while(_40--){
275
+ _3c.endTag+=_3f;
276
+ }
277
+ }
278
+ };
279
+ _8.ol={};
280
+ _8.ol.description="Numbered List <ol>";
281
+ _8.ol.image="images/ol.png";
282
+ _8.ol.key="o";
283
+ _8.ol.textOp=function(_41){
284
+ _8.doList(_41,true);
285
+ };
286
+ _8.ul={};
287
+ _8.ul.description="Bulleted List <ul>";
288
+ _8.ul.image="images/ul.png";
289
+ _8.ul.key="u";
290
+ _8.ul.textOp=function(_42){
291
+ _8.doList(_42,false);
292
+ };
293
+ _8.h1={};
294
+ _8.h1.description="Heading <h1>/<h2>";
295
+ _8.h1.image="images/h1.png";
296
+ _8.h1.key="h";
297
+ _8.h1.textOp=_8.doHeading;
298
+ _8.hr={};
299
+ _8.hr.description="Horizontal Rule <hr>";
300
+ _8.hr.image="images/hr.png";
301
+ _8.hr.key="r";
302
+ _8.hr.textOp=function(_43){
303
+ _43.startTag="----------\n";
304
+ _43.selection="";
305
+ _43.skipLines(2,1,true);
306
+ };
307
+ };
308
+ if(Attacklab.fileLoaded){
309
+ Attacklab.fileLoaded("wmd-plus.js");
310
+ }
311
+
@@ -0,0 +1,73 @@
1
+ var Attacklab=Attacklab||{};
2
+ Attacklab.wmd_env={};
3
+ Attacklab.account_options={};
4
+ Attacklab.wmd_defaults={version:1,output:"HTML",lineLength:40,delayLoad:false};
5
+ if(!Attacklab.wmd){
6
+ Attacklab.wmd=function(){
7
+ Attacklab.loadEnv=function(){
8
+ var _1=function(_2){
9
+ if(!_2){
10
+ return;
11
+ }
12
+ for(var _3 in _2){
13
+ Attacklab.wmd_env[_3]=_2[_3];
14
+ }
15
+ };
16
+ _1(Attacklab.wmd_defaults);
17
+ _1(Attacklab.account_options);
18
+ _1(top["wmd_options"]);
19
+ Attacklab.full=true;
20
+ var _4="bold italic | link blockquote code image | ol ul heading hr";
21
+ Attacklab.wmd_env.buttons=Attacklab.wmd_env.buttons||_4;
22
+ };
23
+ Attacklab.loadEnv();
24
+ var _5=["showdown.js","wmd-base.js","wmd-plus.js"];
25
+ var _6=function(_7){
26
+ };
27
+ Attacklab.fileLoaded=function(_8){
28
+ arguments.callee.count=arguments.callee.count||0;
29
+ if(++arguments.callee.count>=_5.length){
30
+ var go=function(){
31
+ Attacklab.wmdBase();
32
+ Attacklab.Util.startEditor();
33
+ };
34
+ if(Attacklab.wmd_env.delayLoad){
35
+ window.setTimeout(go,0);
36
+ }else{
37
+ go();
38
+ }
39
+ }
40
+ };
41
+ Attacklab.editorInit=function(){
42
+ Attacklab.wmdPlus();
43
+ };
44
+ var _a=function(_b,_c){
45
+ var _d=Attacklab.basePath+_b;
46
+ if(_c){
47
+ _d+="?nocache="+(new Date()).getTime();
48
+ }
49
+ var _e=document.createElement("script");
50
+ _e.src=_d;
51
+ top.document.documentElement.firstChild.appendChild(_e);
52
+ };
53
+ var _f=function(_10){
54
+ var _11=RegExp("(.*)"+_10+"(\\?(.+))?$","g");
55
+ var _12=document.getElementsByTagName("script");
56
+ for(var i=0;i<_12.length;i++){
57
+ if(_11.test(_12[i].src)){
58
+ var _14=RegExp.$1;
59
+ if(/wmd-editor.com/.test(_12[i].src)){
60
+ return null;
61
+ }
62
+ return _14;
63
+ }
64
+ }
65
+ };
66
+ Attacklab.basePath=_f("wmd.js")||"http://static.wmd-editor.com/v2/";
67
+ for(var f,i=0;f=_5[i];i++){
68
+ _a(f,false);
69
+ }
70
+ };
71
+ Attacklab.wmd();
72
+ }
73
+
data/example/config.ru ADDED
@@ -0,0 +1,8 @@
1
+ require 'shinmun'
2
+
3
+ Dir.chdir(File.dirname(__FILE__))
4
+
5
+ use Rack::Session::Cookie
6
+ use Rack::Reloader
7
+
8
+ run Shinmun::Blog.new
@@ -0,0 +1 @@
1
+ ---
@@ -0,0 +1,13 @@
1
+ ---
2
+ stylesheet_files:
3
+ - reset
4
+ - typo
5
+ - article
6
+ - comments
7
+ - coderay
8
+ - style
9
+ javascript_files:
10
+ - jquery.min
11
+ - jquery-form.min
12
+ - comments
13
+ - coderay
@@ -0,0 +1,10 @@
1
+ ---
2
+ language: en
3
+ title: Blog Title
4
+ repository: root@my-blog-url.com:/var/www/
5
+ url: http://www.my-blog-url.com
6
+ author: The Author
7
+ categories:
8
+ - Ruby
9
+ - Javascript
10
+ description: Blog description
data/example/map.rb ADDED
@@ -0,0 +1,100 @@
1
+ Kontrol.map do
2
+ get '/categories/(.*)\.rss' do |category|
3
+ render 'category.rxml', find_category(category)
4
+ end
5
+
6
+ get '/categories/(.*)' do |category|
7
+ render 'category.rhtml', find_category(category)
8
+ end
9
+
10
+ get '/(\d+)/(\d+)/(.*)' do |year, month, name|
11
+ post = find_post(year.to_i, month.to_i, name)
12
+ render 'post.rhtml', :post => post, :comments => comments_for(post)
13
+ end
14
+
15
+ get '/(\d+)/(\d+)' do |year, month|
16
+ render 'archive.rhtml', :year => year.to_i, :month => month.to_i
17
+ end
18
+
19
+ get '/index\.rss' do
20
+ render 'index.rxml'
21
+ end
22
+
23
+ post '/comments' do
24
+ post = find_by_path(params['path'])
25
+ post_comment(post, params)
26
+ render '_comments.rhtml', :comments => comments_for(post)
27
+ end
28
+
29
+ get '/assets/javascripts\.js' do
30
+ render_javascripts
31
+ end
32
+
33
+ get '/assets/stylesheets\.css' do
34
+ render_stylesheets
35
+ end
36
+
37
+ get '/assets/(.*)' do |path|
38
+ if_modified_since do
39
+ assets[path] or raise "#{path} not found"
40
+ end
41
+ end
42
+
43
+ map '/admin' do
44
+ use Rack::Auth::Basic do |username, password|
45
+ File.read(File.join(File.dirname(__FILE__), "password")).chomp("\n") == password
46
+ end
47
+
48
+ get '/posts/(.*)' do |page|
49
+ session[:admin] = true
50
+ render 'admin/posts.rhtml', :posts => posts_by_date, :page => page.to_i, :page_size => 10
51
+ end
52
+
53
+ get '/pages' do
54
+ render 'admin/pages.rhtml'
55
+ end
56
+
57
+ get '/commits/(.*)' do |id|
58
+ render 'admin/commit.rhtml', :commit => repo.commit(id)
59
+ end
60
+
61
+ get '/commits' do
62
+ render 'admin/commits.rhtml'
63
+ end
64
+
65
+ map '/edit/(.*)' do
66
+ get do |path|
67
+ render 'admin/edit.rhtml', :post => find_by_path(path)
68
+ end
69
+
70
+ post do |path|
71
+ update_post(post = find_by_path(path), params['data'])
72
+ redirect(post.date ? '/admin/posts/' : '/admin/pages')
73
+ end
74
+ end
75
+
76
+ post '/delete/(.*)' do |path|
77
+ delete_post(post = find_by_path(path))
78
+ redirect(post.date ? '/admin/posts/' : '/admin/pages/')
79
+ end
80
+
81
+ post '/create' do
82
+ post = create_post(params)
83
+ redirect "/admin/edit/#{post.path}"
84
+ end
85
+
86
+ get '' do
87
+ redirect '/admin/posts/'
88
+ end
89
+
90
+ end
91
+
92
+ get '/$' do
93
+ render 'index.rhtml'
94
+ end
95
+
96
+ get '/(.*)' do |path|
97
+ post = find_page(path)
98
+ render 'page.rhtml', :post => post if post
99
+ end
100
+ end