public
Fork of halorgium/mephisto
Description: A refactored Mephisto that has multiple spam detection engines.
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/francois/mephisto.git
admin changes galore to users, templates.  deprecated pages and added 
design tab

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@760 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sat Feb 11 11:56:43 -0800 2006
commit  ef66d4712540d16007ed3e3db78d9cc50bc5293c
tree    5b0b3c9e90248b35e5f0a8dada8af61916293836
parent  4960a6d2672fe0fd46418f9b796e1d60913dc8d4
...
2
3
4
5
6
7
8
9
 
 
 
10
11
12
13
14
15
 
16
17
18
...
2
3
4
 
 
 
 
 
5
6
7
8
9
10
11
12
 
13
14
15
16
0
@@ -2,17 +2,15 @@ class ArticleSweeper < ActionController::Caching::Sweeper
0
   observe Article
0
 
0
   def after_create(record)
0
- controller.expire_page :categories => [], :controller => '/mephisto', :action => 'list'
0
- controller.expire_page :categories => [], :controller => '/feed', :action => 'feed'
0
- Category.find(:all, :conditions => ['name != ?', 'home']).each do |category|
0
- controller.expire_page :categories => category.name.split('/'), :controller => '/mephisto', :action => 'list'
0
- controller.expire_page :categories => category.name.split('/'), :controller => '/feed', :action => 'feed'
0
+ Category.find(:all).collect { |category| category.to_url }.each do |category|
0
+ controller.expire_page :categories => category, :controller => '/mephisto', :action => 'list'
0
+ controller.expire_page :categories => category, :controller => '/feed', :action => 'feed'
0
     end
0
   end
0
 
0
   def after_save(record)
0
     pages = CachedPage.find_by_reference(record)
0
- unless pages.empty?
0
+ if pages.any?
0
       controller.class.benchmark "Expired pages referenced by #{record.class} ##{record.id}" do
0
         pages.each { |p| controller.class.expire_page(p.url) }
0
         CachedPage.expire_pages(pages)
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ class CategorizationSweeper < ActionController::Caching::Sweeper
0
 
0
   def after_destroy(record)
0
     pages = CachedPage.find_by_reference_key('Category', record.category_id)
0
- unless pages.empty?
0
+ if pages.any?
0
       controller.class.benchmark "Expired pages referenced by Category ##{record.category_id}" do
0
         pages.each { |p| controller.class.expire_page(p.url) }
0
         CachedPage.expire_pages(pages)
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ class CommentSweeper < ActionController::Caching::Sweeper
0
 
0
   def after_save(record)
0
     pages = CachedPage.find_by_reference(record.article)
0
- unless pages.empty?
0
+ if pages.any?
0
       controller.class.benchmark "Expired pages referenced by #{record.class} ##{record.id}" do
0
         pages.each { |p| controller.class.expire_page(p.url) }
0
         CachedPage.expire_pages(pages)
...
8
9
10
 
 
 
 
11
12
13
14
15
16
17
18
19
20
21
 
 
 
 
 
 
 
 
 
 
22
23
24
25
 
 
 
26
27
 
 
 
28
29
...
8
9
10
11
12
13
14
15
16
 
 
 
 
 
 
 
 
 
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
35
36
37
38
39
0
@@ -8,22 +8,32 @@ class Admin::TemplatesController < Admin::BaseController
0
          :redirect_to => { :action => 'edit' }
0
   before_filter :select_template, :except => :index
0
 
0
+ def index
0
+ redirect_to :controller => 'design'
0
+ end
0
+
0
   def update
0
     saved = @tmpl.update_attributes(params[:template])
0
- if request.xhr?
0
- render :partial => 'form', :locals => { :template => @tmpl }
0
- return
0
- end
0
- if saved
0
- flash[:notice] = "#{@tmpl.name} updated."
0
- redirect_to :action => 'edit', :id => @tmpl
0
- else
0
- render :action => 'edit'
0
+ case
0
+ when request.xhr?
0
+ render :partial => 'form', :locals => { :template => @tmpl }
0
+
0
+ when saved
0
+ flash[:notice] = "#{@tmpl.name} updated."
0
+ redirect_to :action => 'edit', :id => @tmpl
0
+
0
+ else
0
+ render :action => 'edit'
0
     end
0
   end
0
 
0
   protected
0
+ # @template var clashes with ActionView instance, so use @tmpl
0
+ # Selects all templates for sidebar
0
+ # Create system template if it does not exist
0
   def select_template
0
- @tmpl = Template.template_types.include?(params[:id].to_sym) ? Template.find_or_create_by_name(params[:id]) : nil
0
+ @templates = Template.find :all
0
+ @tmpl = @templates.detect { |t| t.name == params[:id] }
0
+ @tmpl ||= Template.find_or_create_by_name(params[:id]) if Template.template_types.include?(params[:id].to_sym)
0
   end
0
 end
...
1
2
3
 
 
 
 
 
4
5
...
1
 
2
3
4
5
6
7
8
9
0
@@ -1,5 +1,9 @@
0
 class Admin::UsersController < Admin::BaseController
0
-
0
   def index
0
+ @users = User.find :all, :order => 'login'
0
+ end
0
+
0
+ def show
0
+ @user = User.find_by_login params[:id]
0
   end
0
 end
...
33
34
35
 
 
 
 
36
37
38
39
40
 
 
 
 
 
 
 
 
41
42
43
...
54
55
56
57
58
59
60
61
62
63
64
65
...
69
70
71
72
73
74
75
76
77
78
...
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
...
66
67
68
 
 
 
 
69
 
70
71
72
...
76
77
78
 
 
 
 
 
 
79
0
@@ -33,11 +33,23 @@ class User < ActiveRecord::Base
0
     Digest::SHA1.hexdigest("--#{salt}--#{password}--")
0
   end
0
 
0
+ def make_activation_code
0
+ self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split('//').sort_by {rand}.join )
0
+ end
0
+
0
   # Encrypts the password with the user salt
0
   def encrypt(password)
0
     self.class.encrypt(password, salt)
0
   end
0
 
0
+ def filters=(value)
0
+ write_attribute :filters, [value].flatten.collect(&:to_sym)
0
+ end
0
+
0
+ def to_param
0
+ login
0
+ end
0
+
0
   # Uncomment these methods for user activation These also help let the mailer know precisely when the user is activated.
0
   # There's also a commented-out before hook above and a protected method below.
0
   #
0
@@ -54,12 +66,7 @@ class User < ActiveRecord::Base
0
   # @activated
0
   # end
0
 
0
- def filters=(value)
0
- write_attribute :filters, [value].flatten.collect(&:to_sym)
0
- end
0
-
0
   protected
0
- # before filter
0
   def encrypt_password
0
     return unless password
0
     self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record?
0
@@ -69,10 +76,4 @@ class User < ActiveRecord::Base
0
   def password_required?
0
     crypted_password.nil? or not password.blank?
0
   end
0
-
0
- public
0
- # If you're going to use activation, uncomment this too
0
- def make_activation_code
0
- self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split('//').sort_by {rand}.join )
0
- end
0
 end
...
1
2
3
 
 
 
4
...
1
 
2
3
4
5
6
0
@@ -1,2 +1,4 @@
0
 <p>Please choose a paged category to edit</p>
0
-<%= render :partial => 'pages' %>
0
\ No newline at end of file
0
+<%= render :partial => 'pages' %>
0
+
0
+<p>i hereby declare this section deprecated. will be refactored into an enhanced category section. bye bye.</p>
0
\ No newline at end of file
...
1
2
3
4
5
6
 
 
 
7
...
 
 
1
2
 
3
4
5
6
7
0
@@ -1,5 +1,5 @@
0
-<%= render :partial => 'templates' %>
0
-
0
 <div id='template_container'>
0
 <%= render :partial => 'form', :locals => { :template => @tmpl } %>
0
-</div>
0
\ No newline at end of file
0
+</div>
0
+
0
+<%= render :partial => 'admin/design/sidebar' %>
0
\ No newline at end of file
...
1
2
 
3
4
5
6
7
8
9
 
10
 
11
12
...
1
2
3
4
 
 
 
 
 
 
5
6
7
8
9
0
@@ -1,11 +1,8 @@
0
 <h2>People on the inside</h2>
0
 <ul id="users">
0
+<% @users.each do |user| -%>
0
   <li>
0
- <h3>Justin Palmer</h3>
0
- <p>Justin rocks</p>
0
- </li>
0
- <li>
0
- <h3>Rick Olson</h3>
0
- <p>Rick only thinks he rocks.</p>
0
+ <h3><%= link_to user.login, :action => 'show', :id => user %></h3>
0
   </li>
0
+<% end -%>
0
 </ul>
0
\ No newline at end of file
...
14
15
16
17
 
18
19
20
...
29
30
31
32
 
33
34
35
...
14
15
16
 
17
18
19
20
...
29
30
31
 
32
33
34
35
0
@@ -14,7 +14,7 @@
0
     <div id="header">
0
      <ul id="sec-nav">
0
      <li><%= link_to 'settings', :controller => 'settings' %></li>
0
- <li><%= link_to 'account', :controller => 'account' %></li>
0
+ <li><%= link_to 'account', :controller => 'users', :action => 'show', :id => current_user %></li>
0
      </ul>
0
 
0
      <h1><a href="/" title="ArticleCast">Mephisto: Admin</a></h1>
0
@@ -29,7 +29,7 @@
0
           <ul id="nav-r">
0
             <li><%= link_to 'categories', :controller => '/admin/categories' %></li>
0
             <li><%= link_to 'pages', :controller => '/admin/pages' %></li>
0
- <li><%= link_to 'templates', :controller => '/admin/templates' %></li>
0
+ <li><%= link_to 'design', :controller => '/admin/design' %></li>
0
             <li><%= link_to "users", :controller => "users" %></li>
0
           </ul>
0
         <% end -%>

Comments

    No one has commented yet.