hobix 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/bin/hobix +90 -0
  3. data/lib/hobix/api.rb +91 -0
  4. data/lib/hobix/article.rb +22 -0
  5. data/lib/hobix/base.rb +477 -0
  6. data/lib/hobix/bixwik.rb +200 -0
  7. data/lib/hobix/commandline.rb +661 -0
  8. data/lib/hobix/comments.rb +99 -0
  9. data/lib/hobix/config.rb +39 -0
  10. data/lib/hobix/datamarsh.rb +110 -0
  11. data/lib/hobix/entry.rb +83 -0
  12. data/lib/hobix/facets/comments.rb +74 -0
  13. data/lib/hobix/facets/publisher.rb +314 -0
  14. data/lib/hobix/facets/trackbacks.rb +80 -0
  15. data/lib/hobix/linklist.rb +76 -0
  16. data/lib/hobix/out/atom.rb +92 -0
  17. data/lib/hobix/out/erb.rb +64 -0
  18. data/lib/hobix/out/okaynews.rb +55 -0
  19. data/lib/hobix/out/quick.rb +312 -0
  20. data/lib/hobix/out/rdf.rb +97 -0
  21. data/lib/hobix/out/redrum.rb +26 -0
  22. data/lib/hobix/out/rss.rb +115 -0
  23. data/lib/hobix/plugin/bloglines.rb +73 -0
  24. data/lib/hobix/plugin/calendar.rb +220 -0
  25. data/lib/hobix/plugin/flickr.rb +110 -0
  26. data/lib/hobix/plugin/recent_comments.rb +82 -0
  27. data/lib/hobix/plugin/sections.rb +91 -0
  28. data/lib/hobix/plugin/tags.rb +60 -0
  29. data/lib/hobix/publish/ping.rb +53 -0
  30. data/lib/hobix/publish/replicate.rb +283 -0
  31. data/lib/hobix/publisher.rb +18 -0
  32. data/lib/hobix/search/dictionary.rb +141 -0
  33. data/lib/hobix/search/porter_stemmer.rb +203 -0
  34. data/lib/hobix/search/simple.rb +209 -0
  35. data/lib/hobix/search/vector.rb +100 -0
  36. data/lib/hobix/storage/filesys.rb +398 -0
  37. data/lib/hobix/trackbacks.rb +94 -0
  38. data/lib/hobix/util/objedit.rb +193 -0
  39. data/lib/hobix/util/patcher.rb +155 -0
  40. data/lib/hobix/webapp/cli.rb +195 -0
  41. data/lib/hobix/webapp/htmlform.rb +107 -0
  42. data/lib/hobix/webapp/message.rb +177 -0
  43. data/lib/hobix/webapp/urigen.rb +141 -0
  44. data/lib/hobix/webapp/webrick-servlet.rb +90 -0
  45. data/lib/hobix/webapp.rb +723 -0
  46. data/lib/hobix/weblog.rb +860 -0
  47. data/lib/hobix.rb +223 -0
  48. metadata +87 -0
@@ -0,0 +1,200 @@
1
+ #
2
+ # = hobix/bixwik.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
+ require 'hobix/weblog'
17
+
18
+ module Hobix
19
+ # The BixWik class is an extended Weblog, which acts like a Wiki.
20
+ # (See http://instiki.org/ for inspiration.)
21
+ class BixWikPlugin < Hobix::BasePlugin
22
+ def initialize( weblog )
23
+ class << weblog
24
+ include Hobix::BixWik
25
+ end
26
+ end
27
+ end
28
+
29
+ module BixWik
30
+
31
+ QUICK_MENU = YAML::load <<-END
32
+ --- %YAML:1.0 !omap
33
+ - HomePage: [Home Page, H, Start Over]
34
+ - list/index: [All Pages, A, Alphabetically sorted list of pages]
35
+ - recent/index: [Recently Revised, U, Pages sorted by when they were last changed]
36
+ - authors/index: [Authors, ~, Who wrote what]
37
+ - FeedList: [Feed List, ~, Subscribe to changes by RSS]
38
+ END
39
+
40
+ def default_entry_class; "Hobix::BixWik::Entry"; end
41
+ def default_index_class; "Hobix::BixWik::IndexEntry"; end
42
+
43
+ # Handler for templates with `index' prefix. These pages simply
44
+ # mirror the `HomePage' entry.
45
+ def skel_index( path_storage )
46
+ homePage = path_storage.match( /^HomePage$/ ).first
47
+ page = Page.new( '/index' )
48
+ unless homePage
49
+ homePage = Hobix::Storage::IndexEntry.new( path_storage.default_entry( authors.keys.first ) )
50
+ end
51
+ page.timestamp = homePage.created
52
+ page.updated = homePage.created
53
+ yield :page => page, :entry => homePage
54
+ end
55
+
56
+ # Handler for templates with `list/index' prefix. These templates will
57
+ # receive IndexEntry objects for every entry in the system. Only one
58
+ # index page is requested by this handler.
59
+ def skel_recent_index( path_storage )
60
+ index_entries = storage.find( :all => true )
61
+ page = Page.new( '/list/index' )
62
+ page.timestamp = index_entries.first.created
63
+ page.updated = storage.last_modified( index_entries )
64
+ yield :page => page, :entries => index_entries
65
+ end
66
+
67
+ # Handler for templates with `recent/index' prefix. These templates will
68
+ # receive entries loaded by +Hobix::BaseStorage#lastn+. Only one
69
+ # index page is requested by this handler.
70
+ def skel_recent_index( path_storage )
71
+ index_entries = storage.lastn( @lastn || 120 )
72
+ page = Page.new( '/recent/index' )
73
+ page.timestamp = index_entries.first.created
74
+ page.updated = storage.last_modified( index_entries )
75
+ yield :page => page, :entries => index_entries
76
+ end
77
+
78
+ # Handler for templates with `list/index' prefix. These templates will
79
+ # receive a list of all pages in the Wiki.
80
+ def skel_list_index( path_storage )
81
+ all_pages = storage.all
82
+ page = Page.new( '/list/index' )
83
+ page.timestamp = all_pages.first.created
84
+ page.updated = storage.last_modified( all_pages )
85
+ yield :page => page, :entries => all_pages, :no_load => true
86
+ end
87
+
88
+ def abs_link( word )
89
+ output_entry_map[word] && output_entry_map[word][:page].link
90
+ end
91
+
92
+ def wiki_page( src )
93
+ src.gsub( /\b([A-Z][a-z]+[A-Z][\w\/]+)\b/ ) { wiki_link( $1 ) }
94
+ end
95
+
96
+ def wiki_link( word )
97
+ abs_link = output_entry_map[word]
98
+ if abs_link
99
+ "<a class=\"existingWikiWord\" href=\"#{ expand_path( abs_link[:page].link ) }\">#{ Hobix::BixWik::wiki_word word }</a>"
100
+ else
101
+ "<span class=\"newWikiWord\">#{ Hobix::BixWik::wiki_word word }<a href=\"#{ expand_path( "control/edit/#{ word }" ) }\">?</a></span>"
102
+ end
103
+ end
104
+
105
+ def self.wiki_word( id )
106
+ Hobix::BixWik::QUICK_MENU[ id ].to_a.first || id.gsub( /^\w|_\w|[A-Z]/ ) { |up| " #{up[-1, 1].upcase}" }.strip
107
+ end
108
+
109
+ require 'redcloth'
110
+ class WikiRedCloth < RedCloth
111
+ end
112
+
113
+ class IndexEntry < Hobix::IndexEntry
114
+ _ :author
115
+ def title
116
+ Hobix::BixWik::wiki_word( self.id )
117
+ end
118
+ def to_yaml_type
119
+ "!hobix.com,2004/bixwik/indexEntry"
120
+ end
121
+ end
122
+
123
+ class Entry < Hobix::Entry
124
+ def title
125
+ Hobix::BixWik::wiki_word( self.id )
126
+ end
127
+ def to_yaml_type
128
+ "!hobix.com,2004/bixwik/entry"
129
+ end
130
+ def self.text_processor; WikiRedCloth; end
131
+ end
132
+ end
133
+ end
134
+
135
+ YAML::add_domain_type( 'hobix.com,2004', 'bixwik/entry' ) do |type, val|
136
+ Hobix::BixWik::Entry::maker( val )
137
+ end
138
+
139
+ YAML::add_domain_type( 'hobix.com,2004', 'bixwik/indexEntry' ) do |type, val|
140
+ YAML::object_maker( Hobix::BixWik::IndexEntry, val )
141
+ end
142
+
143
+ module Hobix
144
+ module Facets
145
+ class WikiEdit < BaseFacet
146
+ def initialize( weblog, defaults = {} )
147
+ @weblog = weblog
148
+ end
149
+ def get app
150
+ if app.respond_to? :action_uri
151
+ ns, method_id = app.action_uri.split( '/', 2 )
152
+ return false unless ns == "edit"
153
+
154
+ # Display publisher page
155
+ app.content_type = 'text/html'
156
+ app.puts ::ERB.new( erb_src, nil, nil, "_bixwik" ).result( binding )
157
+ return true
158
+ end
159
+ end
160
+ end
161
+ end
162
+
163
+ module Out
164
+ class Quick
165
+ def banner_erb; %{
166
+ <% page_id = page.id %>
167
+ <% page_id = 'HomePage' if page.id == 'index' %>
168
+ <% page_name = Hobix::BixWik::wiki_word( page_id ) %>
169
+ <div id="banner">
170
+ <% if page_id == "HomePage" %>
171
+ <h1 id="title"><%= weblog.title %></h1>
172
+ <% if weblog.tagline %><div id="tagline"><%= weblog.tagline %></div><% end %>
173
+ <% else %>
174
+ <div id="title"><%= weblog.title %></div>
175
+ <h1 id="pageName"><%= page_name %></h1>
176
+ <% end %>
177
+ <form id="navigationForm" class="navigation" action="<%= weblog.expand_path( 'search' ) %>" action="get" style="font-size: 10px">
178
+ <% Hobix::BixWik::QUICK_MENU.each do |menu_link, attr| %>
179
+ <% if page_id == menu_link %>
180
+ <%= attr[0] %>
181
+ <% else %>
182
+ <a href="<%= weblog.abs_link( menu_link ) %>" title="<% if attr[1] %>[<%= attr[1] %>] <% end %><%= attr[2] %>"
183
+ accesskey="<%= attr[1] %>"><%= attr[0] %></a>
184
+ <% end %> |
185
+ <% end %>
186
+ <input type="text" id="searchField" name="query" style="font-size: 10px" value="Search" onClick="this.value == 'Search' ? this.value = '' : true">
187
+ </form>
188
+ </div> }
189
+ end
190
+ def entry_title_erb; end
191
+ def entry_content_erb
192
+ %{ <div class="entryContent"><%= weblog.wiki_page( entry.content.to_html ) %></div> }
193
+ end
194
+ def sidebar_erb; nil; end
195
+ def entry_footer_erb; %{
196
+ Revision from <%= ( entry.modified || entry.created ).strftime( "%B %d, %Y %H:%M" ) %> by <%= weblog.wiki_link( "authors/" + entry.author ) %> }
197
+ end
198
+ end
199
+ end
200
+ end