junebug-wiki 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +105 -0
- data/Manifest.txt +36 -0
- data/README.txt +87 -0
- data/RELEASE_NOTES.txt +25 -0
- data/Rakefile +63 -0
- data/bin/junebug +12 -0
- data/deploy/Rakefile +10 -0
- data/deploy/config.yml +15 -0
- data/deploy/console +8 -0
- data/deploy/public/images/feed-icon-14x14.png +0 -0
- data/deploy/public/style/base.css +274 -0
- data/deploy/public/style/yui/fonts.css +34 -0
- data/deploy/public/style/yui/grids.css +88 -0
- data/deploy/public/style/yui/reset.css +14 -0
- data/deploy/wiki +12 -0
- data/dump/junebug_pages.yml +148 -0
- data/lib/junebug.rb +55 -0
- data/lib/junebug/config.rb +15 -0
- data/lib/junebug/controllers.rb +187 -0
- data/lib/junebug/ext/acts_as_versioned.rb +509 -0
- data/lib/junebug/ext/diff.rb +317 -0
- data/lib/junebug/ext/mosquito.rb +210 -0
- data/lib/junebug/generator.rb +65 -0
- data/lib/junebug/helpers.rb +48 -0
- data/lib/junebug/models.rb +98 -0
- data/lib/junebug/tasks.rb +4 -0
- data/lib/junebug/tasks/dump.rake +34 -0
- data/lib/junebug/tasks/update.rake +27 -0
- data/lib/junebug/version.rb +9 -0
- data/lib/junebug/views.rb +307 -0
- data/setup.rb +1585 -0
- data/test/fixtures/junebug_page_versions.yml +0 -0
- data/test/fixtures/junebug_pages.yml +5 -0
- data/test/fixtures/junebug_users.yml +5 -0
- data/test/test_helper.rb +2 -0
- data/test/wiki_test.rb +270 -0
- metadata +134 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
|
3
|
+
Code licensed under the BSD License:
|
4
|
+
http://developer.yahoo.net/yui/license.txt
|
5
|
+
version: 0.11.3
|
6
|
+
*/
|
7
|
+
|
8
|
+
/**
|
9
|
+
* 84.5% for !IE, keywords for IE
|
10
|
+
* Percents could work for IE, but for backCompat purposes, we are using
|
11
|
+
keywords.
|
12
|
+
* x-small is for IE < 6 and IE6 quirks mode.
|
13
|
+
*
|
14
|
+
*/
|
15
|
+
body {font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-
|
16
|
+
small;}
|
17
|
+
table {font-size:inherit;font:100%;}
|
18
|
+
|
19
|
+
/**
|
20
|
+
* 99% for safari; 100% is too large
|
21
|
+
*/
|
22
|
+
select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Bump up !IE to get to 13px equivalent
|
26
|
+
*/
|
27
|
+
/*pre, code {font:115% monospace;*font-size:100%;}*/
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Default line-height based on font-size rather than "computed-value"
|
31
|
+
* see: http://www.w3.org/TR/CSS21/visudet.html#line-height
|
32
|
+
*/
|
33
|
+
body * {line-height:1.22em;}
|
34
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
|
3
|
+
Code licensed under the BSD License:
|
4
|
+
http://developer.yahoo.net/yui/license.txt
|
5
|
+
version: 0.11.3
|
6
|
+
*/
|
7
|
+
body {
|
8
|
+
text-align:center;
|
9
|
+
}
|
10
|
+
|
11
|
+
#doc {
|
12
|
+
width:57.69em;
|
13
|
+
*width:56.3em; /* IE */
|
14
|
+
min-width:750px;
|
15
|
+
margin:auto;
|
16
|
+
text-align:left;
|
17
|
+
}
|
18
|
+
|
19
|
+
#hd,#bd {margin-bottom:1em;text-align:left;}
|
20
|
+
#ft {/*font-size:77%;font-family:verdana;*/clear:both;}
|
21
|
+
|
22
|
+
/* rules for main templates */
|
23
|
+
.yui-t1 #yui-main .yui-b, .yui-t2 #yui-main .yui-b, .yui-t3 #yui-main .yui-b,
|
24
|
+
.yui-t4 .yui-b, .yui-t5 .yui-b, .yui-t6 .yui-b {float:right;}
|
25
|
+
.yui-t1 .yui-b, .yui-t2 .yui-b, .yui-t3 .yui-b, .yui-t4 #yui-main .yui-b, .yui-
|
26
|
+
t5 #yui-main .yui-b, .yui-t6 #yui-main .yui-b {float:left;}
|
27
|
+
|
28
|
+
/* t1: L160 */
|
29
|
+
.yui-t1 #yui-main .yui-b {width:76%;min-width:570px;}
|
30
|
+
.yui-t1 .yui-b {width:21.33%;min-width:160px;}
|
31
|
+
|
32
|
+
/* t2 & t4: L180 & R180 */
|
33
|
+
.yui-t2 #yui-main .yui-b, .yui-t4 #yui-main .yui-b {width:73.4%;min-
|
34
|
+
width:550px;}
|
35
|
+
.yui-t2 .yui-b, .yui-t4 .yui-b {width:24%;min-width:180px;}
|
36
|
+
|
37
|
+
/* t3 & t6: L300 & R300 */
|
38
|
+
.yui-t3 #yui-main .yui-b, .yui-t6 #yui-main .yui-b {width:57.6%;min-
|
39
|
+
width:430px;}
|
40
|
+
.yui-t3 .yui-b, .yui-t6 .yui-b {width:40%;min-width:300px;}
|
41
|
+
|
42
|
+
/* t5: R240 */
|
43
|
+
.yui-t5 #yui-main .yui-b {width:65.4%;min-width:490px;}
|
44
|
+
.yui-t5 .yui-b {width:32%;min-width:240px;}
|
45
|
+
|
46
|
+
/* t7: 750 */
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
/* grid-generic rules for all templates */
|
51
|
+
|
52
|
+
/* all modules and grids nested in a grid get floated */
|
53
|
+
.yui-g .yui-u, .yui-g .yui-g, .yui-ge .yui-u, .yui-gf .yui-u {
|
54
|
+
float:right;
|
55
|
+
display:inline; /* IE */
|
56
|
+
}
|
57
|
+
|
58
|
+
/* float left and kill margin on first for added flex */
|
59
|
+
.yui-g .first, .yui-gd .first, .yui-ge .first, .yui-gf .first {float:left; }
|
60
|
+
|
61
|
+
/* 2 col */
|
62
|
+
.yui-g .yui-u, .yui-g .yui-g {width:49.1%;}
|
63
|
+
.yui-g .yui-g .yui-u {width:48.1%;} /* smaller for nested to preserve margins */
|
64
|
+
|
65
|
+
/* 3 col */
|
66
|
+
.yui-gb .yui-u, .yui-gc .yui-u, .yui-gd .yui-u {
|
67
|
+
float:left; /* need to reverse the order for 3 */
|
68
|
+
margin-left:2%; *margin-left:1.895%;
|
69
|
+
width:32%;
|
70
|
+
}
|
71
|
+
|
72
|
+
.yui-gb .first, .yui-gc .first, .yui-gd .first {margin-left:0;}
|
73
|
+
|
74
|
+
/* colspan 2 */
|
75
|
+
.yui-gc .first, .yui-gd .yui-u {width:66%;}
|
76
|
+
.yui-gd .first {width:32%;}
|
77
|
+
|
78
|
+
/* colspan 3 */
|
79
|
+
.yui-ge .yui-u {width:24%;}
|
80
|
+
.yui-ge .first, .yui-gf .yui-u {width:74.2%;}
|
81
|
+
.yui-gf .first {width:24%;}
|
82
|
+
.yui-ge .first {width:74.2%;}
|
83
|
+
|
84
|
+
/* self clear floated parent containers */
|
85
|
+
#bd:after, .yui-g:after, .yui-gb:after, .yui-gc:after, .yui-gd:after, .yui-
|
86
|
+
ge:after, .yui-gf:after
|
87
|
+
{content:".";display:block;height:0;clear:both;visibility:hidden;}
|
88
|
+
#bd, .yui-g, .yui-gb, .yui-gc, .yui-gd, .yui-ge, .yui-gf {zoom:1;} /* IE */
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
|
3
|
+
Code licensed under the BSD License:
|
4
|
+
http://developer.yahoo.net/yui/license.txt
|
5
|
+
version: 0.11.3
|
6
|
+
*/
|
7
|
+
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td{margin:0;padding:0;}
|
8
|
+
table{border-collapse:collapse;border-spacing:0;}
|
9
|
+
fieldset,img{border:0;}
|
10
|
+
address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}
|
11
|
+
ol,ul {list-style:none;}
|
12
|
+
caption,th {text-align:left;}
|
13
|
+
h1,h2,h3,h4,h5,h6{font-size:100%;}
|
14
|
+
q:before,q:after{content:'';}
|
data/deploy/wiki
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift File.dirname(__FILE__) + "/../lib"
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'daemons'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'junebug/config'
|
8
|
+
|
9
|
+
JUNEBUG_ROOT = ENV['JUNEBUG_ROOT'] = File.dirname(File.expand_path(__FILE__))
|
10
|
+
|
11
|
+
Daemons.run(Junebug::Config.script, :dir_mode=>:normal, :dir=>JUNEBUG_ROOT)
|
12
|
+
|
@@ -0,0 +1,148 @@
|
|
1
|
+
---
|
2
|
+
- updated_at: 2006-11-07 18:24:43 -08:00
|
3
|
+
title: JunebugWiki
|
4
|
+
readonly: true
|
5
|
+
body: |
|
6
|
+
h1. Welcome to Junebug!
|
7
|
+
|
8
|
+
To complete setup of you new wiki, here are a few things you should do:
|
9
|
+
|
10
|
+
|
11
|
+
h3. 1. Login to your account
|
12
|
+
|
13
|
+
When you created this wiki, the username and password you submitted were used to set up an account for you. Now click the 'sign in' link at the upper right and sign in.
|
14
|
+
|
15
|
+
Once you sign in you will see your username in the upper right corner.
|
16
|
+
|
17
|
+
|
18
|
+
h3. 2. Set the start page
|
19
|
+
|
20
|
+
This page will always be the default start page for a new wiki. Probably not what you want, right? Fortunately, it is easy to change. Open the config.yml file (in your wiki directory) with any texteditor, and change the startpage field to the page you want.
|
21
|
+
|
22
|
+
Next, in your wiki directory, run the command:
|
23
|
+
|
24
|
+
ruby wiki restart
|
25
|
+
|
26
|
+
The next time you click on the 'Home' link in the nav bar, you will be taken to your new start page. If the page doesn't already exist, you will first be asked to login, and then you will be presented with an edit form to create the page.
|
27
|
+
|
28
|
+
|
29
|
+
h3. 3. Create some pages!
|
30
|
+
|
31
|
+
If you have any trouble, or need some help getting started, click on the 'Help' link in the nav bar. The documentation is pretty sparse right now, but I'm working on it!
|
32
|
+
|
33
|
+
id: 1
|
34
|
+
version: 1
|
35
|
+
user_id: 1
|
36
|
+
created_at: 2006-10-29 16:19:34 -08:00
|
37
|
+
- updated_at: 2006-11-07 18:24:43 -08:00
|
38
|
+
title: JunebugHelp
|
39
|
+
readonly:
|
40
|
+
body: This is a work in progress
|
41
|
+
id: 2
|
42
|
+
version: 1
|
43
|
+
user_id: 1
|
44
|
+
created_at: 2006-11-01 00:10:07 -08:00
|
45
|
+
- updated_at: 2006-11-07 18:24:43 -08:00
|
46
|
+
title: FormatTest
|
47
|
+
readonly:
|
48
|
+
body: |-
|
49
|
+
See "this page":http://hobix.com/textile/ for the full range of formatting options
|
50
|
+
|
51
|
+
h2. Headers
|
52
|
+
|
53
|
+
h1. Header 1
|
54
|
+
|
55
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
56
|
+
|
57
|
+
h2. Header 2
|
58
|
+
|
59
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
60
|
+
|
61
|
+
h3. Header 3
|
62
|
+
|
63
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
64
|
+
|
65
|
+
h4. Header 4
|
66
|
+
|
67
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
68
|
+
|
69
|
+
h5. Header 5
|
70
|
+
|
71
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
72
|
+
|
73
|
+
h2. Structural emphasis
|
74
|
+
|
75
|
+
This is _emphasis_ (italic)
|
76
|
+
|
77
|
+
This is *strong* (bold)
|
78
|
+
|
79
|
+
This is @code@
|
80
|
+
|
81
|
+
more code
|
82
|
+
@difftext = diff( @v1_markup , @v2_markup)
|
83
|
+
|
84
|
+
This is -deleted- text
|
85
|
+
|
86
|
+
This is +inserted+ text
|
87
|
+
|
88
|
+
Arbitrary style: I'm %{color:red}unaware% of most soft drinks.
|
89
|
+
|
90
|
+
|
91
|
+
h2. Arbitrary html, pre, and code
|
92
|
+
|
93
|
+
Inserting arbitrary html (pre/code)
|
94
|
+
|
95
|
+
<pre><code>a.gsub!( /</, '' )</code></pre>
|
96
|
+
|
97
|
+
Inserting arbitrary html (pre/code)
|
98
|
+
|
99
|
+
<pre>
|
100
|
+
<code>a.gsub!( /</, '' )</code>
|
101
|
+
</pre>
|
102
|
+
|
103
|
+
Arbitrary html (pre)
|
104
|
+
|
105
|
+
<pre>
|
106
|
+
a.gsub!( /</, '' )
|
107
|
+
</pre>
|
108
|
+
|
109
|
+
Code by indenting
|
110
|
+
|
111
|
+
more code
|
112
|
+
@difftext = diff( @v1_markup , @v2_markup)
|
113
|
+
|
114
|
+
h2. Lists
|
115
|
+
|
116
|
+
# A first item
|
117
|
+
# A second item
|
118
|
+
# A third
|
119
|
+
|
120
|
+
# Fuel could be:
|
121
|
+
## Coal
|
122
|
+
## Gasoline
|
123
|
+
## Electricity
|
124
|
+
# Humans need only:
|
125
|
+
## Water
|
126
|
+
## Protein
|
127
|
+
|
128
|
+
* A first item
|
129
|
+
* A second item
|
130
|
+
* A third
|
131
|
+
|
132
|
+
h2. External references
|
133
|
+
|
134
|
+
This is a link: "Google":http://google.com
|
135
|
+
|
136
|
+
Images: !/static/images/feed-icon-14x14.png!
|
137
|
+
|
138
|
+
|
139
|
+
h2. Tables
|
140
|
+
|
141
|
+
|_. name |_. age |_. sex |
|
142
|
+
| joan | 24 | f |
|
143
|
+
| archie | 29 | m |
|
144
|
+
| bella | 45 | f |
|
145
|
+
id: 3
|
146
|
+
version: 1
|
147
|
+
user_id: 1
|
148
|
+
created_at: 2006-11-06 09:40:53 -08:00
|
data/lib/junebug.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) # for running in foreground in dev
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require_gem 'camping', '>=1.5'
|
5
|
+
require 'camping/session'
|
6
|
+
|
7
|
+
Camping.goes :Junebug
|
8
|
+
|
9
|
+
require 'junebug/version'
|
10
|
+
require 'junebug/helpers'
|
11
|
+
require 'junebug/models'
|
12
|
+
require 'junebug/views'
|
13
|
+
require 'junebug/controllers'
|
14
|
+
|
15
|
+
require 'yaml'
|
16
|
+
require 'mongrel'
|
17
|
+
require 'fileutils'
|
18
|
+
|
19
|
+
module Junebug
|
20
|
+
include Camping::Session
|
21
|
+
|
22
|
+
def self.create
|
23
|
+
Junebug::Models.create_schema :assume => (Junebug::Models::Page.table_exists? ? 1.0 : 0.0)
|
24
|
+
Camping::Models::Session.create_schema
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.connect
|
28
|
+
Junebug::Models::Base.establish_connection :adapter => 'sqlite3', :database => 'junebug.db'
|
29
|
+
Junebug::Models::Base.logger = Logger.new('junebug.log')
|
30
|
+
Junebug::Models::Base.threaded_connections=false
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.config
|
34
|
+
@config ||= YAML.load(File.read('config.yml'))
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.startpage
|
38
|
+
"#{Junebug.config['url']}/#{Junebug.config['startpage']}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
if __FILE__ == $0 || ENV['DAEMONS_ARGV']
|
44
|
+
# When using daemons, the current dir is /
|
45
|
+
# So we need to set it to the junebug root
|
46
|
+
FileUtils.cd ENV['JUNEBUG_ROOT'] if ENV['JUNEBUG_ROOT']
|
47
|
+
Junebug.connect
|
48
|
+
Junebug.create
|
49
|
+
|
50
|
+
server = Mongrel::Camping::start( Junebug.config['host'], Junebug.config['port'], Junebug.config['sitepath'], Junebug)
|
51
|
+
|
52
|
+
puts "** Junebug is running at http://#{Junebug.config['host']}:#{Junebug.config['port']}#{Junebug.config['sitepath']}"
|
53
|
+
|
54
|
+
server.run.join
|
55
|
+
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
require 'junebug/ext/diff'
|
2
|
+
|
3
|
+
module Junebug::Controllers
|
4
|
+
|
5
|
+
|
6
|
+
class Index < R '/'
|
7
|
+
def get
|
8
|
+
redirect Junebug.startpage
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Show < R '/([\w ]+)', '/([\w ]+)/(\d+)'
|
13
|
+
def get page_name, version = nil
|
14
|
+
@page_title = page_name
|
15
|
+
#redirect(Edit, page_name, 1) and return unless @page = Page.find_by_title(page_name)
|
16
|
+
redirect("#{Junebug.config['url']}/#{page_name.gsub(/ /,'+')}/1/edit") and return unless @page = Page.find_by_title(page_name)
|
17
|
+
@version = (version.nil? or version == @page.version.to_s) ? @page : @page.versions.find_by_version(version)
|
18
|
+
render :show
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Edit < R '/([\w ]+)/edit', '/([\w ]+)/(\d+)/edit'
|
23
|
+
def get page_name, version = nil
|
24
|
+
redirect("#{Junebug.config['url']}/login") and return unless logged_in?
|
25
|
+
@page_title = "Edit #{page_name}"
|
26
|
+
@page = Page.find(:first, :conditions=>['title = ?', page_name])
|
27
|
+
@page = Page.create(:title => page_name, :user_id=>@state.user.id) unless @page
|
28
|
+
@page = @page.versions.find_by_version(version) unless version.nil? or version == @page.version.to_s
|
29
|
+
render :edit
|
30
|
+
end
|
31
|
+
|
32
|
+
# FIXME: no error checking, also no verify quicksave/readonly rights
|
33
|
+
def post page_name
|
34
|
+
redirect("#{Junebug.config['url']}/login") and return unless logged_in?
|
35
|
+
if input.submit == 'save'
|
36
|
+
if ! input.quicksave
|
37
|
+
attrs = { :body => input.post_body, :title => input.post_title, :user_id =>@state.user.id }
|
38
|
+
attrs[:readonly] = input.post_readonly if is_admin?
|
39
|
+
Page.find_or_create_by_title(page_name).update_attributes(attrs)
|
40
|
+
else
|
41
|
+
attrs = { :body => input.post_body }
|
42
|
+
attrs[:readonly] = input.post_readonly if is_admin?
|
43
|
+
page = Page.find_by_title(page_name)
|
44
|
+
current_version = page.find_version(page.version)
|
45
|
+
current_version.update_attributes(attrs)
|
46
|
+
page.without_revision { page.update_attributes(attrs) }
|
47
|
+
end
|
48
|
+
# redirect Show, input.post_title
|
49
|
+
redirect "#{Junebug.config['url']}/#{input.post_title.gsub(/ /,'+')}"
|
50
|
+
else # cancel
|
51
|
+
redirect "#{Junebug.config['url']}/#{page_name.gsub(/ /,'+')}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class Delete < R '/([\w ]+)/delete'
|
57
|
+
def get page_name
|
58
|
+
redirect("#{Junebug.config['url']}/login") and return unless logged_in?
|
59
|
+
Page.find_by_title(page_name).destroy() if is_admin?
|
60
|
+
redirect Junebug.startpage
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
class Revert < R '/([\w ]+)/(\d+)/revert'
|
66
|
+
def get page_name, version
|
67
|
+
redirect("#{Junebug.config['url']}/login") and return unless logged_in?
|
68
|
+
Page.find_by_title(page_name).revert_to!(version) if is_admin?
|
69
|
+
redirect "#{Junebug.config['url']}/#{page_name.gsub(/ /,'+')}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class Versions < R '/([\w ]+)/versions'
|
74
|
+
def get page_name
|
75
|
+
@page_title = "Version History: #{page_name}"
|
76
|
+
@page = Page.find_by_title(page_name)
|
77
|
+
@versions = @page.find_versions(:order => 'version DESC', :include => [:user])
|
78
|
+
render :versions
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class List < R '/all/list'
|
83
|
+
def get
|
84
|
+
@page_title = "All Pages"
|
85
|
+
@pages = Page.find :all, :order => 'title'
|
86
|
+
render :list
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class Backlinks < R '/([\w ]+)/backlinks'
|
91
|
+
def get page_name
|
92
|
+
@page = Page.find_by_title(page_name)
|
93
|
+
@page_title = "Backlinks for: #{page_name}"
|
94
|
+
@pages = Page.find(:all, :conditions => ["body LIKE ?", "%#{page_name}%"])
|
95
|
+
render :backlinks
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
class Recent < R '/all/recent'
|
100
|
+
def get
|
101
|
+
@page_title = "Recent Changes"
|
102
|
+
@pages = Page.find(:all, :order => 'updated_at DESC', :conditions => "julianday('now')-julianday(updated_at) < 30.0")
|
103
|
+
render :recent
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
class Diff < R '/([\w ]+)/(\d+)/(\d+)/diff'
|
108
|
+
include HTMLDiff
|
109
|
+
def get page_name, v1, v2
|
110
|
+
@page_title = "Diff: #{page_name}"
|
111
|
+
@page = Page.find_by_title(page_name)
|
112
|
+
@v1 = @page.find_version(v1)
|
113
|
+
@v2 = @page.find_version(v2)
|
114
|
+
|
115
|
+
#@v1_markup = ( @v1.body ? _markup( @v1.body ) : '' )
|
116
|
+
#@v2_markup = ( @v2.body ? _markup( @v2.body ) : '' )
|
117
|
+
@v1_markup = @v1.body || ''
|
118
|
+
@v2_markup = @v2.body || ''
|
119
|
+
|
120
|
+
@difftext = diff( @v1_markup , @v2_markup)
|
121
|
+
|
122
|
+
render :diff
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
class Feed < R '/all/feed'
|
127
|
+
def get
|
128
|
+
@headers['Content-Type'] = 'application/xml'
|
129
|
+
return Junebug::Views.feed
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
class Static < R '(/images/.+)', '(/style/.+)'
|
134
|
+
MIME_TYPES = {'.css' => 'text/css', '.js' => 'text/javascript', '.jpg' => 'image/jpeg'}
|
135
|
+
#PATH = __FILE__[/(.*)\//, 1]
|
136
|
+
PATH = ENV['JUNEBUG_ROOT'] || '.'
|
137
|
+
|
138
|
+
def get(path)
|
139
|
+
@headers['Content-Type'] = MIME_TYPES[path[/\.\w+$/, 0]] || "text/plain"
|
140
|
+
unless path =~ /\.\./ # sample test to prevent directory traversal attacks
|
141
|
+
@headers['X-Sendfile'] = "#{PATH}/public#{path}"
|
142
|
+
else
|
143
|
+
"404 - Invalid path"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
class Login
|
149
|
+
def get
|
150
|
+
@page_title = "Login/Create Account"
|
151
|
+
@return_to = input.return_to
|
152
|
+
render :login
|
153
|
+
end
|
154
|
+
|
155
|
+
def post
|
156
|
+
@page_title = "Login/Create Account"
|
157
|
+
@user = User.find :first, :conditions => ['username = ? AND password = ?', input.username, input.password]
|
158
|
+
@return_to = input.return_to
|
159
|
+
if @user
|
160
|
+
if @user.password == input.password
|
161
|
+
@state.user = @user
|
162
|
+
input.return_to.blank? ? redirect(Junebug.startpage) : redirect(Junebug.config['url'] + input.return_to)
|
163
|
+
return
|
164
|
+
else
|
165
|
+
@notice = 'Authentication failed'
|
166
|
+
end
|
167
|
+
else
|
168
|
+
@user = User.create :username=>input.username, :password=>input.password
|
169
|
+
if @user.errors.empty?
|
170
|
+
@state.user = @user
|
171
|
+
input.return_to.blank? ? redirect(Junebug.startpage) : redirect(Junebug.config['url'] + input.return_to)
|
172
|
+
return
|
173
|
+
else
|
174
|
+
@notice = @user.errors.full_messages[0]
|
175
|
+
end
|
176
|
+
end
|
177
|
+
render :login
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
class Logout
|
182
|
+
def get
|
183
|
+
@state.user = nil
|
184
|
+
input.return_to.blank? ? redirect(Junebug.startpage) : redirect(Junebug.config['url'] + input.return_to)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|