junebug 0.0.10 → 0.0.11
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.
- data/CHANGELOG +7 -0
- data/Rakefile +1 -1
- data/deploy/Rakefile +17 -6
- data/deploy/static/style/base.css +10 -0
- data/lib/junebug/controllers.rb +18 -1
- data/lib/junebug/models.rb +7 -3
- data/lib/junebug/views.rb +15 -9
- data/test/fixtures/junebug_users.yml +1 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ Gem.manage_gems
|
|
12
12
|
|
13
13
|
gem_spec = Gem::Specification.new do |s|
|
14
14
|
s.name = 'junebug'
|
15
|
-
s.version = '0.0.
|
15
|
+
s.version = '0.0.11'
|
16
16
|
s.summary = "Junebug is a minimalist ruby wiki."
|
17
17
|
s.description = "Junebug is a minimalist ruby wiki running on Camping."
|
18
18
|
s.author = "Tim Myrtle"
|
data/deploy/Rakefile
CHANGED
@@ -5,15 +5,26 @@ require 'rake'
|
|
5
5
|
|
6
6
|
require 'junebug/config'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
namespace :update do
|
9
|
+
|
10
|
+
desc "Update stylesheets"
|
11
|
+
task :stylesheets do
|
12
|
+
junebug_root = Junebug::Config.rootdir
|
13
|
+
cp_r File.join(junebug_root, 'deploy', 'static'), '.'
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Update rakefile"
|
17
|
+
task :rakefile do
|
18
|
+
junebug_root = Junebug::Config.rootdir
|
19
|
+
cp File.join(junebug_root, 'deploy', 'Rakefile'), '.'
|
20
|
+
end
|
14
21
|
|
22
|
+
desc "Update everything"
|
23
|
+
task :everything => [:stylesheets, :rakefile] do
|
15
24
|
|
25
|
+
end
|
16
26
|
|
27
|
+
end
|
17
28
|
|
18
29
|
|
19
30
|
|
@@ -131,6 +131,16 @@ body {
|
|
131
131
|
color: #822;
|
132
132
|
}
|
133
133
|
|
134
|
+
.admin {
|
135
|
+
float: left;
|
136
|
+
/* background-color: #ffa;*/
|
137
|
+
}
|
138
|
+
|
139
|
+
.admin input.button {
|
140
|
+
background-color: #ffa;
|
141
|
+
font-size: 85%;
|
142
|
+
margin: 0;
|
143
|
+
}
|
134
144
|
|
135
145
|
/* WIKI CONTENT STYLES */
|
136
146
|
.content {
|
data/lib/junebug/controllers.rb
CHANGED
@@ -35,7 +35,7 @@ module Junebug::Controllers
|
|
35
35
|
Page.find_by_title(page_name).destroy() if @state.user_id == 1
|
36
36
|
redirect Junebug.startpage
|
37
37
|
elsif input.submit == 'save'
|
38
|
-
attrs = { :body => input.post_body, :title => input.post_title }
|
38
|
+
attrs = { :body => input.post_body, :title => input.post_title, :user_id =>@state.user_id }
|
39
39
|
attrs[:readonly] = input.post_readonly if @state.user_id == 1
|
40
40
|
if Page.find_or_create_by_title(page_name).update_attributes( attrs )
|
41
41
|
# redirect Show, input.post_title
|
@@ -46,6 +46,23 @@ module Junebug::Controllers
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
class Delete < R '/(\w+)/delete'
|
51
|
+
def get page_name
|
52
|
+
redirect("#{Junebug.config['url']}/login") and return if @state.user_id.blank?
|
53
|
+
Page.find_by_title(page_name).destroy() if @state.user_id == 1
|
54
|
+
redirect Junebug.startpage
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
class Revert < R '/(\w+)/(\d+)/revert'
|
60
|
+
def get page_name, version
|
61
|
+
redirect("#{Junebug.config['url']}/login") and return if @state.user_id.blank?
|
62
|
+
Page.find_by_title(page_name).revert_to!(version) if @state.user_id == 1
|
63
|
+
redirect "#{Junebug.config['url']}/#{page_name}"
|
64
|
+
end
|
65
|
+
end
|
49
66
|
|
50
67
|
class Versions < R '/(\w+)/versions'
|
51
68
|
def get page_name
|
data/lib/junebug/models.rb
CHANGED
@@ -4,6 +4,9 @@ require 'acts_as_versioned'
|
|
4
4
|
module Junebug::Models
|
5
5
|
|
6
6
|
class User < Base
|
7
|
+
|
8
|
+
ROLE_USER = 0
|
9
|
+
ROLE_ADMIN = 10
|
7
10
|
validates_uniqueness_of :username
|
8
11
|
validates_format_of :username, :with => /^([\w]*)$/
|
9
12
|
validates_length_of :username, :within=>3..30
|
@@ -41,8 +44,9 @@ module Junebug::Models
|
|
41
44
|
def self.up
|
42
45
|
create_table :junebug_users do |t|
|
43
46
|
t.column :id, :integer, :null => false
|
44
|
-
t.column :username, :string
|
45
|
-
t.column :password, :string
|
47
|
+
t.column :username, :string, :null => false
|
48
|
+
t.column :password, :string, :null => false
|
49
|
+
t.column :role, :integer, :default => 0
|
46
50
|
end
|
47
51
|
create_table :junebug_pages do |t|
|
48
52
|
t.column :title, :string, :limit => 255
|
@@ -66,7 +70,7 @@ module Junebug::Models
|
|
66
70
|
username = 'admin'
|
67
71
|
password = 'password'
|
68
72
|
end
|
69
|
-
admin = User.create :username => username, :password => password
|
73
|
+
admin = User.create :username => username, :password => password, :role => User::ROLE_ADMIN
|
70
74
|
|
71
75
|
# Install some default pages
|
72
76
|
pages_file = File.dirname(__FILE__) + "/../../fixtures/junebug_pages.yml"
|
data/lib/junebug/views.rb
CHANGED
@@ -24,9 +24,9 @@ module Junebug::Views
|
|
24
24
|
_header (@version.version == @page.version ? :show : :backlinks), @page.title
|
25
25
|
_body {
|
26
26
|
div.content {
|
27
|
-
_button '
|
27
|
+
_button 'edit', R(Edit, @page.title, @version.version), {:style=>'float: right; margin: 0 0 5px 5px;'} if (@version.version == @page.version && (! @page.readonly || @state.user_id == 1))
|
28
28
|
_markup @version.body
|
29
|
-
_button '
|
29
|
+
_button 'edit', R(Edit, @page.title, @version.version), {:style=>'float: right; margin: 0 0 5px 5px;'} if (@version.version == @page.version && (! @page.readonly || @state.user_id == 1)) && (@version.body && @version.body.size > 100)
|
30
30
|
}
|
31
31
|
}
|
32
32
|
_footer {
|
@@ -45,9 +45,15 @@ module Junebug::Views
|
|
45
45
|
a '«older', :href => R(Show, @page.title, @version.version-1) unless @version.version == 1
|
46
46
|
a 'newer»', :href => R(Show, @page.title, @version.version+1) unless @version.version == @page.version
|
47
47
|
a 'current', :href => R(Show, @page.title) unless @version.version == @page.version
|
48
|
-
a '
|
48
|
+
a 'versions', :href => R(Versions, @page.title)
|
49
49
|
}
|
50
50
|
}
|
51
|
+
if (@state.user_id == 1)
|
52
|
+
div.admin {
|
53
|
+
_button 'delete', R(Delete, @page.title), {:onclick=>'return confirm("Sure you want to delete?")'} if @version.version == @page.version
|
54
|
+
_button 'revert to', R(Revert, @page.title, @version.version), {:onclick=>'return confirm("Sure you want to revert?")'} if @version.version != @page.version
|
55
|
+
}
|
56
|
+
end
|
51
57
|
end
|
52
58
|
|
53
59
|
def edit
|
@@ -66,7 +72,7 @@ module Junebug::Views
|
|
66
72
|
p {
|
67
73
|
label 'Page Content'
|
68
74
|
br
|
69
|
-
textarea @page.body, :name => 'post_body', :rows =>
|
75
|
+
textarea @page.body, :name => 'post_body', :rows => 17, :cols => 80
|
70
76
|
}
|
71
77
|
if @state.user_id == 1
|
72
78
|
opts = { :type => 'checkbox', :value=>'1', :name => 'post_readonly' }
|
@@ -77,7 +83,6 @@ module Junebug::Views
|
|
77
83
|
end
|
78
84
|
input :type => 'submit', :name=>'submit', :value=>'cancel', :class=>'button', :style=>'float: right;'
|
79
85
|
input :type => 'submit', :name=>'submit', :value=>'save', :class=>'button', :style=>'float: right;'
|
80
|
-
input :type => 'submit', :name=>'submit', :value=>'delete', :class=>'button', :onclick=>'return confirm("You sure?")'
|
81
86
|
end
|
82
87
|
a 'syntax help', :href => 'http://hobix.com/textile/', :target=>'_blank'
|
83
88
|
br :clear=>'all'
|
@@ -104,7 +109,7 @@ module Junebug::Views
|
|
104
109
|
text last_updated(page)
|
105
110
|
text ' ago by '
|
106
111
|
strong page.user.username
|
107
|
-
text ' (current)' if
|
112
|
+
text ' (current)' if @page.version == page.version
|
108
113
|
}
|
109
114
|
end
|
110
115
|
}
|
@@ -195,9 +200,10 @@ module Junebug::Views
|
|
195
200
|
}
|
196
201
|
end
|
197
202
|
|
198
|
-
def _button(text, options={})
|
199
|
-
form :method=>:get, :action=>
|
200
|
-
|
203
|
+
def _button(text, href, options={})
|
204
|
+
form :method=>:get, :action=>href do
|
205
|
+
opts = {:type=>'submit', :name=>'submit', :value=>text}.merge(options)
|
206
|
+
input.button opts
|
201
207
|
end
|
202
208
|
end
|
203
209
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: junebug
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2006-11-
|
6
|
+
version: 0.0.11
|
7
|
+
date: 2006-11-13 00:00:00 -08:00
|
8
8
|
summary: Junebug is a minimalist ruby wiki.
|
9
9
|
require_paths:
|
10
10
|
- lib
|