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 CHANGED
@@ -1,3 +1,10 @@
1
+ v0.0.11 2006-11-13
2
+
3
+ * Added revert
4
+ * Versioning bugfix
5
+ * Changed delete operation
6
+ * Added 'role' user field
7
+
1
8
  v0.0.10 2006-11-12
2
9
 
3
10
  * Submit bugfix
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.10'
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
- desc "Update stylesheets"
9
- task :update_stylesheets do
10
- junebug_root = Junebug::Config.rootdir
11
- puts junebug_root
12
- cp File.join(junebug_root, 'deploy', 'static', 'style', 'base.css'), File.join('static', 'style')
13
- end
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 {
@@ -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
@@ -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 'Edit page', {:href => 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))
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 'Edit page', {:href => 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.size > 100
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 'show all', :href => R(Versions, @page.title)
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 => 20, :cols => 80
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 i == 0
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=>options[:href] do
200
- input.button :type=>'submit', :name=>'submit', :value=>text, :style=>options[:style]
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
 
@@ -2,3 +2,4 @@ id_1:
2
2
  id: 1
3
3
  username: admin
4
4
  password: password
5
+ role: 10
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.10
7
- date: 2006-11-12 00:00:00 -08:00
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