instiki 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/CHANGELOG +174 -165
  2. data/README +68 -68
  3. data/app/controllers/admin_controller.rb +94 -94
  4. data/app/controllers/application.rb +135 -131
  5. data/app/controllers/file_controller.rb +129 -129
  6. data/app/controllers/wiki_controller.rb +354 -354
  7. data/app/helpers/application_helper.rb +68 -68
  8. data/app/models/author.rb +3 -3
  9. data/app/models/chunks/category.rb +33 -33
  10. data/app/models/chunks/chunk.rb +86 -86
  11. data/app/models/chunks/engines.rb +61 -54
  12. data/app/models/chunks/include.rb +41 -41
  13. data/app/models/chunks/literal.rb +31 -31
  14. data/app/models/chunks/nowiki.rb +28 -28
  15. data/app/models/chunks/test.rb +18 -18
  16. data/app/models/chunks/uri.rb +182 -182
  17. data/app/models/chunks/wiki.rb +141 -141
  18. data/app/models/file_yard.rb +58 -58
  19. data/app/models/page.rb +112 -112
  20. data/app/models/page_lock.rb +22 -22
  21. data/app/models/page_set.rb +89 -89
  22. data/app/models/revision.rb +123 -123
  23. data/app/models/web.rb +182 -176
  24. data/app/models/wiki_content.rb +207 -207
  25. data/app/models/wiki_service.rb +233 -233
  26. data/app/models/wiki_words.rb +23 -23
  27. data/app/views/admin/create_system.rhtml +83 -83
  28. data/app/views/admin/create_web.rhtml +69 -69
  29. data/app/views/admin/edit_web.rhtml +137 -136
  30. data/app/views/file/file.rhtml +18 -18
  31. data/app/views/file/import.rhtml +22 -22
  32. data/app/views/layouts/default.rhtml +86 -85
  33. data/app/views/markdown_help.rhtml +12 -12
  34. data/app/views/mixed_help.rhtml +6 -6
  35. data/app/views/navigation.rhtml +30 -30
  36. data/app/views/rdoc_help.rhtml +12 -12
  37. data/app/views/textile_help.rhtml +24 -24
  38. data/app/views/wiki/authors.rhtml +11 -11
  39. data/app/views/wiki/edit.rhtml +39 -39
  40. data/app/views/wiki/export.rhtml +12 -12
  41. data/app/views/wiki/feeds.rhtml +14 -14
  42. data/app/views/wiki/list.rhtml +64 -64
  43. data/app/views/wiki/locked.rhtml +23 -23
  44. data/app/views/wiki/login.rhtml +14 -14
  45. data/app/views/wiki/new.rhtml +31 -31
  46. data/app/views/wiki/page.rhtml +115 -115
  47. data/app/views/wiki/print.rhtml +14 -14
  48. data/app/views/wiki/published.rhtml +9 -9
  49. data/app/views/wiki/recently_revised.rhtml +26 -26
  50. data/app/views/wiki/revision.rhtml +103 -103
  51. data/app/views/wiki/rollback.rhtml +36 -36
  52. data/app/views/wiki/rss_feed.rhtml +22 -22
  53. data/app/views/wiki/search.rhtml +38 -38
  54. data/app/views/wiki/tex.rhtml +22 -22
  55. data/app/views/wiki/tex_web.rhtml +34 -34
  56. data/app/views/wiki/web_list.rhtml +18 -18
  57. data/app/views/wiki_words_help.rhtml +9 -9
  58. data/config/environment.rb +82 -82
  59. data/config/environments/development.rb +5 -5
  60. data/config/environments/production.rb +4 -4
  61. data/config/environments/test.rb +17 -17
  62. data/config/routes.rb +18 -18
  63. data/lib/active_record_stub.rb +31 -31
  64. data/lib/bluecloth_tweaked.rb +1127 -0
  65. data/lib/diff.rb +444 -444
  66. data/lib/instiki_errors.rb +14 -14
  67. data/lib/rdocsupport.rb +151 -151
  68. data/lib/redcloth_for_tex.rb +736 -736
  69. data/natives/osx/desktop_launcher/AppDelegate.h +18 -18
  70. data/natives/osx/desktop_launcher/AppDelegate.mm +109 -109
  71. data/natives/osx/desktop_launcher/Credits.html +15 -15
  72. data/natives/osx/desktop_launcher/English.lproj/MainMenu.nib/classes.nib +12 -12
  73. data/natives/osx/desktop_launcher/English.lproj/MainMenu.nib/info.nib +24 -24
  74. data/natives/osx/desktop_launcher/Info.plist +12 -12
  75. data/natives/osx/desktop_launcher/Instiki.xcode/project.pbxproj +592 -592
  76. data/natives/osx/desktop_launcher/Instiki_Prefix.pch +7 -7
  77. data/natives/osx/desktop_launcher/MakeDMG.sh +9 -9
  78. data/natives/osx/desktop_launcher/main.mm +14 -14
  79. data/natives/osx/desktop_launcher/version.plist +16 -16
  80. data/public/404.html +5 -5
  81. data/public/500.html +5 -5
  82. data/public/dispatch.rb +9 -9
  83. data/public/javascripts/edit_web.js +52 -52
  84. data/public/javascripts/prototype.js +336 -336
  85. data/public/stylesheets/instiki.css +222 -222
  86. data/script/breakpointer +4 -4
  87. data/script/server +93 -93
  88. metadata +4 -3
@@ -1,23 +1,23 @@
1
- # Contains all the lock methods to be mixed in with the page
2
- module PageLock
3
- LOCKING_PERIOD = 30 * 60 # 30 minutes
4
-
5
- attr_reader :locked_by
6
-
7
- def lock(time, locked_by)
8
- @locked_at, @locked_by = time, locked_by
9
- end
10
-
11
- def lock_duration(time)
12
- ((time - @locked_at) / 60).to_i unless @locked_at.nil?
13
- end
14
-
15
- def unlock
16
- @locked_at = nil
17
- end
18
-
19
- def locked?(comparison_time)
20
- @locked_at + LOCKING_PERIOD > comparison_time unless @locked_at.nil?
21
- end
22
-
1
+ # Contains all the lock methods to be mixed in with the page
2
+ module PageLock
3
+ LOCKING_PERIOD = 30 * 60 # 30 minutes
4
+
5
+ attr_reader :locked_by
6
+
7
+ def lock(time, locked_by)
8
+ @locked_at, @locked_by = time, locked_by
9
+ end
10
+
11
+ def lock_duration(time)
12
+ ((time - @locked_at) / 60).to_i unless @locked_at.nil?
13
+ end
14
+
15
+ def unlock
16
+ @locked_at = nil
17
+ end
18
+
19
+ def locked?(comparison_time)
20
+ @locked_at + LOCKING_PERIOD > comparison_time unless @locked_at.nil?
21
+ end
22
+
23
23
  end
@@ -1,89 +1,89 @@
1
- # Container for a set of pages with methods for manipulation.
2
-
3
- class PageSet < Array
4
- attr_reader :web
5
-
6
- def initialize(web, pages = nil, condition = nil)
7
- @web = web
8
- # if pages is not specified, make a list of all pages in the web
9
- if pages.nil?
10
- super(web.pages.values)
11
- # otherwise use specified pages and condition to produce a set of pages
12
- elsif condition.nil?
13
- super(pages)
14
- else
15
- super(pages.select { |page| condition[page] })
16
- end
17
- end
18
-
19
- def most_recent_revision
20
- self.map { |page| page.created_at }.max || Time.at(0)
21
- end
22
-
23
-
24
- def by_name
25
- PageSet.new(@web, sort_by { |page| page.name })
26
- end
27
-
28
- alias :sort :by_name
29
-
30
- def by_revision
31
- PageSet.new(@web, sort_by { |page| page.created_at }).reverse
32
- end
33
-
34
- def pages_that_reference(page_name)
35
- self.select { |page| page.wiki_references.include?(page_name) }
36
- end
37
-
38
- def pages_that_link_to(page_name)
39
- self.select { |page| page.wiki_words.include?(page_name) }
40
- end
41
-
42
- def pages_that_include(page_name)
43
- self.select { |page| page.wiki_includes.include?(page_name) }
44
- end
45
-
46
- def pages_authored_by(author)
47
- self.select { |page| page.authors.include?(author) }
48
- end
49
-
50
- def characters
51
- self.inject(0) { |chars,page| chars += page.content.size }
52
- end
53
-
54
- # Returns all the orphaned pages in this page set. That is,
55
- # pages in this set for which there is no reference in the web.
56
- # The HomePage and author pages are always assumed to have
57
- # references and so cannot be orphans
58
- # Pages that refer to themselves and have no links from outside are oprphans.
59
- def orphaned_pages
60
- never_orphans = web.select.authors + ['HomePage']
61
- self.select { |page|
62
- if never_orphans.include? page.name
63
- false
64
- else
65
- references = pages_that_reference(page.name)
66
- references.empty? or references == [page]
67
- end
68
- }
69
- end
70
-
71
- # Returns all the wiki words in this page set for which
72
- # there are no pages in this page set's web
73
- def wanted_pages
74
- wiki_words - web.select.names
75
- end
76
-
77
- def names
78
- self.map { |page| page.name }
79
- end
80
-
81
- def wiki_words
82
- self.inject([]) { |wiki_words, page| wiki_words << page.wiki_words }.flatten.uniq
83
- end
84
-
85
- def authors
86
- self.inject([]) { |authors, page| authors << page.authors }.flatten.uniq.sort
87
- end
88
-
89
- end
1
+ # Container for a set of pages with methods for manipulation.
2
+
3
+ class PageSet < Array
4
+ attr_reader :web
5
+
6
+ def initialize(web, pages = nil, condition = nil)
7
+ @web = web
8
+ # if pages is not specified, make a list of all pages in the web
9
+ if pages.nil?
10
+ super(web.pages.values)
11
+ # otherwise use specified pages and condition to produce a set of pages
12
+ elsif condition.nil?
13
+ super(pages)
14
+ else
15
+ super(pages.select { |page| condition[page] })
16
+ end
17
+ end
18
+
19
+ def most_recent_revision
20
+ self.map { |page| page.created_at }.max || Time.at(0)
21
+ end
22
+
23
+
24
+ def by_name
25
+ PageSet.new(@web, sort_by { |page| page.name })
26
+ end
27
+
28
+ alias :sort :by_name
29
+
30
+ def by_revision
31
+ PageSet.new(@web, sort_by { |page| page.created_at }).reverse
32
+ end
33
+
34
+ def pages_that_reference(page_name)
35
+ self.select { |page| page.wiki_references.include?(page_name) }
36
+ end
37
+
38
+ def pages_that_link_to(page_name)
39
+ self.select { |page| page.wiki_words.include?(page_name) }
40
+ end
41
+
42
+ def pages_that_include(page_name)
43
+ self.select { |page| page.wiki_includes.include?(page_name) }
44
+ end
45
+
46
+ def pages_authored_by(author)
47
+ self.select { |page| page.authors.include?(author) }
48
+ end
49
+
50
+ def characters
51
+ self.inject(0) { |chars,page| chars += page.content.size }
52
+ end
53
+
54
+ # Returns all the orphaned pages in this page set. That is,
55
+ # pages in this set for which there is no reference in the web.
56
+ # The HomePage and author pages are always assumed to have
57
+ # references and so cannot be orphans
58
+ # Pages that refer to themselves and have no links from outside are oprphans.
59
+ def orphaned_pages
60
+ never_orphans = web.select.authors + ['HomePage']
61
+ self.select { |page|
62
+ if never_orphans.include? page.name
63
+ false
64
+ else
65
+ references = pages_that_reference(page.name)
66
+ references.empty? or references == [page]
67
+ end
68
+ }
69
+ end
70
+
71
+ # Returns all the wiki words in this page set for which
72
+ # there are no pages in this page set's web
73
+ def wanted_pages
74
+ wiki_words - web.select.names
75
+ end
76
+
77
+ def names
78
+ self.map { |page| page.name }
79
+ end
80
+
81
+ def wiki_words
82
+ self.inject([]) { |wiki_words, page| wiki_words << page.wiki_words }.flatten.uniq
83
+ end
84
+
85
+ def authors
86
+ self.inject([]) { |authors, page| authors << page.authors }.flatten.uniq.sort
87
+ end
88
+
89
+ end
@@ -1,123 +1,123 @@
1
- require 'diff'
2
- require 'wiki_content'
3
- require 'chunks/wiki'
4
- require 'date'
5
- require 'author'
6
- require 'page'
7
-
8
- class Revision
9
-
10
- attr_accessor :page, :number, :content, :created_at, :author
11
-
12
- def initialize(page, number, content, created_at, author)
13
- @page, @number, @created_at, @author = page, number, created_at, author
14
- self.content = content
15
- @display_cache = nil
16
- end
17
-
18
- def created_on
19
- Date.new(@created_at.year, @created_at.mon, @created_at.day)
20
- end
21
-
22
- def pretty_created_at
23
- # Must use DateTime because Time doesn't support %e on at least some platforms
24
- DateTime.new(
25
- @created_at.year, @created_at.mon, @created_at.day, @created_at.hour, @created_at.min
26
- ).strftime "%B %e, %Y %H:%M"
27
- end
28
-
29
- def next_revision
30
- page.revisions[number + 1]
31
- end
32
-
33
- def previous_revision
34
- number > 0 ? page.revisions[number - 1] : nil
35
- end
36
-
37
- # Returns an array of all the WikiIncludes present in the content of this revision.
38
- def wiki_includes
39
- unless @wiki_includes_cache
40
- chunks = display_content.find_chunks(Include)
41
- @wiki_includes_cache = chunks.map { |c| ( c.escaped? ? nil : c.page_name ) }.compact.uniq
42
- end
43
- @wiki_includes_cache
44
- end
45
-
46
- # Returns an array of all the WikiReferences present in the content of this revision.
47
- def wiki_references
48
- unless @wiki_references_cache
49
- chunks = display_content.find_chunks(WikiChunk::WikiReference)
50
- @wiki_references_cache = chunks.map { |c| ( c.escaped? ? nil : c.page_name ) }.compact.uniq
51
- end
52
- @wiki_references_cache
53
- end
54
-
55
- # Returns an array of all the WikiWords present in the content of this revision.
56
- def wiki_words
57
- unless @wiki_words_cache
58
- wiki_chunks = display_content.find_chunks(WikiChunk::WikiLink)
59
- @wiki_words_cache = wiki_chunks.map { |c| ( c.escaped? ? nil : c.page_name ) }.compact.uniq
60
- end
61
- @wiki_words_cache
62
- end
63
-
64
- # Returns an array of all the WikiWords present in the content of this revision.
65
- # that already exists as a page in the web.
66
- def existing_pages
67
- wiki_words.select { |wiki_word| page.web.pages[wiki_word] }
68
- end
69
-
70
- # Returns an array of all the WikiWords present in the content of this revision
71
- # that *doesn't* already exists as a page in the web.
72
- def unexisting_pages
73
- wiki_words - existing_pages
74
- end
75
-
76
- # Explicit check for new type of display cache with chunks_by_type method.
77
- # Ensures new version works with older snapshots.
78
- def display_content
79
- unless @display_cache && @display_cache.respond_to?(:chunks_by_type)
80
- @display_cache = WikiContent.new(self)
81
- @display_cache.render!
82
- end
83
- @display_cache
84
- end
85
-
86
- def display_diff
87
- previous_revision ? HTMLDiff.diff(previous_revision.display_content, display_content) : display_content
88
- end
89
-
90
- def clear_display_cache
91
- @wiki_words_cache = @published_cache = @display_cache = @wiki_includes_cache =
92
- @wiki_references_cache = nil
93
- end
94
-
95
- def display_published
96
- unless @published_cache && @published_cache.respond_to?(:chunks_by_type)
97
- @published_cache = WikiContent.new(self, {:mode => :publish})
98
- @published_cache.render!
99
- end
100
- @published_cache
101
- end
102
-
103
- def display_content_for_export
104
- WikiContent.new(self, {:mode => :export} ).render!
105
- end
106
-
107
- def force_rendering
108
- begin
109
- display_content.render!
110
- rescue Exception => e
111
- ApplicationController.logger.error "Failed rendering page #{@name}"
112
- ApplicationController.logger.error e
113
- message = e.message.gsub(/\n/, '<br/>')
114
- # substitute content with an error message
115
- content = <<-EOL
116
- <p>Markup engine has failed to render this page, raising the following error:</p>
117
- <p>#{message}</p>
118
- EOL
119
- raise e
120
- end
121
- end
122
-
123
- end
1
+ require 'diff'
2
+ require 'wiki_content'
3
+ require 'chunks/wiki'
4
+ require 'date'
5
+ require 'author'
6
+ require 'page'
7
+
8
+ class Revision
9
+
10
+ attr_accessor :page, :number, :content, :created_at, :author
11
+
12
+ def initialize(page, number, content, created_at, author)
13
+ @page, @number, @created_at, @author = page, number, created_at, author
14
+ self.content = content
15
+ @display_cache = nil
16
+ end
17
+
18
+ def created_on
19
+ Date.new(@created_at.year, @created_at.mon, @created_at.day)
20
+ end
21
+
22
+ def pretty_created_at
23
+ # Must use DateTime because Time doesn't support %e on at least some platforms
24
+ DateTime.new(
25
+ @created_at.year, @created_at.mon, @created_at.day, @created_at.hour, @created_at.min
26
+ ).strftime "%B %e, %Y %H:%M"
27
+ end
28
+
29
+ def next_revision
30
+ page.revisions[number + 1]
31
+ end
32
+
33
+ def previous_revision
34
+ number > 0 ? page.revisions[number - 1] : nil
35
+ end
36
+
37
+ # Returns an array of all the WikiIncludes present in the content of this revision.
38
+ def wiki_includes
39
+ unless @wiki_includes_cache
40
+ chunks = display_content.find_chunks(Include)
41
+ @wiki_includes_cache = chunks.map { |c| ( c.escaped? ? nil : c.page_name ) }.compact.uniq
42
+ end
43
+ @wiki_includes_cache
44
+ end
45
+
46
+ # Returns an array of all the WikiReferences present in the content of this revision.
47
+ def wiki_references
48
+ unless @wiki_references_cache
49
+ chunks = display_content.find_chunks(WikiChunk::WikiReference)
50
+ @wiki_references_cache = chunks.map { |c| ( c.escaped? ? nil : c.page_name ) }.compact.uniq
51
+ end
52
+ @wiki_references_cache
53
+ end
54
+
55
+ # Returns an array of all the WikiWords present in the content of this revision.
56
+ def wiki_words
57
+ unless @wiki_words_cache
58
+ wiki_chunks = display_content.find_chunks(WikiChunk::WikiLink)
59
+ @wiki_words_cache = wiki_chunks.map { |c| ( c.escaped? ? nil : c.page_name ) }.compact.uniq
60
+ end
61
+ @wiki_words_cache
62
+ end
63
+
64
+ # Returns an array of all the WikiWords present in the content of this revision.
65
+ # that already exists as a page in the web.
66
+ def existing_pages
67
+ wiki_words.select { |wiki_word| page.web.pages[wiki_word] }
68
+ end
69
+
70
+ # Returns an array of all the WikiWords present in the content of this revision
71
+ # that *doesn't* already exists as a page in the web.
72
+ def unexisting_pages
73
+ wiki_words - existing_pages
74
+ end
75
+
76
+ # Explicit check for new type of display cache with chunks_by_type method.
77
+ # Ensures new version works with older snapshots.
78
+ def display_content
79
+ unless @display_cache && @display_cache.respond_to?(:chunks_by_type)
80
+ @display_cache = WikiContent.new(self)
81
+ @display_cache.render!
82
+ end
83
+ @display_cache
84
+ end
85
+
86
+ def display_diff
87
+ previous_revision ? HTMLDiff.diff(previous_revision.display_content, display_content) : display_content
88
+ end
89
+
90
+ def clear_display_cache
91
+ @wiki_words_cache = @published_cache = @display_cache = @wiki_includes_cache =
92
+ @wiki_references_cache = nil
93
+ end
94
+
95
+ def display_published
96
+ unless @published_cache && @published_cache.respond_to?(:chunks_by_type)
97
+ @published_cache = WikiContent.new(self, {:mode => :publish})
98
+ @published_cache.render!
99
+ end
100
+ @published_cache
101
+ end
102
+
103
+ def display_content_for_export
104
+ WikiContent.new(self, {:mode => :export} ).render!
105
+ end
106
+
107
+ def force_rendering
108
+ begin
109
+ display_content.render!
110
+ rescue Exception => e
111
+ ApplicationController.logger.error "Failed rendering page #{@name}"
112
+ ApplicationController.logger.error e
113
+ message = e.message.gsub(/\n/, '<br/>')
114
+ # substitute content with an error message
115
+ content = <<-EOL
116
+ <p>Markup engine has failed to render this page, raising the following error:</p>
117
+ <p>#{message}</p>
118
+ EOL
119
+ raise e
120
+ end
121
+ end
122
+
123
+ end