hobix 0.6

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 (156) hide show
  1. data/COPYING +18 -0
  2. data/README +18 -0
  3. data/Rakefile +96 -0
  4. data/bin/hobix +94 -0
  5. data/contrib/blosxom-to-hobix.rb +253 -0
  6. data/contrib/txp-to-hobix.rb +56 -0
  7. data/contrib/webrick-all-mine.rb +20 -0
  8. data/doc/CHANGELOG +285 -0
  9. data/doc/rdoc/classes/Hobix/API.html +382 -0
  10. data/doc/rdoc/classes/Hobix/Article.html +111 -0
  11. data/doc/rdoc/classes/Hobix/BaseContent.html +692 -0
  12. data/doc/rdoc/classes/Hobix/BaseEntry.html +218 -0
  13. data/doc/rdoc/classes/Hobix/BaseFacet.html +205 -0
  14. data/doc/rdoc/classes/Hobix/BaseOutput.html +122 -0
  15. data/doc/rdoc/classes/Hobix/BasePlugin.html +201 -0
  16. data/doc/rdoc/classes/Hobix/BaseProperties/ClassMethods.html +243 -0
  17. data/doc/rdoc/classes/Hobix/BaseProperties.html +218 -0
  18. data/doc/rdoc/classes/Hobix/BasePublish.html +157 -0
  19. data/doc/rdoc/classes/Hobix/BaseStorage.html +417 -0
  20. data/doc/rdoc/classes/Hobix/BixWik/Entry.html +196 -0
  21. data/doc/rdoc/classes/Hobix/BixWik/IndexEntry.html +170 -0
  22. data/doc/rdoc/classes/Hobix/BixWik/WikiRedCloth.html +111 -0
  23. data/doc/rdoc/classes/Hobix/BixWik.html +418 -0
  24. data/doc/rdoc/classes/Hobix/BixWikPlugin.html +158 -0
  25. data/doc/rdoc/classes/Hobix/CommandLine.html +1970 -0
  26. data/doc/rdoc/classes/Hobix/Comment.html +113 -0
  27. data/doc/rdoc/classes/Hobix/Config.html +212 -0
  28. data/doc/rdoc/classes/Hobix/DataMarsh.html +667 -0
  29. data/doc/rdoc/classes/Hobix/Entry.html +178 -0
  30. data/doc/rdoc/classes/Hobix/EntryEnum.html +162 -0
  31. data/doc/rdoc/classes/Hobix/Enumerable.html +170 -0
  32. data/doc/rdoc/classes/Hobix/Facets/WikiEdit.html +180 -0
  33. data/doc/rdoc/classes/Hobix/Facets.html +111 -0
  34. data/doc/rdoc/classes/Hobix/LinkList.html +182 -0
  35. data/doc/rdoc/classes/Hobix/Out/Quick.html +412 -0
  36. data/doc/rdoc/classes/Hobix/Out.html +119 -0
  37. data/doc/rdoc/classes/Hobix/Page.html +381 -0
  38. data/doc/rdoc/classes/Hobix/Trackback.html +113 -0
  39. data/doc/rdoc/classes/Hobix/UriStr.html +198 -0
  40. data/doc/rdoc/classes/Hobix/WebApp/QueryString.html +207 -0
  41. data/doc/rdoc/classes/Hobix/WebApp/QueryValidationFailure.html +111 -0
  42. data/doc/rdoc/classes/Hobix/WebApp.html +1383 -0
  43. data/doc/rdoc/classes/Hobix/Weblog/AuthorNotFound.html +111 -0
  44. data/doc/rdoc/classes/Hobix/Weblog.html +2082 -0
  45. data/doc/rdoc/classes/Hobix.html +399 -0
  46. data/doc/rdoc/classes/Kernel.html +139 -0
  47. data/doc/rdoc/classes/Regexp.html +154 -0
  48. data/doc/rdoc/classes/YAML/Omap.html +144 -0
  49. data/doc/rdoc/classes/YAML.html +111 -0
  50. data/doc/rdoc/created.rid +1 -0
  51. data/doc/rdoc/files/COPYING.html +129 -0
  52. data/doc/rdoc/files/README.html +131 -0
  53. data/doc/rdoc/files/doc/CHANGELOG.html +101 -0
  54. data/doc/rdoc/files/lib/hobix/api_rb.html +119 -0
  55. data/doc/rdoc/files/lib/hobix/article_rb.html +126 -0
  56. data/doc/rdoc/files/lib/hobix/base_rb.html +128 -0
  57. data/doc/rdoc/files/lib/hobix/bixwik_rb.html +126 -0
  58. data/doc/rdoc/files/lib/hobix/commandline_rb.html +140 -0
  59. data/doc/rdoc/files/lib/hobix/comments_rb.html +126 -0
  60. data/doc/rdoc/files/lib/hobix/config_rb.html +125 -0
  61. data/doc/rdoc/files/lib/hobix/datamarsh_rb.html +108 -0
  62. data/doc/rdoc/files/lib/hobix/entry_rb.html +118 -0
  63. data/doc/rdoc/files/lib/hobix/linklist_rb.html +127 -0
  64. data/doc/rdoc/files/lib/hobix/publisher_rb.html +126 -0
  65. data/doc/rdoc/files/lib/hobix/trackbacks_rb.html +128 -0
  66. data/doc/rdoc/files/lib/hobix/webapp_rb.html +127 -0
  67. data/doc/rdoc/files/lib/hobix/weblog_rb.html +135 -0
  68. data/doc/rdoc/files/lib/hobix_rb.html +127 -0
  69. data/doc/rdoc/fr_class_index.html +67 -0
  70. data/doc/rdoc/fr_file_index.html +44 -0
  71. data/doc/rdoc/fr_method_index.html +307 -0
  72. data/doc/rdoc/index.html +24 -0
  73. data/doc/rdoc/rdoc-style.css +208 -0
  74. data/git_hobix_update.php +13 -0
  75. data/lib/hobix/api.rb +91 -0
  76. data/lib/hobix/article.rb +22 -0
  77. data/lib/hobix/base.rb +480 -0
  78. data/lib/hobix/bixwik.rb +200 -0
  79. data/lib/hobix/commandline.rb +677 -0
  80. data/lib/hobix/comments.rb +98 -0
  81. data/lib/hobix/config.rb +39 -0
  82. data/lib/hobix/datamarsh.rb +110 -0
  83. data/lib/hobix/entry.rb +84 -0
  84. data/lib/hobix/facets/comments.rb +99 -0
  85. data/lib/hobix/facets/publisher.rb +314 -0
  86. data/lib/hobix/facets/trackbacks.rb +80 -0
  87. data/lib/hobix/linklist.rb +81 -0
  88. data/lib/hobix/out/atom.rb +101 -0
  89. data/lib/hobix/out/erb.rb +64 -0
  90. data/lib/hobix/out/okaynews.rb +55 -0
  91. data/lib/hobix/out/quick.rb +314 -0
  92. data/lib/hobix/out/rdf.rb +97 -0
  93. data/lib/hobix/out/redrum.rb +26 -0
  94. data/lib/hobix/out/rss.rb +128 -0
  95. data/lib/hobix/plugin/akismet.rb +196 -0
  96. data/lib/hobix/plugin/bloglines.rb +73 -0
  97. data/lib/hobix/plugin/calendar.rb +212 -0
  98. data/lib/hobix/plugin/flickr.rb +110 -0
  99. data/lib/hobix/plugin/recent_comments.rb +84 -0
  100. data/lib/hobix/plugin/sections.rb +91 -0
  101. data/lib/hobix/plugin/tags.rb +60 -0
  102. data/lib/hobix/publish/ping.rb +53 -0
  103. data/lib/hobix/publish/replicate.rb +283 -0
  104. data/lib/hobix/publisher.rb +18 -0
  105. data/lib/hobix/search/dictionary.rb +141 -0
  106. data/lib/hobix/search/porter_stemmer.rb +203 -0
  107. data/lib/hobix/search/simple.rb +209 -0
  108. data/lib/hobix/search/vector.rb +100 -0
  109. data/lib/hobix/storage/filesys.rb +408 -0
  110. data/lib/hobix/trackbacks.rb +93 -0
  111. data/lib/hobix/util/objedit.rb +193 -0
  112. data/lib/hobix/util/patcher.rb +155 -0
  113. data/lib/hobix/webapp/cli.rb +195 -0
  114. data/lib/hobix/webapp/htmlform.rb +107 -0
  115. data/lib/hobix/webapp/message.rb +177 -0
  116. data/lib/hobix/webapp/urigen.rb +141 -0
  117. data/lib/hobix/webapp/webrick-servlet.rb +90 -0
  118. data/lib/hobix/webapp.rb +723 -0
  119. data/lib/hobix/weblog.rb +893 -0
  120. data/lib/hobix.rb +230 -0
  121. data/share/default-blog/hobix.yaml +16 -0
  122. data/share/default-blog/htdocs/site.css +174 -0
  123. data/share/default-blog/skel/entry.html.quick +0 -0
  124. data/share/default-blog/skel/index.atom.atom +0 -0
  125. data/share/default-blog/skel/index.html.quick-summary +0 -0
  126. data/share/default-blog/skel/index.xml.rss +0 -0
  127. data/share/default-blog/skel/index.yaml.okaynews +0 -0
  128. data/share/default-blog/skel/monthly.html.quick-archive +0 -0
  129. data/share/default-blog/skel/section.html.quick-archive +0 -0
  130. data/share/default-blog/skel/yearly.html.quick-archive +0 -0
  131. data/share/default-blog-modes.yaml +7 -0
  132. data/share/default-blog.apache-cgi.patch +8 -0
  133. data/share/default-blog.apache-ssi.patch +38 -0
  134. data/share/default-blog.apache2-ssi.patch +3 -0
  135. data/share/default-blog.cgi.patch +8 -0
  136. data/share/default-blog.comments.patch +5 -0
  137. data/share/default-blog.prototype.patch +766 -0
  138. data/share/default-blog.publisher.patch +5 -0
  139. data/share/default-blog.wiki.patch +29 -0
  140. data/share/publisher/css/control.css +90 -0
  141. data/share/publisher/css/form.css +238 -0
  142. data/share/publisher/css/form.import.css +72 -0
  143. data/share/publisher/css/main-menu.css +134 -0
  144. data/share/publisher/i/hobix-emblazen-1.png +0 -0
  145. data/share/publisher/i/hobix-emblazen-2.png +0 -0
  146. data/share/publisher/i/hobix-emblazen-3.png +0 -0
  147. data/share/publisher/i/hobix-emblazen-4.png +0 -0
  148. data/share/publisher/i/hobix-emblazen-5.png +0 -0
  149. data/share/publisher/i/hobix-emblazen-6.png +0 -0
  150. data/share/publisher/i/hobix-emblazen-7.png +0 -0
  151. data/share/publisher/index.erb +66 -0
  152. data/share/publisher/js/controls.js +261 -0
  153. data/share/publisher/js/dragdrop.js +476 -0
  154. data/share/publisher/js/effects.js +570 -0
  155. data/share/publisher/js/prototype.js +1011 -0
  156. metadata +230 -0
@@ -0,0 +1,98 @@
1
+ #
2
+ # = hobix/comments.rb
3
+ #
4
+ # Hobix command-line weblog system, API for comments.
5
+ #
6
+ # Copyright (c) 2003-2004 why the lucky stiff
7
+ #
8
+ # Written & maintained by why the lucky stiff <why@ruby-lang.org>
9
+ #
10
+ # This program is free software, released under a BSD license.
11
+ # See COPYING for details.
12
+ #
13
+ #--
14
+ # $Id$
15
+ #++
16
+
17
+ require 'hobix/facets/comments'
18
+
19
+ module Hobix
20
+ module Out
21
+ class Quick
22
+ append_def :head_tags_erb, %{
23
+ <meta http-equiv="Pragma" content="no-cache" />
24
+ <meta http-equiv="Expires" content="-1" />
25
+ <script type="text/javascript" src="<%= weblog.expand_path( '/js/prototype.js' ) %>"></script>
26
+ <script type="text/javascript">
27
+ function quickRedReference() {
28
+ window.open(
29
+ "http://hobix.com/textile/quick.html",
30
+ "redRef",
31
+ "height=600,width=550,channelmode=0,dependent=0," +
32
+ "directories=0,fullscreen=0,location=0,menubar=0," +
33
+ "resizable=0,scrollbars=1,status=1,toolbar=0"
34
+ );
35
+ }
36
+ </script>
37
+ }
38
+
39
+ append_def :entry_erb, %{
40
+ <% if entry and not defined? entries %>
41
+ <+ entry_comment +>
42
+ <+ entry_comment_form +>
43
+ <% end %>
44
+ }
45
+
46
+ def entry_comment_erb; %{
47
+ <% entry_id = entry.id %>
48
+ <div id="comments">
49
+ <% comments = weblog.storage.load_attached( entry_id, "comments" ) rescue [] %>
50
+ <% comments.each do |comment| %>
51
+ <div class="entry">
52
+ <div class="entryAttrib">
53
+ <div class="entryAuthor"><h3><%= comment.author %></h3></div>
54
+ <div class="entryTime">said on <%= comment.created.strftime( "<nobr>%d %b %Y</nobr> at <nobr>%H:%M</nobr>" ) %></div>
55
+ </div>
56
+ <div class="entryContentOuter"><div class="entryContent"><%= comment.content.to_html %></div></div>
57
+ </div>
58
+ <% end %>
59
+ } end
60
+
61
+ def entry_comment_form_erb; %{
62
+ <div class="entry">
63
+ <form id="userComment" method="post" action="<%= weblog.expand_path( '/control/comment/' + entry_id )%>">
64
+ <div class="entryAttrib">
65
+ <div class="entryAuthor"><input name="<%= Hobix::Facets::Comments.form_field 'author' %>" type="textbox" size="15" maxlength="50" /></div>
66
+ <div id="liveTime" class="entryTime">said on <%= Time.now.strftime( "<nobr>%d %b %Y</nobr> at <nobr>%H:%M</nobr>")%></div>
67
+ </div>
68
+ <div class="entryContentOuter"><div class="entryContent">
69
+ <textarea name="<%= Hobix::Facets::Comments.form_field 'content' %>" rows="6" cols="50"></textarea>
70
+ <p><input type="button" name="pleasePreview" value="preview"
71
+ onClick="new Ajax.Request( '<%= weblog.expand_path '/control/preview' %>', {parameters: Form.serialize('userComment'), onComplete: function(req) { $('textilePreview').innerHTML = req.responseText }})" />
72
+ <input type="submit" name="<%= Hobix::Facets::Comments.form_field 'submit' %>" value="&gt;&gt;" />
73
+ <small>* do <a href="javascript:quickRedReference();">fancy stuff</a> in your comment.</small>
74
+ </p>
75
+ <div id="textileWrap"><!-- <h4>PREVIEW PANE</h4> -->
76
+ <div id="textilePreview"></div>
77
+ </div>
78
+ </div>
79
+ </div></div>
80
+
81
+ </form>
82
+ </div>
83
+ } end
84
+ end
85
+ end
86
+
87
+ class Comment < BaseContent
88
+ _! "Comment Information"
89
+ _ :author, :req => true, :edit_as => :text, :search => :prefix
90
+ _ :created, :edit_as => :datetime
91
+ _ :url, :edit_as => :text
92
+ _ :email, :edit_as => :text
93
+ _ :content, :edit_as => :textarea, :search => :fulltext, :text_processor => true
94
+ _ :ipaddress, :edit_as => :text
95
+
96
+ yaml_type "tag:hobix.com,2005:comment"
97
+ end
98
+ end
@@ -0,0 +1,39 @@
1
+ #
2
+ # = hobix/config.rb
3
+ #
4
+ # Hobix command-line weblog system.
5
+ #
6
+ # Copyright (c) 2003-2004 why the lucky stiff
7
+ #
8
+ # Written & maintained by why the lucky stiff <why@ruby-lang.org>
9
+ #
10
+ # This program is free software, released under a BSD license.
11
+ # See COPYING for details.
12
+ #
13
+ #--
14
+ # $Id$
15
+ #++
16
+
17
+ require 'yaml'
18
+
19
+ module Hobix
20
+ class Config
21
+ attr_accessor :weblogs, :username, :personal,
22
+ :post_upgen, :use_editor
23
+ def initialize
24
+ @username = ENV['USER'] unless @username
25
+ self
26
+ end
27
+ def Config.load( conf_file )
28
+ c = YAML::load( File::open( conf_file ) )
29
+ c.keys.each do |k|
30
+ if k =~ /\s/
31
+ k_ = k.gsub( /\s/, '_' )
32
+ c[k_] = c.delete( k )
33
+ end
34
+ end
35
+ c = YAML::object_maker( Hobix::Config, c )
36
+ c.initialize
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,110 @@
1
+ require 'dbm'
2
+ #
3
+ # Marshal + DBM = DataMarsh
4
+ # - Same interface as DBM class
5
+ #
6
+ module Hobix
7
+
8
+ class DataMarsh < ::DBM
9
+ VERSION = "0.1"
10
+ def []( key )
11
+ fetch( key )
12
+ end
13
+ def []=( key, val )
14
+ store( key, val )
15
+ end
16
+ def fetch( keystr, ifnone = nil )
17
+ begin
18
+ val = super( keystr )
19
+ return Marshal::load( val ) if String === val
20
+ rescue IndexError
21
+ end
22
+ if block_given?
23
+ yield keystr
24
+ else
25
+ ifnone
26
+ end
27
+ end
28
+ def index( keystr )
29
+ super( keystr.to_yaml )
30
+ end
31
+ def values_at( *keys )
32
+ keys.collect { |k| fetch( k ) }
33
+ end
34
+ def delete( key )
35
+ v = super( key )
36
+ if String === v
37
+ v = Marshal::load( v )
38
+ end
39
+ v
40
+ end
41
+ def delete_if
42
+ del_keys = keys.dup
43
+ del_keys.delete_if { |k| yield( k, fetch( k ) ) == false }
44
+ del_keys.each { |k| delete( k ) }
45
+ self
46
+ end
47
+ def reject
48
+ hsh = self.to_hash
49
+ hsh.reject { |k,v| yield k, v }
50
+ end
51
+ def each_pair
52
+ keys.each { |k| yield k, fetch( k ) }
53
+ self
54
+ end
55
+ def each_value
56
+ super { |v| yield Marshal::load( v ) }
57
+ self
58
+ end
59
+ def values
60
+ super.collect { |v| Marshal::load( v ) }
61
+ end
62
+ def has_value?( val )
63
+ each_value { |v| return true if v == val }
64
+ return false
65
+ end
66
+ def invert
67
+ h = {}
68
+ keys.each { |k| h[ self.fetch( k ) ] = k }
69
+ h
70
+ end
71
+ def replace( hsh )
72
+ clear
73
+ update( hsh )
74
+ end
75
+ def shift
76
+ a = super
77
+ a[1] = Marshal::load( a[1] ) if a
78
+ a
79
+ end
80
+ def select( *keys )
81
+ if block_given?
82
+ self.keys.collect { |k| v = self[k]; [k, v] if yield k, v }.compact
83
+ else
84
+ values_at( *keys )
85
+ end
86
+ end
87
+ def store( key, val )
88
+ super( key, val.to_yaml )
89
+ val
90
+ end
91
+ def update( hsh )
92
+ hsh.keys.each do |k|
93
+ self.store( k, hsh.fetch( k ) )
94
+ end
95
+ self
96
+ end
97
+ def to_a
98
+ a = []
99
+ keys.each { |k| a.push [ k, self.fetch( k ) ] }
100
+ a
101
+ end
102
+ def to_hash
103
+ h = {}
104
+ keys.each { |k| h[ k ] = self.fetch( k ) }
105
+ h
106
+ end
107
+ alias :each :each_pair
108
+ end
109
+
110
+ end
@@ -0,0 +1,84 @@
1
+ #
2
+ # = hobix/entry.rb
3
+ #
4
+ # Hobix command-line weblog system.
5
+ #
6
+ # Copyright (c) 2003-2004 why the lucky stiff
7
+ #
8
+ # Written & maintained by why the lucky stiff <why@ruby-lang.org>
9
+ #
10
+ # This program is free software, released under a BSD license.
11
+ # See COPYING for details.
12
+ #
13
+ #--
14
+ # $Id$
15
+ #++
16
+
17
+ module Hobix
18
+ # The Entry class stores complete data for an entry on the site. All
19
+ # entry extensions should behave like this class as well.
20
+ #
21
+ # == Properties
22
+ #
23
+ # At the very least, entry data should support the following
24
+ # accessors.
25
+ #
26
+ # id:: The id (or shortName) for this entry. Includes
27
+ # the basic entry path.
28
+ # link:: The full URL to this entry from the weblog.
29
+ # title:: The heading for this entry.
30
+ # tagline:: The subheading for this entry.
31
+ # tags:: A list of free-tagged categories.
32
+ # author:: The author's username.
33
+ # contributors:: An Array of contributors' usernames.
34
+ # created:: The time the Entry was initially created.
35
+ # modified:: A modification time.
36
+ # updated:: Used internally to ensure an entry has been generated.
37
+ # summary:: A brief description of this entry. Can be used
38
+ # for an abbreviated text of a long article.
39
+ # content:: The full text of the entry.
40
+ #
41
+ # The following read-only properties are also available:
42
+ #
43
+ # day_id:: The day ID can act as a path where other
44
+ # entry, posted on the same day, are stored.
45
+ # month_id:: A path for the month's entries.
46
+ # year_id:: A path for the year's entries.
47
+ class Entry < BaseEntry
48
+
49
+ _ :title, :req => true, :edit_as => :text, :search => :fulltext
50
+ _ :tagline, :edit_as => :text, :search => :fulltext, :text_processor => true
51
+ _ :summary, :edit_as => :textarea, :search => :fulltext, :text_processor => true
52
+ _ :content, :req => true, :edit_as => :textarea, :search => :fulltext, :text_processor => true
53
+
54
+ # Hobix::Entry objects are typed in YAML as !hobix.com,2004/entry
55
+ # objects. This type is virtually identical to !okay/news/feed objects,
56
+ # which are documented at http://yaml.kwiki.org/?OkayNews.
57
+ yaml_type "tag:okay.yaml.org,2002:news/entry#1.0"
58
+ yaml_type "tag:hobix.com,2004:entry"
59
+
60
+ end
61
+ end
62
+
63
+ module Hobix
64
+ # The EntryEnum class is mixed into an Array of entries just before
65
+ # passing on to a template. This Enumerator-like module provides some
66
+ # common iteration of entries.
67
+ module EntryEnum
68
+ # Calls the block with two arguments: (1) a Time object with
69
+ # the earliest date of an issued post for that day; (2) an
70
+ # Array of entries posted that day, in chronological order.
71
+ def each_day
72
+ last_day, day = nil, []
73
+ each do |e|
74
+ if last_day and last_day != e.day_id
75
+ yield day.first.created, day
76
+ day = []
77
+ end
78
+ last_day = e.day_id
79
+ day << e
80
+ end
81
+ yield day.first.created, day if last_day
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,99 @@
1
+ #
2
+ # = hobix/facets/comments.rb
3
+ #
4
+ # Hobix command-line weblog system, API for comments.
5
+ #
6
+ # Copyright (c) 2003-2004 why the lucky stiff
7
+ #
8
+ # Written & maintained by why the lucky stiff <why@ruby-lang.org>
9
+ #
10
+ # This program is free software, released under a BSD license.
11
+ # See COPYING for details.
12
+ #
13
+ #--
14
+ # $Id$
15
+ #++
16
+
17
+ require 'hobix/entry'
18
+
19
+ module Hobix
20
+ module Facets
21
+
22
+ # The Comments plugin adds a remote API for adding comments.
23
+ # Basically, to add comments to your site, ensure the plugin
24
+ # is loaded within your hobix.yaml `requires' list:
25
+ #
26
+ # requires:
27
+ # - hobix/facets/comments
28
+ #
29
+ class Comments < BaseFacet
30
+ def self.form_field( name ); "hobix_comment:#{ name }" end
31
+ def self.comment_fields; ['author', 'content']; end
32
+ def self.comment_class; Hobix::Comment end
33
+
34
+ def initialize( weblog, defaults = {} )
35
+ @weblog = weblog
36
+ end
37
+ def get app
38
+ if app.respond_to? :action_uri
39
+ action, entry_id = app.action_uri.split( '/', 2 )
40
+ case action
41
+ when "comment"
42
+ # Create the comment entry
43
+ on_entry = @weblog.storage.load_entry( entry_id )
44
+ comment = Comments.comment_class.new do |c|
45
+ Comments.comment_fields.each do |cf|
46
+ getf = Comments.form_field cf
47
+ if app._POST[getf].to_s.empty?
48
+ app.puts "Missing field `#{ getf }'. Please back up and try again."
49
+ return true
50
+ end
51
+ c.method( "#{ cf }=" ).call( app._POST[getf] )
52
+ end
53
+ c.created = Time.now
54
+ c.ipaddress = app.remote_addr
55
+ end
56
+
57
+ # A quick hack to try akismet content spam checking
58
+ if @weblog.requires.detect{ |i| i['hobix/plugin/akismet'] }
59
+ @akismet = Akismet.new(@weblog.link, AkismetKey.key)
60
+ if @akismet.verifyAPIKey
61
+ if @akismet.commentCheck(
62
+ app.remote_addr, # remote IP
63
+ app.get_request_header('User-Agent'), # user agent
64
+ app.get_request_header('Referer'), # http referer
65
+ '', # permalink
66
+ 'comment', # comment type
67
+ app._POST['hobix_comment:author'].to_s, # author name
68
+ '', # author email
69
+ '', # author url
70
+ app._POST['hobix_comment:comment'].to_s, # comment text
71
+ {}) # other
72
+ app.puts( "Sorry, that smelled like spam. If wasn't meant to, go back and try again" )
73
+ return true
74
+ end
75
+ else
76
+ # If the key does not verify, post the comment
77
+ # but note the failure in the apache error logs.
78
+ $stderr.puts( "Hobix: Akismet API key did not verify." )
79
+ end
80
+ end
81
+
82
+ # Save the comment, upgen
83
+ @weblog.storage.append_to_attachment( entry_id, 'comments', comment )
84
+ @weblog.regenerate :update
85
+
86
+ # Redirect
87
+ link = @weblog.output_entry_map[entry_id]
88
+ app.setup_redirection( 302, @weblog.expand_path( link[:page].link ) )
89
+ return true
90
+ when "preview"
91
+ app.puts RedCloth.new( app._POST[Comments.form_field('content')] ).to_html
92
+ return true
93
+ end
94
+ end
95
+ end
96
+ end
97
+
98
+ end
99
+ end