public
Description: This contains various plugins for Feather
Clone URL: git://github.com/eldiablo/feather-plugins.git
Search Repo:
Click here to lend your support to: feather-plugins and make a donation at www.pledgie.com !
added a style plugin, allowing custom css snippets to be specified, so as 
to override the default styles; also updated the admin index views for the 
redirects and snippets plugins
eldiablo (author)
Sat Apr 12 14:35:05 -0700 2008
commit  c9095fcb94080ba023a268f6ab07e5ae850b042f
tree    5892d18e818515db91855c0b1731a0c7343b2db2
parent  24d287024b1771ce6417107c46249a12362ca5aa
0
...
8
9
10
 
11
...
8
9
10
11
12
0
@@ -8,5 +8,6 @@
0
 feather-redirects: this allows custom redirects to be setup to maintain links and compatibility with previous blog services
0
 feather-sidebar: this allows the creation of generic sidebar items for your Feather blog
0
 feather-snippets: this allows custom and dynamic creation of snippets to add to the blog template
0
+feather-styles: this allows custom stylesheets to be defined and automatically included so as to override default blog styling
0
 feather-tagging: this provides tagging for articles, and a tag cloud for the blog sidebar
...
2
3
4
 
 
 
 
 
 
 
 
 
 
5
6
7
...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
0
@@ -2,6 +2,16 @@
0
   property :from_url, :string, :nullable => false, :length => 255
0
   property :to_url, :string, :nullable => false, :length => 255
0
   property :permanent, :boolean
0
+
0
+ def validate(arg)
0
+ super
0
+ if self.from_url == self.to_url
0
+ self.errors.add "Cannot redirect", "from and to the same url"
0
+ false
0
+ else
0
+ true
0
+ end
0
+ end
0
 
0
   def self.find_by_from_url(from_url)
0
     self.first(:from_url => from_url)
...
10
11
12
13
 
14
15
16
...
10
11
12
 
13
14
15
16
0
@@ -10,7 +10,7 @@
0
 <table>
0
   <% @redirects.each do |redirect| %>
0
   <tr>
0
- <td>From <%= redirect.from_url %> to <%= redirect.to_url %></td>
0
+ <td>From <%= link_to "#{redirect.from_url} to #{redirect.to_url}", url(:admin_redirect, redirect) %></td>
0
     <td>(<%= redirect.permanent ? "Permanent" : "Temporary" %>)</td>
0
     <td <%= link_to "Edit", url(:edit_admin_redirect, redirect) %> | <%= link_to 'Delete', url(:delete_admin_redirect, redirect), {:method => :delete, :onclick => "return confirm('Are you sure?')"} %></td>
0
   </tr>
...
1
2
 
3
4
...
1
 
2
3
4
0
@@ -1,5 +1,5 @@
0
 <tr>
0
- <td><%= snippet.location %></td>
0
+ <td><%= link_to snippet.location, url(:admin_snippet, snippet) %></td>
0
   <td <%= link_to "Edit", url(:edit_admin_snippet, snippet) %> | <%= link_to 'Delete', url(:delete_admin_snippet, snippet), {:method => :delete, :onclick => "return confirm('Are you sure?')"} %></td>
0
 </tr>
...
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
0
@@ -1 +1,13 @@
0
+class Css < Application
0
+ def custom
0
+ css = ""
0
+ Style.all.each do |style|
0
+ css << style.content + "\n\n"
0
+ end
0
+ self.status = 200
0
+ self.headers["Content-Type"] = "text/css"
0
+ self.body = css
0
+ css
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
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
40
41
42
43
44
45
46
47
48
49
50
51
52
0
@@ -1 +1,53 @@
0
+module Admin
0
+ class Styles < Base
0
+ include_plugin_views __FILE__
0
+
0
+ before :find_style, :only => %w(edit update delete show)
0
+
0
+ def index
0
+ @styles = Style.all
0
+ display @styles
0
+ end
0
+
0
+ def new
0
+ @style = Style.new
0
+ display @style
0
+ end
0
+
0
+ def create(style)
0
+ @style = Style.new(style)
0
+ if @style.save
0
+ redirect url(:admin_style)
0
+ else
0
+ render :new
0
+ end
0
+ end
0
+
0
+ def edit
0
+ display @style
0
+ end
0
+
0
+ def update(style)
0
+ if @style.update_attributes(style)
0
+ redirect url(:admin_style, @style)
0
+ else
0
+ render :edit
0
+ end
0
+ end
0
+
0
+ def delete
0
+ @style.destroy!
0
+ redirect url(:admin_styles)
0
+ end
0
+
0
+ def show
0
+ display @style
0
+ end
0
+
0
+ private
0
+ def find_style
0
+ @style = Style[params[:id]]
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
0
@@ -1 +1,19 @@
0
+require File.join(File.join(File.dirname(__FILE__), "controllers"), "css")
0
+require File.join(File.join(File.dirname(__FILE__), "controllers"), "styles")
0
+require File.join(File.join(File.dirname(__FILE__), "models"), "style")
0
+
0
+Merb::Router.prepend do |r|
0
+ r.namespace :admin do |admin|
0
+ admin.resources :styles
0
+ end
0
+ r.match("/stylesheets/custom.css").to(:controller => "css", :action => "custom")
0
+end
0
+
0
+Hooks::Menu.add_menu_item do
0
+ {:text => "Styles", :url => "/admin/styles" }
0
+end
0
+
0
+Hooks::View.register_view do
0
+ {:name => "head", :content => "<link type=\"text/css\" media=\"all\" href=\"/stylesheets/custom.css\" rel=\"Stylesheet\" charset=\"utf-8\" />"}
0
+end
...
 
...
1
0
@@ -1 +1,2 @@
0
+Database::migrate(Style)
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
0
@@ -1 +1,30 @@
0
+plugin:
0
+ name: feather-styles
0
+ author: El Draper
0
+ version: 1.0
0
+ homepage: http://featherblog.com
0
+ about: This plugin adds the ability for the user to create and manage custom stylesheets
0
+ contents:
0
+ .:
0
+ - init.rb
0
+ - install.rb
0
+ controllers:
0
+ .:
0
+ - css.rb
0
+ - styles.rb
0
+ models:
0
+ .:
0
+ - style.rb
0
+ views:
0
+ .:
0
+ admin:
0
+ .:
0
+ styles:
0
+ .:
0
+ - _form.html.erb
0
+ - _style.html.erb
0
+ - edit.html.erb
0
+ - index.html.erb
0
+ - new.html.erb
0
+ - show.html.erb
...
 
 
 
 
...
1
2
3
4
0
@@ -1 +1,5 @@
0
+class Style < DataMapper::Base
0
+ property :name, :string, :nullable => false, :length => 255
0
+ property :content, :text, :nullable => false
0
+end
...
 
 
...
1
2
0
@@ -1 +1,3 @@
0
+<%= text_control :name, :label => 'Name:' %>
0
+<%= text_area_control :content, :rows => 20, :cols => 100, :label => 'Content:' %>
...
 
 
 
 
...
1
2
3
4
0
@@ -1 +1,5 @@
0
+<tr>
0
+ <td><%= link_to style.name, url(:admin_style, style) %></td>
0
+ <td <%= link_to "Edit", url(:edit_admin_style, style) %> | <%= link_to 'Delete', url(:delete_admin_style, style), {:method => :delete, :onclick => "return confirm('Are you sure?')"} %></td>
0
+</tr>
...
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
0
@@ -1 +1,12 @@
0
+<% throw_content :right do %>
0
+ Edit the style.
0
+<% end %>
0
+
0
+<%= error_messages_for @style %>
0
+<h1>Edit style</h1>
0
+
0
+<% form_for :style, :action => url(:admin_style, @style), :method => :put do %>
0
+ <%= partial 'form' %>
0
+ <p><%= submit_button 'Save Style' %> or <%= link_to 'Cancel', url(:admin_styles) %></p>
0
+<% end %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
0
@@ -1 +1,15 @@
0
+<% throw_content :right do %>
0
+ <h4>View Styles</h4>
0
+ <p>
0
+ Styles allow you to create custom stylesheet rules.
0
+ </p>
0
+<% end %>
0
+
0
+<h1>View Styles</h1>
0
+
0
+<table>
0
+ <%= partial('admin/styles/style', :with => @styles) %>
0
+</table>
0
+<br />
0
+<%= link_to "New Style", url(:new_admin_style) %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
@@ -1 +1,16 @@
0
+<% throw_content :right do %>
0
+ <p>
0
+ Setup a new style here.
0
+ </p>
0
+<% end %>
0
+
0
+<%= error_messages_for @style %>
0
+<h1>New Style</h1>
0
+
0
+<% form_for :style, :action => url(:admin_style, @style) do %>
0
+ <%= partial 'form' %>
0
+ <p><%= submit_button 'Save Style' %> or <%= link_to 'Cancel', url(:admin_styles) %></p>
0
+<% end %>
0
+
0
+<%= link_to "Back to styles", url(:admin_styles) %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
0
@@ -1 +1,22 @@
0
+<% throw_content :right do %>
0
+ <h4>View Style</h4>
0
+ <p>
0
+ Here you can view the details of an existing style.
0
+ </p>
0
+<% end %>
0
+
0
+<h1>View Style</h1>
0
+
0
+<p>
0
+ Name: <%= @style.name %>
0
+</p>
0
+
0
+<p>
0
+ Content:
0
+ <br />
0
+ <%= @style.content %>
0
+</p>
0
+
0
+<%= link_to "Edit style", url(:edit_admin_style, @style) %> |
0
+<%= link_to "Back to styles", url(:admin_styles) %>

Comments

    No one has commented yet.