Pimki 1.0.092

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/README +158 -0
  2. data/README-PIMKI +87 -0
  3. data/app/controllers/wiki.rb +563 -0
  4. data/app/models/author.rb +4 -0
  5. data/app/models/chunks/category.rb +31 -0
  6. data/app/models/chunks/category_test.rb +21 -0
  7. data/app/models/chunks/chunk.rb +20 -0
  8. data/app/models/chunks/engines.rb +34 -0
  9. data/app/models/chunks/include.rb +29 -0
  10. data/app/models/chunks/literal.rb +19 -0
  11. data/app/models/chunks/match.rb +19 -0
  12. data/app/models/chunks/nowiki.rb +31 -0
  13. data/app/models/chunks/nowiki_test.rb +14 -0
  14. data/app/models/chunks/test.rb +18 -0
  15. data/app/models/chunks/todo.rb +22 -0
  16. data/app/models/chunks/uri.rb +97 -0
  17. data/app/models/chunks/uri_test.rb +92 -0
  18. data/app/models/chunks/wiki.rb +82 -0
  19. data/app/models/chunks/wiki_test.rb +36 -0
  20. data/app/models/page.rb +91 -0
  21. data/app/models/page_lock.rb +24 -0
  22. data/app/models/page_set.rb +73 -0
  23. data/app/models/page_test.rb +76 -0
  24. data/app/models/revision.rb +91 -0
  25. data/app/models/revision_test.rb +252 -0
  26. data/app/models/web.rb +277 -0
  27. data/app/models/web_test.rb +53 -0
  28. data/app/models/wiki_content.rb +113 -0
  29. data/app/models/wiki_service.rb +137 -0
  30. data/app/models/wiki_service_test.rb +15 -0
  31. data/app/models/wiki_words.rb +26 -0
  32. data/app/models/wiki_words_test.rb +12 -0
  33. data/app/views/bottom.rhtml +4 -0
  34. data/app/views/markdown_help.rhtml +16 -0
  35. data/app/views/menu.rhtml +20 -0
  36. data/app/views/navigation.rhtml +26 -0
  37. data/app/views/rdoc_help.rhtml +16 -0
  38. data/app/views/static_style_sheet.rhtml +231 -0
  39. data/app/views/style.rhtml +179 -0
  40. data/app/views/textile_help.rhtml +28 -0
  41. data/app/views/top.rhtml +52 -0
  42. data/app/views/wiki/authors.rhtml +15 -0
  43. data/app/views/wiki/bliki.rhtml +101 -0
  44. data/app/views/wiki/bliki_edit.rhtml +33 -0
  45. data/app/views/wiki/bliki_new.rhtml +61 -0
  46. data/app/views/wiki/bliki_revision.rhtml +51 -0
  47. data/app/views/wiki/edit.rhtml +34 -0
  48. data/app/views/wiki/edit_menu.rhtml +27 -0
  49. data/app/views/wiki/edit_web.rhtml +139 -0
  50. data/app/views/wiki/export.rhtml +14 -0
  51. data/app/views/wiki/feeds.rhtml +10 -0
  52. data/app/views/wiki/list.rhtml +164 -0
  53. data/app/views/wiki/locked.rhtml +14 -0
  54. data/app/views/wiki/login.rhtml +11 -0
  55. data/app/views/wiki/mind.rhtml +39 -0
  56. data/app/views/wiki/new.rhtml +27 -0
  57. data/app/views/wiki/new_system.rhtml +78 -0
  58. data/app/views/wiki/new_web.rhtml +64 -0
  59. data/app/views/wiki/page.rhtml +84 -0
  60. data/app/views/wiki/print.rhtml +16 -0
  61. data/app/views/wiki/published.rhtml +10 -0
  62. data/app/views/wiki/recently_revised.rhtml +31 -0
  63. data/app/views/wiki/revision.rhtml +87 -0
  64. data/app/views/wiki/rss_feed.rhtml +22 -0
  65. data/app/views/wiki/search.rhtml +26 -0
  66. data/app/views/wiki/tex.rhtml +23 -0
  67. data/app/views/wiki/tex_web.rhtml +35 -0
  68. data/app/views/wiki/todo.rhtml +39 -0
  69. data/app/views/wiki/web_list.rhtml +13 -0
  70. data/app/views/wiki_words_help.rhtml +8 -0
  71. data/libraries/action_controller_servlet.rb +177 -0
  72. data/libraries/bluecloth.rb +1127 -0
  73. data/libraries/diff/diff.rb +475 -0
  74. data/libraries/diff/diff_test.rb +80 -0
  75. data/libraries/erb.rb +490 -0
  76. data/libraries/madeleine/automatic.rb +357 -0
  77. data/libraries/madeleine/clock.rb +94 -0
  78. data/libraries/madeleine_service.rb +69 -0
  79. data/libraries/rdocsupport.rb +156 -0
  80. data/libraries/redcloth_for_tex.rb +869 -0
  81. data/libraries/redcloth_for_tex_test.rb +41 -0
  82. data/libraries/view_helper.rb +33 -0
  83. data/libraries/web_controller_server.rb +95 -0
  84. data/pimki.rb +97 -0
  85. metadata +169 -0
@@ -0,0 +1,41 @@
1
+ require "test/unit"
2
+ require "redcloth_for_tex"
3
+
4
+ class RedClothForTexTest < Test::Unit::TestCase
5
+ def test_basics
6
+ assert_equal '{\bf First Page}', RedClothForTex.new("*First Page*").to_tex
7
+ assert_equal '{\em First Page}', RedClothForTex.new("_First Page_").to_tex
8
+ assert_equal "\\begin{itemize}\n\t\\item A\n\t\t\\item B\n\t\t\\item C\n\t\\end{itemize}", RedClothForTex.new("* A\n* B\n* C").to_tex
9
+ end
10
+
11
+ def test_blocks
12
+ assert_equal '\section*{hello}', RedClothForTex.new("h1. hello").to_tex
13
+ assert_equal '\subsection*{hello}', RedClothForTex.new("h2. hello").to_tex
14
+ end
15
+
16
+ def test_table_of_contents
17
+ assert_equal(
18
+ "\n\\section{A}\nAbe\n\n\\subsection{B}\nBabe\n\n\\subsection{C}\n\n\\section{D}\n\n\\subsection{E}\n\n\\subsubsection{F}",
19
+ table_of_contents("* [[A]]\n** [[B]]\n** [[C]]\n* D\n** [[E]]\n*** F", { "A" => "Abe", "B" => "Babe" } )
20
+ )
21
+ end
22
+
23
+ def test_entities
24
+ assert_equal "Beck \\& Fowler are 100\\% cool", RedClothForTex.new("Beck & Fowler are 100% cool").to_tex
25
+ end
26
+
27
+ def test_bracket_links
28
+ assert_equal "such a Horrible Day, but I won't be Made Useless", RedClothForTex.new("such a [[Horrible Day]], but I won't be [[Made Useless]]").to_tex
29
+ end
30
+
31
+ def test_footnotes_on_abbreviations
32
+ assert_equal(
33
+ "such a Horrible Day\\footnote{1}, but I won't be Made Useless",
34
+ RedClothForTex.new("such a [[Horrible Day]][1], but I won't be [[Made Useless]]").to_tex
35
+ )
36
+ end
37
+
38
+ def test_subsection_depth
39
+ assert_equal "\\subsubsection*{Hello}", RedClothForTex.new("h4. Hello").to_tex
40
+ end
41
+ end
@@ -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,95 @@
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 WebControllerServer.the_active_server
18
+ @the_active_server
19
+ end
20
+ def WebControllerServer.the_active_server= server
21
+ @the_active_server = server
22
+ end
23
+
24
+ def initialize(port, server_type, controller_path)
25
+ @server = WEBrick::HTTPServer::new(:Port => port, :ServerType => server_type || SERVER_TYPE)
26
+ WebControllerServer::the_active_server = @server
27
+ @server.logger.info "Your WEBrick server is now running on http://localhost:#{port}"
28
+ @controller_path = controller_path
29
+ mount_controllers
30
+ start_server
31
+ end
32
+
33
+ private
34
+ # Mounts all the controllers in the controller_path according to the mount type
35
+ def mount_controllers
36
+ require_controller_files
37
+
38
+ case MOUNT_TYPE
39
+ when STATIC_MOUNTING then controller_names.each { |name| mount_static_controller(name) }
40
+ when DYNAMIC_MOUNTING then controller_names.each { |name| mount_dynamic_controller(name) }
41
+ end
42
+ end
43
+
44
+ # Mounts the controller specified by <tt>controller_name</tt> to accept all requests below it's path.
45
+ # If more than one controller is mounted by this WebControllerServer, the controller is mounted by name,
46
+ # such that fx WikiController would get the requests of "/wiki/something" and "/wiki/some/thing/else".
47
+ # If only one controller is mounted, all requests to this WebControllerServer is handled by that controller
48
+ def mount_dynamic_controller(controller_name)
49
+ mount_path = mounting_multiple_controllers? ? "/#{controller_name}" : "/"
50
+ @server.mount(mount_path, controller_class(controller_name))
51
+ end
52
+
53
+ # Mount all public show_* and do_* methods as actions tied to the controller specified by <tt>controller_name</tt>.
54
+ # If more than one controller is mounted by this WebControllerServer, the actions are mounted below the controller
55
+ # in the path, such as "/wiki/page" or "/wiki/list". If only one controller is mounted, they're mounted directly on
56
+ # the root, such as "/page" or "/list"
57
+ def mount_static_controller(controller_name)
58
+ controller_class(controller_name).public_instance_methods(false).each { |method|
59
+ mount_path = (mounting_multiple_controllers? ? "/#{controller_name}" : "") + "/#{method}"
60
+ @server.mount(mount_path, controller_class(controller_name))
61
+ }
62
+ end
63
+
64
+ # Requires all the controller files that are present in the controller_path
65
+ def require_controller_files
66
+ controller_names.each { |controller| require @controller_path + controller }
67
+ end
68
+
69
+ # Returns true if more than one controller exists in the controller_path
70
+ def mounting_multiple_controllers?
71
+ controller_names.length > 1
72
+ end
73
+
74
+ # Returns a list of controller names in lower-case from the controller path
75
+ def controller_names
76
+ Dir.entries(@controller_path).delete_if { |file| file !~ /rb$/ }.collect{ |c| c[0..-4] }
77
+ end
78
+
79
+ # Returns the class of the controller specified by the <tt>controller_name</tt>
80
+ def controller_class(controller_name)
81
+ eval(controller_name.capitalize + "Controller")
82
+ end
83
+
84
+ public
85
+
86
+ # Start accepting requests to the defined mount points
87
+ def start_server
88
+ @server.start
89
+ end
90
+
91
+ # Stops accepting requests to the defined mount points
92
+ def shutdown
93
+ @server.shutdown
94
+ end
95
+ end
@@ -0,0 +1,97 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ if RUBY_VERSION < "1.8.1"
4
+ puts "Pimki requires Ruby 1.8.1+"
5
+ exit
6
+ end
7
+
8
+ # Handle rubygems support & loading libraries: {{{
9
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), "libraries")
10
+ begin
11
+ require 'rubygems'
12
+ require_gem 'madeleine'
13
+ require_gem 'redcloth', '~> 2.0.11'
14
+ require_gem 'rubyzip'
15
+ require_gem 'bluecloth'
16
+
17
+ rescue LoadError
18
+ # no rubygems, so load from the libraries directory
19
+ require 'redcloth'
20
+ require 'bluecloth'
21
+ end
22
+ # }}}
23
+
24
+ # Handle command-line options: {{{
25
+ require 'optparse'
26
+
27
+ cdir = File.expand_path(File.dirname(__FILE__))
28
+ %w( /libraries/ /app/models /app/controllers ).each { |dir| $:.unshift(cdir + dir) }
29
+ %w( web_controller_server action_controller_servlet wiki_service wiki ).each { |lib| require lib }
30
+
31
+ fork_available = true
32
+ begin
33
+ exit unless fork
34
+ rescue NotImplementedError
35
+ fork_available = false
36
+ end
37
+
38
+ begin
39
+ pdflatex_available = system "pdflatex -version"
40
+ rescue Errno::ENOENT
41
+ pdflatex_available = false
42
+ end
43
+
44
+ OPTIONS = {
45
+ :server_type => fork_available ? Daemon : SimpleServer,
46
+ :port => 2500,
47
+ :storage => "#{cdir}/storage",
48
+ :pdflatex => pdflatex_available
49
+ }
50
+
51
+ ARGV.options do |opts|
52
+ script_name = File.basename($0)
53
+ opts.banner = "Usage: ruby #{script_name} [options]"
54
+
55
+ opts.separator ""
56
+
57
+ opts.on("-p", "--port=port", Integer,
58
+ "Runs Instiki on the specified port.",
59
+ "Default: 2500") { |OPTIONS[:port]| }
60
+ opts.on("-s", "--simple", "--simple-server",
61
+ "Forces Instiki not to run as a Daemon if fork is available."
62
+ ) { OPTIONS[:server_type] = SimpleServer }
63
+ opts.on("-t", "--storage=storage", String,
64
+ "Makes Instiki use the specified directory for storage.",
65
+ "Default: ./storage/[port]") { |OPTIONS[:storage]| }
66
+
67
+ opts.separator ""
68
+
69
+ opts.on("-h", "--help",
70
+ "Show this help message.") { puts opts; exit }
71
+
72
+ opts.parse!
73
+ end
74
+
75
+ Socket.do_not_reverse_lookup = true
76
+ #}}}
77
+
78
+ # Start the application: {{{
79
+ storage_dir = OPTIONS[:storage] + "/" + OPTIONS[:port].to_s
80
+ require 'fileutils'
81
+ FileUtils.mkdir_p(storage_dir)
82
+ WikiService.storage_path = storage_dir
83
+
84
+ WikiController.template_root = "#{cdir}/app/views/"
85
+
86
+ trap "INT" do
87
+ WebControllerServer::the_active_server.shutdown
88
+ end
89
+ trap "TERM" do
90
+ WebControllerServer::the_active_server.shutdown
91
+ end
92
+
93
+ WebControllerServer.new(OPTIONS[:port], OPTIONS[:server_type], "#{cdir}/app/controllers/")
94
+
95
+ # }}}
96
+
97
+ # jEdit :folding=explicit:collapseFolds=1:
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.1
3
+ specification_version: 1
4
+ name: Pimki
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.0.092
7
+ date: 2004-11-24
8
+ summary: A Personal Information Manager (PIM) based on the Wiki technology of Instiki.
9
+ require_paths:
10
+ - libraries
11
+ author: Assaph Mehr (based on work by David Heinemeier Hansson)
12
+ email: assaph@gmail.com
13
+ homepage: http://pimki.rubyforge.org
14
+ rubyforge_project: pimki
15
+ description: "Pimki in a Personal Information Manager based on the Wiki technology of Instiki. Besides all the rich features and excellent look of Instiki, a few features have been added, such as: a personal blog, todo lists, graphical mapping, quick-links and others."
16
+ autorequire:
17
+ default_executable: pimki.rb
18
+ bindir: "."
19
+ has_rdoc: false
20
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
21
+ requirements:
22
+ -
23
+ - ">"
24
+ - !ruby/object:Gem::Version
25
+ version: 0.0.0
26
+ version:
27
+ platform: ruby
28
+ files:
29
+ - pimki.rb
30
+ - README
31
+ - README-PIMKI
32
+ - "./pimki.rb"
33
+ - app/controllers
34
+ - app/models
35
+ - app/views
36
+ - app/controllers/wiki.rb
37
+ - app/models/author.rb
38
+ - app/models/chunks
39
+ - app/models/page.rb
40
+ - app/models/page_lock.rb
41
+ - app/models/page_set.rb
42
+ - app/models/page_test.rb
43
+ - app/models/revision.rb
44
+ - app/models/revision_test.rb
45
+ - app/models/web.rb
46
+ - app/models/web_test.rb
47
+ - app/models/wiki_content.rb
48
+ - app/models/wiki_service.rb
49
+ - app/models/wiki_service_test.rb
50
+ - app/models/wiki_words.rb
51
+ - app/models/wiki_words_test.rb
52
+ - app/models/chunks/category.rb
53
+ - app/models/chunks/category_test.rb
54
+ - app/models/chunks/chunk.rb
55
+ - app/models/chunks/engines.rb
56
+ - app/models/chunks/include.rb
57
+ - app/models/chunks/literal.rb
58
+ - app/models/chunks/match.rb
59
+ - app/models/chunks/nowiki.rb
60
+ - app/models/chunks/nowiki_test.rb
61
+ - app/models/chunks/test.rb
62
+ - app/models/chunks/todo.rb
63
+ - app/models/chunks/uri.rb
64
+ - app/models/chunks/uri_test.rb
65
+ - app/models/chunks/wiki.rb
66
+ - app/models/chunks/wiki_test.rb
67
+ - app/views/bottom.rhtml
68
+ - app/views/markdown_help.rhtml
69
+ - app/views/menu.rhtml
70
+ - app/views/navigation.rhtml
71
+ - app/views/rdoc_help.rhtml
72
+ - app/views/static_style_sheet.rhtml
73
+ - app/views/style.rhtml
74
+ - app/views/textile_help.rhtml
75
+ - app/views/top.rhtml
76
+ - app/views/wiki
77
+ - app/views/wiki_words_help.rhtml
78
+ - app/views/wiki/authors.rhtml
79
+ - app/views/wiki/bliki.rhtml
80
+ - app/views/wiki/bliki_edit.rhtml
81
+ - app/views/wiki/bliki_new.rhtml
82
+ - app/views/wiki/bliki_revision.rhtml
83
+ - app/views/wiki/edit.rhtml
84
+ - app/views/wiki/edit_menu.rhtml
85
+ - app/views/wiki/edit_web.rhtml
86
+ - app/views/wiki/export.rhtml
87
+ - app/views/wiki/feeds.rhtml
88
+ - app/views/wiki/list.rhtml
89
+ - app/views/wiki/locked.rhtml
90
+ - app/views/wiki/login.rhtml
91
+ - app/views/wiki/mind.rhtml
92
+ - app/views/wiki/new.rhtml
93
+ - app/views/wiki/new_system.rhtml
94
+ - app/views/wiki/new_web.rhtml
95
+ - app/views/wiki/page.rhtml
96
+ - app/views/wiki/print.rhtml
97
+ - app/views/wiki/published.rhtml
98
+ - app/views/wiki/recently_revised.rhtml
99
+ - app/views/wiki/revision.rhtml
100
+ - app/views/wiki/rss_feed.rhtml
101
+ - app/views/wiki/search.rhtml
102
+ - app/views/wiki/tex.rhtml
103
+ - app/views/wiki/tex_web.rhtml
104
+ - app/views/wiki/todo.rhtml
105
+ - app/views/wiki/web_list.rhtml
106
+ - libraries/action_controller_servlet.rb
107
+ - libraries/bluecloth.rb
108
+ - libraries/diff
109
+ - libraries/erb.rb
110
+ - libraries/madeleine
111
+ - libraries/madeleine_service.rb
112
+ - libraries/rdocsupport.rb
113
+ - libraries/redcloth_for_tex.rb
114
+ - libraries/redcloth_for_tex_test.rb
115
+ - libraries/view_helper.rb
116
+ - libraries/web_controller_server.rb
117
+ - libraries/diff/diff.rb
118
+ - libraries/diff/diff_test.rb
119
+ - libraries/madeleine/automatic.rb
120
+ - libraries/madeleine/clock.rb
121
+ test_files: []
122
+ rdoc_options: []
123
+ extra_rdoc_files: []
124
+ executables:
125
+ - pimki.rb
126
+ extensions: []
127
+ requirements:
128
+ - none
129
+ dependencies:
130
+ - !ruby/object:Gem::Dependency
131
+ name: RedCloth
132
+ version_requirement:
133
+ version_requirements: !ruby/object:Gem::Version::Requirement
134
+ requirements:
135
+ -
136
+ - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 2.0.11
139
+ version:
140
+ - !ruby/object:Gem::Dependency
141
+ name: BlueCloth
142
+ version_requirement:
143
+ version_requirements: !ruby/object:Gem::Version::Requirement
144
+ requirements:
145
+ -
146
+ - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: 0.0.3
149
+ version:
150
+ - !ruby/object:Gem::Dependency
151
+ name: rubyzip
152
+ version_requirement:
153
+ version_requirements: !ruby/object:Gem::Version::Requirement
154
+ requirements:
155
+ -
156
+ - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: 0.5.5
159
+ version:
160
+ - !ruby/object:Gem::Dependency
161
+ name: madeleine
162
+ version_requirement:
163
+ version_requirements: !ruby/object:Gem::Version::Requirement
164
+ requirements:
165
+ -
166
+ - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: 0.6.1
169
+ version: