instiki 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. data/README +172 -0
  2. data/app/controllers/wiki.rb +389 -0
  3. data/app/models/author.rb +4 -0
  4. data/app/models/chunks/category.rb +31 -0
  5. data/app/models/chunks/chunk.rb +20 -0
  6. data/app/models/chunks/engines.rb +38 -0
  7. data/app/models/chunks/include.rb +29 -0
  8. data/app/models/chunks/literal.rb +19 -0
  9. data/app/models/chunks/match.rb +19 -0
  10. data/app/models/chunks/nowiki.rb +31 -0
  11. data/app/models/chunks/test.rb +18 -0
  12. data/app/models/chunks/uri.rb +97 -0
  13. data/app/models/chunks/wiki.rb +82 -0
  14. data/app/models/page.rb +86 -0
  15. data/app/models/page_lock.rb +24 -0
  16. data/app/models/page_set.rb +64 -0
  17. data/app/models/revision.rb +90 -0
  18. data/app/models/web.rb +89 -0
  19. data/app/models/wiki_content.rb +105 -0
  20. data/app/models/wiki_service.rb +83 -0
  21. data/app/models/wiki_words.rb +25 -0
  22. data/app/views/bottom.rhtml +4 -0
  23. data/app/views/markdown_help.rhtml +16 -0
  24. data/app/views/navigation.rhtml +19 -0
  25. data/app/views/rdoc_help.rhtml +16 -0
  26. data/app/views/static_style_sheet.rhtml +199 -0
  27. data/app/views/textile_help.rhtml +28 -0
  28. data/app/views/top.rhtml +49 -0
  29. data/app/views/wiki/authors.rhtml +13 -0
  30. data/app/views/wiki/edit.rhtml +31 -0
  31. data/app/views/wiki/edit_web.rhtml +138 -0
  32. data/app/views/wiki/export.rhtml +14 -0
  33. data/app/views/wiki/feeds.rhtml +10 -0
  34. data/app/views/wiki/list.rhtml +57 -0
  35. data/app/views/wiki/locked.rhtml +14 -0
  36. data/app/views/wiki/login.rhtml +11 -0
  37. data/app/views/wiki/new.rhtml +27 -0
  38. data/app/views/wiki/new_system.rhtml +78 -0
  39. data/app/views/wiki/new_web.rhtml +64 -0
  40. data/app/views/wiki/page.rhtml +81 -0
  41. data/app/views/wiki/print.rhtml +16 -0
  42. data/app/views/wiki/published.rhtml +10 -0
  43. data/app/views/wiki/recently_revised.rhtml +30 -0
  44. data/app/views/wiki/revision.rhtml +81 -0
  45. data/app/views/wiki/rollback.rhtml +31 -0
  46. data/app/views/wiki/rss_feed.rhtml +22 -0
  47. data/app/views/wiki/search.rhtml +15 -0
  48. data/app/views/wiki/tex.rhtml +23 -0
  49. data/app/views/wiki/tex_web.rhtml +35 -0
  50. data/app/views/wiki/web_list.rhtml +13 -0
  51. data/app/views/wiki_words_help.rhtml +8 -0
  52. data/instiki +67 -0
  53. data/libraries/action_controller_servlet.rb +177 -0
  54. data/libraries/diff/diff.rb +475 -0
  55. data/libraries/erb.rb +490 -0
  56. data/libraries/madeleine_service.rb +68 -0
  57. data/libraries/rdocsupport.rb +156 -0
  58. data/libraries/redcloth_for_tex.rb +869 -0
  59. data/libraries/view_helper.rb +33 -0
  60. data/libraries/web_controller_server.rb +81 -0
  61. metadata +142 -0
@@ -0,0 +1,33 @@
1
+ module ViewHelper
2
+ # Accepts a container (hash, array, enumerable, your type) and returns a string of option tags. Given a container
3
+ # where the elements respond to first and last (such as a two-element array), the "lasts" serve as option values and
4
+ # the "firsts" as option text. Hashes are turned into this form automatically, so the keys become "firsts" and values
5
+ # become lasts. If +selected+ is specified, the matching "last" or element will get the selected option-tag.
6
+ #
7
+ # Examples (call, result):
8
+ # html_options([["Dollar", "$"], ["Kroner", "DKK"]])
9
+ # <option value="$">Dollar</option>\n<option value="DKK">Kroner</option>
10
+ #
11
+ # html_options([ "VISA", "Mastercard" ], "Mastercard")
12
+ # <option>VISA</option>\n<option selected>Mastercard</option>
13
+ #
14
+ # html_options({ "Basic" => "$20", "Plus" => "$40" }, "$40")
15
+ # <option value="$20">Basic</option>\n<option value="$40" selected>Plus</option>
16
+ def html_options(container, selected = nil)
17
+ container = container.to_a if Hash === container
18
+
19
+ html_options = container.inject([]) do |options, element|
20
+ if element.respond_to?(:first) && element.respond_to?(:last)
21
+ if element.last != selected
22
+ options << "<option value=\"#{element.last}\">#{element.first}</option>"
23
+ else
24
+ options << "<option value=\"#{element.last}\" selected>#{element.first}</option>"
25
+ end
26
+ else
27
+ options << ((element != selected) ? "<option>#{element}</option>" : "<option selected>#{element}</option>")
28
+ end
29
+ end
30
+
31
+ html_options.join("\n")
32
+ end
33
+ end
@@ -0,0 +1,81 @@
1
+ require 'webrick'
2
+ include WEBrick
3
+
4
+ # Terminology:
5
+ # * Static controller: Is a controller that has all it's show_* and do_* methods mounted by the server
6
+ # at server start, so the server will handle request rejection of invalid requests
7
+ # * Dynamic controller: Is a controller that's mounted with a responsibility to handle all the request mapping
8
+ # itself. Hence, the server will never reject a request that's below the controller in the path.
9
+ class WebControllerServer
10
+ STATIC_MOUNTING = 1
11
+ DYNAMIC_MOUNTING = 2
12
+
13
+ MOUNT_TYPE = DYNAMIC_MOUNTING
14
+
15
+ SERVER_TYPE = (RUBY_PLATFORM =~ /mswin/ ? SimpleServer : Daemon)
16
+
17
+ def initialize(port, server_type, controller_path)
18
+ @server = WEBrick::HTTPServer::new(:Port => port, :ServerType => server_type || SERVER_TYPE)
19
+ @server.logger.info "Your WEBrick server is now running on http://localhost:#{port}"
20
+ @controller_path = controller_path
21
+ mount_controllers
22
+ start_server
23
+ end
24
+
25
+ private
26
+ # Mounts all the controllers in the controller_path according to the mount type
27
+ def mount_controllers
28
+ require_controller_files
29
+
30
+ case MOUNT_TYPE
31
+ when STATIC_MOUNTING then controller_names.each { |name| mount_static_controller(name) }
32
+ when DYNAMIC_MOUNTING then controller_names.each { |name| mount_dynamic_controller(name) }
33
+ end
34
+ end
35
+
36
+ # Mounts the controller specified by <tt>controller_name</tt> to accept all requests below it's path.
37
+ # If more than one controller is mounted by this WebControllerServer, the controller is mounted by name,
38
+ # such that fx WikiController would get the requests of "/wiki/something" and "/wiki/some/thing/else".
39
+ # If only one controller is mounted, all requests to this WebControllerServer is handled by that controller
40
+ def mount_dynamic_controller(controller_name)
41
+ mount_path = mounting_multiple_controllers? ? "/#{controller_name}" : "/"
42
+ @server.mount(mount_path, controller_class(controller_name))
43
+ end
44
+
45
+ # Mount all public show_* and do_* methods as actions tied to the controller specified by <tt>controller_name</tt>.
46
+ # If more than one controller is mounted by this WebControllerServer, the actions are mounted below the controller
47
+ # in the path, such as "/wiki/page" or "/wiki/list". If only one controller is mounted, they're mounted directly on
48
+ # the root, such as "/page" or "/list"
49
+ def mount_static_controller(controller_name)
50
+ controller_class(controller_name).public_instance_methods(false).each { |method|
51
+ mount_path = (mounting_multiple_controllers? ? "/#{controller_name}" : "") + "/#{method}"
52
+ @server.mount(mount_path, controller_class(controller_name))
53
+ }
54
+ end
55
+
56
+ # Requires all the controller files that are present in the controller_path
57
+ def require_controller_files
58
+ controller_names.each { |controller| require @controller_path + controller }
59
+ end
60
+
61
+ # Returns true if more than one controller exists in the controller_path
62
+ def mounting_multiple_controllers?
63
+ controller_names.length > 1
64
+ end
65
+
66
+ # Returns a list of controller names in lower-case from the controller path
67
+ def controller_names
68
+ Dir.entries(@controller_path).delete_if { |file| file !~ /rb$/ }.collect{ |c| c[0..-4] }
69
+ end
70
+
71
+ # Returns the class of the controller specified by the <tt>controller_name</tt>
72
+ def controller_class(controller_name)
73
+ eval(controller_name.capitalize + "Controller")
74
+ end
75
+
76
+ # Start accepting requests to the defined mount points
77
+ def start_server
78
+ trap("INT") { @server.shutdown }
79
+ @server.start
80
+ end
81
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.4
3
+ specification_version: 1
4
+ name: instiki
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.9.2
7
+ date: 2005-01-07
8
+ summary: Easy to install WikiClone running on WEBrick and Madeleine
9
+ require_paths:
10
+ - libraries
11
+ email: david@loudthinking.com
12
+ homepage: http://www.instiki.org
13
+ rubyforge_project: instiki
14
+ description: Instiki is a Wiki Clone written in Ruby that ships with an embedded webserver. You can setup up an Instiki in just a few steps. Possibly the simplest wiki setup ever.
15
+ autorequire:
16
+ default_executable: instiki
17
+ bindir: "."
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ -
22
+ - ">"
23
+ - !ruby/object:Gem::Version
24
+ version: 0.0.0
25
+ version:
26
+ platform: ruby
27
+ authors:
28
+ - David Heinemeier Hansson
29
+ files:
30
+ - README
31
+ - instiki
32
+ - app/controllers/wiki.rb
33
+ - app/models/author.rb
34
+ - app/models/page.rb
35
+ - app/models/page_lock.rb
36
+ - app/models/page_set.rb
37
+ - app/models/revision.rb
38
+ - app/models/web.rb
39
+ - app/models/wiki_content.rb
40
+ - app/models/wiki_service.rb
41
+ - app/models/wiki_words.rb
42
+ - app/models/chunks/category.rb
43
+ - app/models/chunks/chunk.rb
44
+ - app/models/chunks/engines.rb
45
+ - app/models/chunks/include.rb
46
+ - app/models/chunks/literal.rb
47
+ - app/models/chunks/match.rb
48
+ - app/models/chunks/nowiki.rb
49
+ - app/models/chunks/test.rb
50
+ - app/models/chunks/uri.rb
51
+ - app/models/chunks/wiki.rb
52
+ - app/views/bottom.rhtml
53
+ - app/views/markdown_help.rhtml
54
+ - app/views/navigation.rhtml
55
+ - app/views/rdoc_help.rhtml
56
+ - app/views/static_style_sheet.rhtml
57
+ - app/views/textile_help.rhtml
58
+ - app/views/top.rhtml
59
+ - app/views/wiki_words_help.rhtml
60
+ - app/views/wiki/authors.rhtml
61
+ - app/views/wiki/edit.rhtml
62
+ - app/views/wiki/edit_web.rhtml
63
+ - app/views/wiki/export.rhtml
64
+ - app/views/wiki/feeds.rhtml
65
+ - app/views/wiki/list.rhtml
66
+ - app/views/wiki/locked.rhtml
67
+ - app/views/wiki/login.rhtml
68
+ - app/views/wiki/new.rhtml
69
+ - app/views/wiki/new_system.rhtml
70
+ - app/views/wiki/new_web.rhtml
71
+ - app/views/wiki/page.rhtml
72
+ - app/views/wiki/print.rhtml
73
+ - app/views/wiki/published.rhtml
74
+ - app/views/wiki/recently_revised.rhtml
75
+ - app/views/wiki/revision.rhtml
76
+ - app/views/wiki/rollback.rhtml
77
+ - app/views/wiki/rss_feed.rhtml
78
+ - app/views/wiki/search.rhtml
79
+ - app/views/wiki/tex.rhtml
80
+ - app/views/wiki/tex_web.rhtml
81
+ - app/views/wiki/web_list.rhtml
82
+ - libraries/action_controller_servlet.rb
83
+ - libraries/erb.rb
84
+ - libraries/madeleine_service.rb
85
+ - libraries/rdocsupport.rb
86
+ - libraries/redcloth_for_tex.rb
87
+ - libraries/view_helper.rb
88
+ - libraries/web_controller_server.rb
89
+ - libraries/diff/diff.rb
90
+ test_files: []
91
+ rdoc_options:
92
+ - "--title"
93
+ - "Instiki -- The Wiki"
94
+ - "--line-numbers"
95
+ - "--inline-source"
96
+ extra_rdoc_files: []
97
+ executables:
98
+ - instiki
99
+ extensions: []
100
+ requirements:
101
+ - none
102
+ dependencies:
103
+ - !ruby/object:Gem::Dependency
104
+ name: madeleine
105
+ version_requirement:
106
+ version_requirements: !ruby/object:Gem::Version::Requirement
107
+ requirements:
108
+ -
109
+ - "="
110
+ - !ruby/object:Gem::Version
111
+ version: 0.7.1
112
+ version:
113
+ - !ruby/object:Gem::Dependency
114
+ name: BlueCloth
115
+ version_requirement:
116
+ version_requirements: !ruby/object:Gem::Version::Requirement
117
+ requirements:
118
+ -
119
+ - "="
120
+ - !ruby/object:Gem::Version
121
+ version: 1.0.0
122
+ version:
123
+ - !ruby/object:Gem::Dependency
124
+ name: RedCloth
125
+ version_requirement:
126
+ version_requirements: !ruby/object:Gem::Version::Requirement
127
+ requirements:
128
+ -
129
+ - "="
130
+ - !ruby/object:Gem::Version
131
+ version: 2.0.11
132
+ version:
133
+ - !ruby/object:Gem::Dependency
134
+ name: rubyzip
135
+ version_requirement:
136
+ version_requirements: !ruby/object:Gem::Version::Requirement
137
+ requirements:
138
+ -
139
+ - "="
140
+ - !ruby/object:Gem::Version
141
+ version: 0.5.5
142
+ version: