cartoonist 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,17 @@
1
1
  form.inline { display: inline-block; }
2
2
 
3
+ table {
4
+ tbody {
5
+ tr:nth-of-type(odd) {
6
+ background-color: #ddd;
7
+ }
8
+
9
+ tr:nth-of-type(even) {
10
+ background-color: #fff;
11
+ }
12
+ }
13
+ }
14
+
3
15
  table.cache {
4
16
  tbody {
5
17
  tr:nth-of-type(odd) {
@@ -0,0 +1,32 @@
1
+ class AccountsController < CartoonistController
2
+ before_filter :ensure_ssl!
3
+ before_filter :check_admin!
4
+
5
+ def index
6
+ @users = User.order(:name).all
7
+ end
8
+
9
+ def create
10
+ user = User.create_user params
11
+ redirect_to "/accounts"
12
+ end
13
+
14
+ def show
15
+ @user = User.find params[:id].to_i
16
+ end
17
+
18
+ def edit
19
+ @user = User.find params[:id].to_i
20
+ end
21
+
22
+ def update
23
+ user = User.update_user params
24
+ redirect_to "/accounts/#{user.id}"
25
+ end
26
+
27
+ def destroy
28
+ raise "Cannot destroy yourself!" if current_user.id == params[:id].to_i
29
+ User.delete_user params
30
+ redirect_to "/accounts"
31
+ end
32
+ end
@@ -26,12 +26,19 @@ class SettingsController < CartoonistController
26
26
 
27
27
  def save_initial_setup
28
28
  return redirect_to "/admin" unless initial_setup_required?
29
+
30
+ if params[:admin_password] != params[:admin_confirm_password]
31
+ flash[:error] = t "settings.initial_setup.passwords_dont_match"
32
+ return redirect_to "/settings/initial_setup"
33
+ end
34
+
35
+ Setting[:copyright_starting_year] = Date.today.strftime("%Y").to_i
29
36
  Setting[:domain] = params[:domain]
30
37
  Setting[:site_name] = params[:site_name]
31
38
  Setting[:secret_token] = SecureRandom.hex 30
32
39
  Setting[:devise_pepper] = SecureRandom.hex 64
33
40
  # This MUST go AFTER we set the pepper
34
- User.create! :email => params[:admin_email], :password => params[:admin_password], :name => params[:admin_name]
41
+ User.create! :email => params[:admin_email], :password => params[:admin_password], :password_confirmation => params[:admin_confirm_password], :name => params[:admin_name]
35
42
  redirect_to "/admin"
36
43
  end
37
44
  end
data/app/models/user.rb CHANGED
@@ -3,4 +3,28 @@ class User < ActiveRecord::Base
3
3
 
4
4
  # Setup accessible (or protected) attributes for your model
5
5
  attr_accessible :email, :password, :password_confirmation, :remember_me, :name
6
+
7
+ class << self
8
+ def create_user(params)
9
+ create :email => params[:email], :name => params[:name], :password => params[:password], :password_confirmation => params[:confirm_password]
10
+ end
11
+
12
+ def delete_user(params)
13
+ User.find(params[:id].to_i).destroy
14
+ end
15
+
16
+ def update_user(params)
17
+ user = find params[:id].to_i
18
+ user.email = params[:email]
19
+ user.name = params[:name]
20
+
21
+ if params[:password].present? || params[:confirm_password].present?
22
+ user.password = params[:password]
23
+ user.password_confirmation = params[:confirm_password]
24
+ end
25
+
26
+ user.save!
27
+ user
28
+ end
29
+ end
6
30
  end
@@ -0,0 +1,21 @@
1
+ <h2><%= t "accounts.edit.subtitle" %></h2>
2
+
3
+ <%= form_tag "/accounts/#{@user.id}", :method => :put do %>
4
+ <p>
5
+ <%= t "accounts.edit.email" %> <input type="text" name="email" value="<%= @user.email %>" />
6
+ </p>
7
+
8
+ <p>
9
+ <%= t "accounts.edit.name" %> <input type="text" name="name" value="<%= @user.name %>" />
10
+ </p>
11
+
12
+ <p>
13
+ <%= t "accounts.edit.password" %> <input type="password" name="password" value="" />
14
+ </p>
15
+
16
+ <p>
17
+ <%= t "accounts.edit.confirm" %> <input type="password" name="confirm_password" value="" />
18
+ </p>
19
+
20
+ <input type="submit" value="<%= t "accounts.edit.save" %>" />
21
+ <% end %>
@@ -0,0 +1,29 @@
1
+ <a href="/accounts/new"><%= t "accounts.index.new_user" %></a>
2
+
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th><%= t "accounts.index.name" %></th>
7
+ <th><%= t "accounts.index.email" %></th>
8
+ <th><%= t "accounts.index.edit" %></th>
9
+ <th><%= t "accounts.index.delete" %></th>
10
+ </tr>
11
+ </thead>
12
+
13
+ <tbody>
14
+ <% @users.each do |user| %>
15
+ <tr>
16
+ <td><%= user.name %></td>
17
+ <td><%= user.email %></td>
18
+ <td><a href="/accounts/<%= user.id %>/edit"><%= t "accounts.index.edit_button" %></a></td>
19
+ <td>
20
+ <% if current_user.id != user.id %>
21
+ <%= form_tag "/accounts/#{user.id}", :method => :delete do %>
22
+ <input type="submit" value="<%= t "accounts.index.delete_button" %>" />
23
+ <% end %>
24
+ <% end %>
25
+ </td>
26
+ </tr>
27
+ <% end %>
28
+ </tbody>
29
+ </table>
@@ -0,0 +1,21 @@
1
+ <h2><%= t "accounts.new.subtitle" %></h2>
2
+
3
+ <%= form_tag "/accounts", :method => :post do %>
4
+ <p>
5
+ <%= t "accounts.new.email" %> <input type="text" name="email" value="" />
6
+ </p>
7
+
8
+ <p>
9
+ <%= t "accounts.new.name" %> <input type="text" name="name" value="" />
10
+ </p>
11
+
12
+ <p>
13
+ <%= t "accounts.new.password" %> <input type="password" name="password" value="" />
14
+ </p>
15
+
16
+ <p>
17
+ <%= t "accounts.new.confirm" %> <input type="password" name="confirm_password" value="" />
18
+ </p>
19
+
20
+ <input type="submit" value="<%= t "accounts.new.save" %>" />
21
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <p>
2
+ <a href="/accounts/<%= @user.id %>/edit"><%= t "accounts.show.edit" %></a>
3
+ </p>
4
+
5
+ <p>
6
+ <%= t "accounts.show.email" %> <%= @user.email %>
7
+ </p>
8
+
9
+ <p>
10
+ <%= t "accounts.show.name" %> <%= @user.name %>
11
+ </p>
@@ -0,0 +1,8 @@
1
+ <% content_for :subtabs do %>
2
+ <a class="subtab" href="/accounts/<%= current_user.id %>"><%= t "admin.accounts.layout.my_account" %></a>
3
+ <a class="subtab" href="/accounts"><%= t "admin.accounts.layout.users" %></a>
4
+ <% end %>
5
+
6
+ <% content_for :page_title, t("admin.accounts.layout.section") %>
7
+ <% content_for(:content) { yield } %>
8
+ <%= render :template => "layouts/admin" %>
@@ -14,6 +14,7 @@
14
14
  <a class="tab" href="<%= Cartoonist::Admin::Tab[tab] %>"><%= t tab, :scope => "admin.layout.tab" %></a>
15
15
  <% end %>
16
16
  | <%= t "admin.layout.user_heading", :user => current_user.name %>
17
+ <a href="/accounts/<%= current_user.id %>"><%= t "admin.layout.account" %></a>
17
18
  <input type="submit" value="<%= t "admin.layout.logout" %>" />
18
19
  </p>
19
20
  <% end %>
@@ -1,3 +1,9 @@
1
+ <% if flash[:error] %>
2
+ <div class="error">
3
+ <%= flash[:error] %>
4
+ </div>
5
+ <% end %>
6
+
1
7
  <%= form_tag "/settings/save_initial_setup", :method => :post do %>
2
8
  <p>
3
9
  <%= t "settings.initial_setup.email" %><input type="text" name="admin_email" value="<%= t "settings.initial_setup.default_email" %>" autofocus="autofocus" />
@@ -11,6 +17,10 @@
11
17
  <%= t "settings.initial_setup.password" %><input type="password" name="admin_password" />
12
18
  </p>
13
19
 
20
+ <p>
21
+ <%= t "settings.initial_setup.confirm_password" %><input type="password" name="admin_confirm_password" />
22
+ </p>
23
+
14
24
  <p>
15
25
  <%= t "settings.initial_setup.domain" %><input type="text" name="domain" />
16
26
  </p>
@@ -1,5 +1,37 @@
1
1
  en:
2
+ accounts:
3
+ edit:
4
+ confirm: "Confirm:"
5
+ email: "Email:"
6
+ name: "Name:"
7
+ password: "Password:"
8
+ save: Save
9
+ subtitle: Edit Account
10
+ index:
11
+ delete: Delete
12
+ delete_button: delete
13
+ edit: Edit
14
+ edit_button: edit
15
+ email: Email
16
+ name: Name
17
+ new_user: New User
18
+ new:
19
+ confirm: "Confirm:"
20
+ email: "Email:"
21
+ name: "Name:"
22
+ password: "Password:"
23
+ save: Save
24
+ subtitle: New Account
25
+ show:
26
+ edit: edit
27
+ email: "Email:"
28
+ name: "Name:"
2
29
  admin:
30
+ accounts:
31
+ layout:
32
+ my_account: My Account
33
+ section: Account
34
+ users: Users
3
35
  general:
4
36
  actions:
5
37
  backup: Download Backup
@@ -11,6 +43,7 @@ en:
11
43
  settings: Settings
12
44
  static_cache: Static Cache
13
45
  layout:
46
+ account: Account
14
47
  tab:
15
48
  general: General
16
49
  logout: Logout
@@ -43,12 +76,14 @@ en:
43
76
  www_tmp: www tmp
44
77
  settings:
45
78
  initial_setup:
79
+ confirm_password: "Confirmation: "
46
80
  default_email: you@youremail.com
47
81
  default_name: Anonymous
48
82
  domain: "Domain: "
49
83
  email: "Email: "
50
84
  name: "Name: "
51
85
  password: "Password: "
86
+ passwords_dont_match: Your passwords must match.
52
87
  save: Save
53
88
  site_name: "Site Name: "
54
89
  username: "Username: "
@@ -3,6 +3,8 @@ module Cartoonist
3
3
  # Use this hook to configure devise mailer, warden hooks and so forth.
4
4
  # Many of these configuration options can be set straight in your model.
5
5
  Devise.setup do |devise_config|
6
+ devise_config.parent_controller = "CartoonistController"
7
+
6
8
  # ==> Mailer Configuration
7
9
  # Configure the e-mail address which will be shown in Devise::Mailer,
8
10
  # note that it will be overwritten if you use your own mailer class with default "from" parameter.
@@ -358,6 +360,8 @@ module Cartoonist
358
360
  end
359
361
  end
360
362
 
363
+ resources :accounts
364
+
361
365
  resources :admin do
362
366
  collection do
363
367
  get "cache_cron"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cartoonist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-19 00:00:00.000000000 Z
12
+ date: 2012-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise
16
- requirement: &13208780 !ruby/object:Gem::Requirement
16
+ requirement: &6819100 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *13208780
24
+ version_requirements: *6819100
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jquery-rails
27
- requirement: &13206920 !ruby/object:Gem::Requirement
27
+ requirement: &6817240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *13206920
35
+ version_requirements: *6817240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: railties
38
- requirement: &13205660 !ruby/object:Gem::Requirement
38
+ requirement: &6816220 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 3.2.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *13205660
46
+ version_requirements: *6816220
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: redcarpet
49
- requirement: &13205080 !ruby/object:Gem::Requirement
49
+ requirement: &6815620 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.1.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *13205080
57
+ version_requirements: *6815620
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: twitter
60
- requirement: &13204340 !ruby/object:Gem::Requirement
60
+ requirement: &6814720 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 2.2.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *13204340
68
+ version_requirements: *6814720
69
69
  description: This provides the main functionality and plugin api for Cartoonist.
70
70
  email: reasonnumber@gmail.com
71
71
  executables: []
@@ -75,6 +75,7 @@ files:
75
75
  - .gitignore
76
76
  - app/assets/javascripts/cartoonist.js.erb
77
77
  - app/assets/stylesheets/admin.css.scss
78
+ - app/controllers/accounts_controller.rb
78
79
  - app/controllers/admin_controller.rb
79
80
  - app/controllers/cache_controller.rb
80
81
  - app/controllers/cartoonist_controller.rb
@@ -93,8 +94,13 @@ files:
93
94
  - app/models/static_cache.rb
94
95
  - app/models/tweetable.rb
95
96
  - app/models/user.rb
97
+ - app/views/accounts/edit.html.erb
98
+ - app/views/accounts/index.html.erb
99
+ - app/views/accounts/new.html.erb
100
+ - app/views/accounts/show.html.erb
96
101
  - app/views/admin/main.html.erb
97
102
  - app/views/cache/index.html.erb
103
+ - app/views/layouts/accounts.html.erb
98
104
  - app/views/layouts/admin.html.erb
99
105
  - app/views/layouts/cartoonist.html.erb
100
106
  - app/views/layouts/cartoonist.rss.erb