app/models/page.rb in Pimki-1.3.092 vs app/models/page.rb in Pimki-1.4.092
- old
+ new
@@ -15,17 +15,31 @@
def initialize(web, name, content, created_at, author)
@web, @name, @revisions = web, name, []
revise(content, created_at, author)
end
- def revise(content, created_at, author)
- if !@revisions.empty? && continous_revision?(created_at, author)
- @revisions.last.created_at = Time.now
- @revisions.last.content = content
- @revisions.last.clear_display_cache
- else
- @revisions << Revision.new(self, @revisions.length, content, created_at, author)
+ def revise(content, created_at, author, edit_type='default')
+ case edit_type
+ when 'major'
+ revise_major(content, created_at, author)
+
+ when 'minor'
+ if !@revisions.empty? # sanity check
+ revise_minor(content, created_at, author)
+ else
+ revise_major(content, created_at, author)
+ end
+
+ when 'default'
+ if !@revisions.empty? && continous_revision?(created_at, author)
+ revise_minor(content, created_at, author)
+ else
+ revise_major(content, created_at, author)
+ end
+
+ else
+ revise_major(content, created_at, author)
end
web.refresh_pages_with_references(name) if @revisions.length == 1
end
@@ -59,10 +73,14 @@
end
def references
web.select.pages_that_reference(name)
end
+
+ def bliki_references
+ web.select_bliki.pages_that_reference(name)
+ end
# Returns the original wiki-word name as separate words, so "MyPage" becomes "My Page".
def plain_name
WikiWords.separate(name, web.brackets_only)
end
@@ -76,18 +94,32 @@
end
def last_visited() @last_visited || revisions.last.created_at end
def viewed() @viewed ||= 0 end
+ def has_todos?
+ not display_content.find_chunks(Todo).empty?
+ end
private
def continous_revision?(created_at, author)
@revisions.last.author == author && @revisions.last.created_at + CONTINOUS_REVISION_PERIOD > created_at
end
# Forward method calls to the current revision, so the page responds to all revision calls
def method_missing(method_symbol)
revisions.last.send(method_symbol)
end
+
+ def revise_minor(content, created_at, author) #{{{
+ @revisions.last.created_at = Time.now
+ @revisions.last.content = content
+ @revisions.last.clear_display_cache
+ end #}}}
+
+ def revise_major(content, created_at, author) #{{{
+ @revisions << Revision.new(self, @revisions.length, content, created_at, author)
+ end #}}}
+
end
# jEdit :folding=indent:collapseFolds=1:
\ No newline at end of file