camping 1.5.180 → 2.0.rc0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/CHANGELOG +35 -0
  2. data/README +43 -68
  3. data/Rakefile +155 -86
  4. data/bin/camping +64 -246
  5. data/book/01_introduction +19 -0
  6. data/book/02_getting_started +443 -0
  7. data/book/51_upgrading +93 -0
  8. data/doc/api.html +1953 -0
  9. data/doc/book.html +73 -0
  10. data/doc/book/01_introduction.html +57 -0
  11. data/doc/book/02_getting_started.html +573 -0
  12. data/doc/book/51_upgrading.html +146 -0
  13. data/doc/created.rid +1 -0
  14. data/{extras → doc/images}/Camping.gif +0 -0
  15. data/doc/images/loadingAnimation.gif +0 -0
  16. data/{extras → doc/images}/permalink.gif +0 -0
  17. data/doc/index.html +148 -0
  18. data/doc/js/camping.js +79 -0
  19. data/doc/js/jquery.js +32 -0
  20. data/doc/rdoc.css +117 -0
  21. data/examples/blog.rb +280 -181
  22. data/extras/images/badge.gif +0 -0
  23. data/extras/images/boys-life.png +0 -0
  24. data/extras/images/deerputer.png +0 -0
  25. data/extras/images/diagram.png +0 -0
  26. data/extras/images/hill.png +0 -0
  27. data/extras/images/i-wish.png +0 -0
  28. data/extras/images/latl.png +0 -0
  29. data/extras/images/little-wheels.png +0 -0
  30. data/extras/images/square-badge.png +0 -0
  31. data/extras/images/uniform.png +0 -0
  32. data/extras/images/whale-bounce.png +0 -0
  33. data/extras/rdoc/generator/singledarkfish.rb +205 -0
  34. data/extras/rdoc/generator/template/flipbook/images/Camping.gif +0 -0
  35. data/extras/rdoc/generator/template/flipbook/images/loadingAnimation.gif +0 -0
  36. data/extras/rdoc/generator/template/flipbook/images/permalink.gif +0 -0
  37. data/extras/rdoc/generator/template/flipbook/js/camping.js +79 -0
  38. data/extras/rdoc/generator/template/flipbook/js/jquery.js +32 -0
  39. data/extras/rdoc/generator/template/flipbook/page.rhtml +30 -0
  40. data/extras/rdoc/generator/template/flipbook/rdoc.css +117 -0
  41. data/extras/rdoc/generator/template/flipbook/readme.rhtml +31 -0
  42. data/extras/rdoc/generator/template/flipbook/reference.rhtml +71 -0
  43. data/extras/rdoc/generator/template/flipbook/toc.rhtml +43 -0
  44. data/lib/camping-unabridged.rb +420 -481
  45. data/lib/camping.rb +40 -55
  46. data/lib/camping/{db.rb → ar.rb} +5 -8
  47. data/lib/camping/mab.rb +26 -0
  48. data/lib/camping/reloader.rb +175 -147
  49. data/lib/camping/server.rb +178 -0
  50. data/lib/camping/session.rb +34 -121
  51. data/test/apps/env_debug.rb +65 -0
  52. data/test/apps/forms.rb +95 -0
  53. data/test/apps/forward_to_other_controller.rb +60 -0
  54. data/test/apps/migrations.rb +97 -0
  55. data/test/apps/misc.rb +86 -0
  56. data/test/apps/sessions.rb +38 -0
  57. metadata +120 -80
  58. data/doc/camping.1.gz +0 -0
  59. data/examples/campsh.rb +0 -630
  60. data/examples/tepee.rb +0 -242
  61. data/extras/flipbook_rdoc.rb +0 -491
  62. data/lib/camping/fastcgi.rb +0 -244
  63. data/lib/camping/webrick.rb +0 -65
  64. data/test/test_xhtml_trans.rb +0 -55
data/doc/camping.1.gz DELETED
Binary file
data/examples/campsh.rb DELETED
@@ -1,630 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $:.unshift File.dirname(__FILE__) + "/../../lib"
4
- %w(rubygems redcloth camping acts_as_versioned).each { |lib| require lib }
5
-
6
- Camping.goes :CampSh
7
-
8
- module CampSh
9
- NAME = 'CampSh'
10
- DESCRIPTION = %{
11
- Script your own URL commands, then run these commands through
12
- the proxy with "cmd/CommandName". All scripts are versioned
13
- and attributed.
14
- }
15
- VERSION = '0.1'
16
- ANON = 'AnonymousCoward'
17
-
18
- begin
19
- require 'syntax/convertors/html'
20
- SYNTAX = ::Syntax::Convertors::HTML.for_syntax "ruby"
21
- rescue LoadError
22
- end
23
-
24
- def self.create
25
- Models.create_schema :assume => (Models::Command.table_exists? ? 1.0 : 0.0)
26
- end
27
- end
28
-
29
- module CampSh::Models
30
- class Command < Base
31
- validates_uniqueness_of :name
32
- validates_presence_of :author
33
- acts_as_versioned
34
- end
35
- class CreateBasics < V 1.0
36
- def self.up
37
- create_table :campsh_commands, :force => true do |t|
38
- t.column :id, :integer, :null => false
39
- t.column :author, :string, :limit => 40
40
- t.column :name, :string, :limit => 255
41
- t.column :created_at, :datetime
42
- t.column :doc, :text
43
- t.column :code, :text
44
- end
45
- Command.create_versioned_table
46
- Command.reset_column_information
47
- end
48
- def self.down
49
- drop_table :campsh_commands
50
- Command.drop_versioned_table
51
- end
52
- end
53
- end
54
-
55
- module CampSh::Controllers
56
- class Index < R '/'
57
- def get
58
- redirect List
59
- end
60
- end
61
-
62
- class List
63
- def get
64
- @cmds = Command.find :all, :order => 'name'
65
- @title = "Command List"
66
- render :list
67
- end
68
- end
69
-
70
- class Run < R '/run/(\w+)', '/run/(\w+)/(.+)', '/run/(\w+) (.+)'
71
- def get(cmd, args=nil)
72
- @cmd = Command.find_by_name(cmd)
73
- unless @cmd
74
- redirect New, name
75
- return
76
- end
77
-
78
- args = args.to_s.strip.split(/[\/\s]+/)
79
- eval(@cmd.code)
80
- end
81
- end
82
-
83
- class Authors
84
- def get
85
- @authors =
86
- Command.find(:all, :order => "author, name").inject({}) do |hsh, cmd|
87
- (hsh[cmd.author] ||= []) << cmd
88
- hsh
89
- end
90
- @title = "Author"
91
- render :authors
92
- end
93
- end
94
-
95
- class Recent
96
- def get
97
- @days =
98
- Command.find(:all, :order => "created_at DESC").inject({}) do |hsh, cmd|
99
- (hsh[cmd.created_at.strftime("%B %d, %Y")] ||= []) << cmd
100
- hsh
101
- end
102
- @title = "Recently Revised"
103
- render :recent
104
- end
105
- end
106
-
107
- class Show < R '/show/(\w+)', '/show/(\w+)/(\d+)', '/cancel_edit/(\w+)'
108
- def get(name, version = nil)
109
- unless @cmd = Command.find_by_name(name)
110
- redirect(Edit, name)
111
- return
112
- end
113
- @version = (version.nil? or version == @cmd.version.to_s) ? @cmd : @cmd.versions.find_by_version(version)
114
- render :show
115
- end
116
- end
117
-
118
- class New < R '/new', '/new/(\w+)'
119
- def get(name)
120
- @cmd = Command.new(:name => name)
121
- @title = "Creating #{name}"
122
- render :edit
123
- end
124
- def post
125
- @cmd = Command.new(:name => input.cmd)
126
- @title = "Creating #{input.cmd}"
127
- render :edit
128
- end
129
- end
130
-
131
- class Edit < R '/edit/(\w+)', '/edit/(\w+)/(\d+)'
132
- def get(name, version = nil)
133
- @cmd = Command.find_by_name(name)
134
- @cmd = @cmd.versions.find_by_version(version) unless version.nil? or version == @cmd.version.to_s
135
- @title = "Editing #{name}"
136
- @author = @cookies.cmd_author || CampSh::ANON
137
- render :edit
138
- end
139
- def post(name)
140
- @cookies.cmd_author = input.command.author
141
- Command.find_or_create_by_name(name).update_attributes(input.command)
142
- redirect Show, name
143
- end
144
- end
145
-
146
- class HowTo
147
- def get
148
- @title = "How To"
149
- render :howto
150
- end
151
- end
152
-
153
- class Style < R '/styles.css'
154
- def get
155
- @headers['Content-Type'] = 'text/css'
156
- %Q[
157
- h1#pageName, .newWikiWord a, a.existingWikiWord, .newWikiWord a:hover,
158
- #TextileHelp h3 { color: #003B76; }
159
-
160
- #container { width: 720px; }
161
-
162
- #container {
163
- float: none;
164
- margin: 0 auto;
165
- text-align: center;
166
- padding: 2px;
167
- border: solid 2px #999;
168
- }
169
-
170
- #content {
171
- margin: 0;
172
- padding: 9px;
173
- text-align: left;
174
- border-top: none;
175
- border: solid 1px #999;
176
- background-color: #eee;
177
- }
178
-
179
- body, p, ol, ul, td {
180
- font-family: verdana, arial, helvetica, sans-serif;
181
- font-size: 15px;
182
- line-height: 110%;
183
- }
184
-
185
- a { color: #000; }
186
-
187
- .newWikiWord { background-color: #eee; }
188
- .newWikiWord a:hover { background-color: white; }
189
-
190
- a:visited { color: #666; }
191
- a:hover { color: #fff; background-color:#000; }
192
-
193
- /* a.edit:link, a.edit:visited { color: #DA0006; } */
194
-
195
-
196
- h1, h2, h3 { color: #333; font-family: georgia, verdana; text-align: center; line-height: 70%; margin-bottom: 0; }
197
- h1 { font-size: 28px }
198
- h2 { font-size: 22px }
199
- h3 { font-size: 19px }
200
-
201
- h1#pageName {
202
- margin: 5px 0px 0px 0px;
203
- padding: 0px 0px 0px 0px;
204
- line-height: 28px;
205
- }
206
-
207
- h1#pageName small {
208
- color: grey;
209
- line-height: 10px;
210
- font-size: 10px;
211
- padding: 0px;
212
- }
213
-
214
- a.nav, a.nav:link, a.nav:visited { color: #000; }
215
- a.nav:hover { color: #fff; background-color:#000; }
216
-
217
- li { margin-bottom: 7px }
218
-
219
- .navigation {
220
- margin-top: 5px;
221
- font-size : 12px;
222
- color: #999;
223
- text-align: center;
224
- }
225
-
226
- .navigation a:hover { color: #fff; background-color:#000; }
227
-
228
- .navigation a {
229
- font-size: 11px;
230
- color: black;
231
- font-weight: bold;
232
- }
233
-
234
- .navigation small a {
235
- font-weight: normal;
236
- font-size: 11px;
237
- }
238
-
239
- .navOn{
240
- font-size: 11px;
241
- color: grey;
242
- font-weight: bold;
243
- text-decoration: none;
244
- }
245
-
246
- .help {
247
- font-family: verdana, arial, helvetica, sans-serif;
248
- font-size: 11px;
249
- }
250
-
251
- .inputBox {
252
- font-family: verdana, arial, helvetica, sans-serif;
253
- font-size: 11px;
254
- background-color: #eee;
255
- padding: 5px;
256
- margin-bottom: 20px;
257
- }
258
-
259
- blockquote {
260
- display: block;
261
- margin: 0px 0px 20px 0px;
262
- padding: 0px 30px;
263
- font-size:11px;
264
- line-height:17px;
265
- font-style: italic;
266
- }
267
-
268
- pre {
269
- background-color: #eee;
270
- padding: 10px;
271
- font-size: 11px;
272
- }
273
-
274
- ol.setup {
275
- font-size: 19px;
276
- font-family: georgia, verdana;
277
- padding-left: 25px;
278
- }
279
-
280
- ol.setup li {
281
- margin-bottom: 20px
282
- }
283
-
284
- .byline {
285
- font-size: 10px;
286
- font-style: italic;
287
- margin-bottom: 10px;
288
- color: #999;
289
- }
290
-
291
- .references {
292
- font-size: 10px;
293
- }
294
-
295
- .diffdel {
296
- background: pink;
297
- }
298
-
299
- .diffins {
300
- background: lightgreen;
301
- }
302
-
303
- #allCommands ul {
304
- list-style: none;
305
- }
306
-
307
- #allCommands li {
308
- padding: 1px 4px;
309
- }
310
-
311
- #allCommands li:hover {
312
- background-color: white;
313
- }
314
-
315
- #allCommands a,
316
- #allCommands a:hover,
317
- #allCommands a:link,
318
- #allCommands a:visited,
319
- #allCommands h2 {
320
- color: #369;
321
- background-color: transparent;
322
- font-weight: normal;
323
- font-size: 24px;
324
- text-align: left;
325
- }
326
-
327
- #TextileHelp table {
328
- margin-bottom: 0;
329
- }
330
-
331
- #TextileHelp table+h3 {
332
- margin-top: 11px;
333
- }
334
-
335
- #TextileHelp table td {
336
- font-size: 11px;
337
- padding: 3px;
338
- vertical-align: top;
339
- border-top: 1px dotted #ccc;
340
- }
341
-
342
- #TextileHelp table td.arrow {
343
- padding-right: 5px;
344
- padding-left: 10px;
345
- color: #999;
346
- }
347
-
348
- #TextileHelp table td.label {
349
- font-weight: bold;
350
- white-space: nowrap;
351
- font-size: 10px;
352
- padding-right: 15px;
353
- color: #000;
354
- }
355
-
356
- #TextileHelp h3 {
357
- font-size: 11px;
358
- font-weight: bold;
359
- font-weight: normal;
360
- margin: 0 0 5px 0;
361
- padding: 5px 0 0 0;
362
- }
363
-
364
- #TextileHelp p {
365
- font-size: 10px;
366
- }
367
-
368
- .rightHandSide {
369
- float: right;
370
- width: 147px;
371
- margin-left: 10px;
372
- padding-left: 20px;
373
- border-left: 1px dotted #ccc;
374
- }
375
-
376
- .rightHandSide p {
377
- font-size: 10px;
378
- }
379
-
380
- .newsList {
381
- margin-top: 20px;
382
- }
383
-
384
- .newsList p {
385
- margin-bottom:30px
386
- }
387
-
388
- .leftHandSide
389
- {
390
- float: right;
391
- width: 147px;
392
- margin-left: 10px;
393
- padding-left: 20px;
394
- border-left: 1px dotted #ccc;
395
- }
396
-
397
- .leftHandSide p
398
- {
399
- font-size: 10px;
400
- margin: 0;
401
- padding: 0;
402
- }
403
-
404
- .leftHandSide h2
405
- {
406
- font-size: 12px;
407
- margin-bottom: 0;
408
- padding-bottom: 0;
409
- }
410
-
411
- .property
412
- {
413
- color: grey;
414
- font-size: 9px;
415
- text-align: right;
416
- }
417
-
418
- body
419
- {
420
- background-color: #ccc;
421
- padding: 0;
422
- margin: 20px;
423
- color: #333;
424
- line-height: 1.5;
425
- font-size: 85%;
426
- /* hacky hack */
427
- voice-family: "\"}\"";
428
- voice-family: inherit;
429
- font-size: 80%;
430
- }
431
-
432
- /* be nice to opera */
433
- html>body { font-size: 80%; }
434
-
435
- /* syntax highlighting */
436
- .keyword {
437
- font-weight: bold;
438
- }
439
- .comment {
440
- color: #555;
441
- }
442
- .string, .number {
443
- color: #396;
444
- }
445
- .regex {
446
- color: #435;
447
- }
448
- .ident {
449
- color: #369;
450
- }
451
- .symbol {
452
- color: #000;
453
- }
454
- .constant, .class {
455
- color: #630;
456
- font-weight: bold;
457
- }
458
- ]
459
- end
460
- end
461
-
462
- end
463
-
464
- module CampSh::Views
465
- def red( str )
466
- require 'redcloth'
467
- self << RedCloth.new( str ).to_html
468
- end
469
-
470
- def layout
471
- html do
472
- head do
473
- title "CampShell -- #{ @title }"
474
- style "@import '#{ self / R(Style) }';", :type => 'text/css'
475
- end
476
- body do
477
- div.container! do
478
- div.content! do
479
- h2 "CampShell"
480
- h1 @title
481
- _navigation
482
- self << yield
483
- end
484
- end
485
- end
486
- end
487
- end
488
-
489
- def _navigation
490
- form :id => "navigationForm", :class => "navigation", :style => "font-size: 10px" do
491
- [["Command List", R(List), "Alphabetical list of commands", "A"],
492
- ["Recently Revised", R(Recent), "Pages sorted by when they were last changed", "U"],
493
- ["Authors", R(Authors), "Who wrote what", "W"],
494
- ["How To", R(HowTo), "How to use CampShell", "H"]
495
- ].map do |txt, link, title, key|
496
- a txt, :href => link, :title => title, :accesskey => key
497
- end.join(" | ")
498
- end
499
- end
500
-
501
- def list
502
- div.allCommands! :style => "width: 500px; margin: 0 100px" do
503
- form.editForm! :action => R(New), :method => "post" do
504
- ul do
505
- if @cmds.each do |cmd|
506
- li do
507
- h2 { a cmd.name, :href => R(Show, cmd.name) }
508
- red cmd.doc
509
- end
510
- end.empty?
511
- h2 "No commands created yet."
512
- end
513
-
514
- li do
515
- text "Create command: "
516
- input :type => "text", :name => "cmd", :id=> "newCmd", :value => "shortcut",
517
- :onClick => "this.value == 'shortcut' ? this.value = '' : true"
518
- end
519
- end
520
- end
521
- end
522
- end
523
-
524
- def authors
525
- ul.authorList! do
526
- @authors.each do |author, cmds|
527
- li do
528
- strong(author) + " worked on: " +
529
- cmds.map { |cmd| a cmd.name, :href => R(Show, cmd.name) }.join(", ")
530
- end
531
- end
532
- end
533
- end
534
-
535
- def recent
536
- @days.each do |day, cmds|
537
- strong day
538
- ul do
539
- cmds.each do |cmd|
540
- li do
541
- a cmd.name, :href => R(Show, cmd.name)
542
- div.byline "by #{ cmd.author } at #{ cmd.created_at.strftime("%H:%M") }"
543
- end
544
- end
545
- end
546
- end
547
- end
548
-
549
- def show
550
- h2 "Instructions"
551
- red @version.doc
552
-
553
- h2 "Code"
554
- if defined? SYNTAX
555
- SYNTAX.convert(@version.code)
556
- else
557
- pre @version.code
558
- end
559
-
560
- div.byline "Revised on #{ @version.created_at } by #{ @version.author }"
561
-
562
- div.navigation do
563
- a "Edit Page", :href => R(Edit, @version.name, @version.version),
564
- :class => "navlink", :accesskey => "E"
565
- unless @version.version == 1
566
- text " | "
567
- a 'Back in time', :href => R(Show, @version.name, @version.version-1)
568
- end
569
- unless @version.version == @cmd.version
570
- text " | "
571
- a 'Next', :href => R(Show, @version.name, @version.version+1)
572
- text " | "
573
- a 'Current', :href => R(Show, @version.name)
574
- end
575
- if @cmd.versions.size > 1
576
- small "(#{ @cmd.versions.size } revisions)"
577
- end
578
- end
579
- end
580
-
581
- def edit
582
- form :id => "editForm", :action => R(Edit, @cmd.name), :method => "post", :onSubmit => "cleanAuthorName();" do
583
- div :style => "margin: 0 100px;" do
584
- h2 "Instructions"
585
- textarea @cmd.doc, :name => "command[doc]", :style => "width: 450px; height: 120px"
586
-
587
- h2 "Code"
588
- textarea @cmd.code, :name => "command[code]", :style => "width: 450px; height: 380px"
589
-
590
- p do
591
- input :type => "submit", :value => "Save"; text " as "
592
- input :type => "text", :name => "command[author]", :id => "authorName", :value => @author,
593
- :onClick => "this.value == '#{ CampSh::ANON }' ? this.value = '' : true"; text " | "
594
- a "Cancel", :href => "/cancel_edit/#{ @cmd.name }"
595
- end
596
- end
597
-
598
- script <<-END, :language => "JavaScript1.2"
599
- function cleanAuthorName() {
600
- if (document.getElementById('authorName').value == "") {
601
- document.getElementById('authorName').value = '#{ @anon }';
602
- }
603
- }
604
- END
605
- end
606
- end
607
-
608
- def howto
609
- red %[
610
- Here's the rundown on CampShell. It's wiki-like storage for simple Ruby scripts. You can then run these scripts from
611
- the URL. So, your job is to fill up CampShell with these commands, some of which can be found
612
- "here":http://mousehole.rubyforge.org/wiki/wiki.pl?CampShells.
613
-
614
- h2. Using with Firefox
615
-
616
- For best effect, go to @about:config@ and set @keyword.URL@ to @http://#{env['HTTP_HOST']}#{self./ "/run/"}@. Restart Firefox,
617
- you will then be able to run commands directly from the address bar.
618
-
619
- For example:
620
-
621
- * @new google@ will open the page for creating a new @google@ command.
622
- * @show google@ will display the documentation for that command once it is saved.
623
- * @edit google@ will open the editor for the @google@ command.
624
- * @google mousehole commands@ will run the @google@ command with the arguments @mousehole@ and @commands@.
625
- * @list all@ or @keyword:list@ displays all commands.
626
- * @howto ?@ or @keyword:howto@ shoots you over to this page.
627
- ].gsub(/^ +/, '')
628
- end
629
- end
630
-