This repository has been archived by the owner on Aug 15, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Josh Adams
committed
Oct 3, 2008
1 parent
7c92a43
commit 06b03be
Showing
25 changed files
with
325 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
AnsuzThemeRepository | ||
=================== | ||
|
||
This plugin provides the ability for an ansuz site to serve as a theme repository for other ansuz sites. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
|
||
desc 'Default: run unit tests.' | ||
task :default => :test | ||
|
||
desc 'Test the ansuz_content_section plugin.' | ||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = true | ||
end | ||
|
||
desc 'Generate documentation for the ansuz_content_section plugin.' | ||
Rake::RDocTask.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'AnsuzContentSection' | ||
rdoc.options << '--line-numbers' << '--inline-source' | ||
rdoc.rdoc_files.include('README') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end |
21 changes: 21 additions & 0 deletions
21
.../plugins/ansuz_theme_installer/app/controllers/admin/ansuz_theme_installers_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class Admin::AnsuzThemeInstallersController < Admin::BaseController | ||
unloadable # This is required if you subclass a controller provided by the base rails app | ||
|
||
layout 'admin' | ||
before_filter :load_themes, :only => [:index] | ||
|
||
protected | ||
def load_themes | ||
@themes = Ansuz::JAdams::AnsuzThemesListing.listing | ||
end | ||
|
||
public | ||
def index | ||
end | ||
|
||
def install | ||
Ansuz::JAdams::AnsuzThemesListing.install(params[:repository_url]) | ||
flash[:notice] = "Theme installed successfully." | ||
redirect_to admin_ansuz_theme_installers_path | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
vendor/plugins/ansuz_theme_installer/app/models/ansuz_theme.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Ansuz | ||
class JAdams | ||
class AnsuzTheme < ActiveRecord::Base | ||
validates_uniqueness_of :name | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
vendor/plugins/ansuz_theme_installer/app/models/menu_entry.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Ansuz | ||
class JAdams | ||
class MenuEntry < ActiveRecord::Base | ||
acts_as_tree :order => 'position' | ||
def self.root_entries | ||
Ansuz::JAdams::MenuEntry.find(:all, :conditions => "parent_id IS NULL", :order => 'position') | ||
end | ||
end | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
vendor/plugins/ansuz_theme_installer/app/views/admin/ansuz_theme_installers/index.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<%= title "Install Themes" -%> | ||
<table class='subdued'> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @themes.each do |theme| -%> | ||
<tr> | ||
<td><%= link_to(theme[0], install_admin_ansuz_theme_installers_path(:repository_url => theme[1])) -%></td> | ||
</tr> | ||
<% end -%> | ||
</tbody> | ||
</table> |
13 changes: 13 additions & 0 deletions
13
vendor/plugins/ansuz_theme_installer/db/migrate/001_create_ansuz_themes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreateAnsuzThemes < ActiveRecord::Migration | ||
def self.up | ||
create_table "ansuz_themes", :force => true do |t| | ||
t.string "name" | ||
t.string "repository_url" | ||
t.timestamps | ||
end | ||
end | ||
|
||
def self.end | ||
drop_table "ansuz_themes" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Include hook code here | ||
require 'ansuz/jadams/ansuz_themes_listing' | ||
Ansuz::PluginManagerInstance.register_admin_plugin_nav('Install Themes', '/admin/ansuz_theme_installers') |
34 changes: 34 additions & 0 deletions
34
vendor/plugins/ansuz_theme_installer/lib/ansuz/jadams/ansuz_themes_listing.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'open-uri' | ||
class Ansuz | ||
class JAdams | ||
class AnsuzThemesListing | ||
REPOSITORY = "http://localhost:3001/ansuz_themes.xml" | ||
|
||
# Returns an array of theme arrays. A theme array | ||
# looks like [name, repository_url] | ||
def self.listing | ||
ary = [] | ||
xml.elements.each("themes/theme") do |theme| | ||
name = theme.elements["name"].text | ||
repository_url = theme.elements["repository_url"].text | ||
ary << [name, repository_url] | ||
end | ||
ary | ||
end | ||
|
||
def self.xml_document | ||
uri = URI.parse REPOSITORY | ||
uri.read | ||
end | ||
|
||
def self.xml | ||
REXML::Document.new xml_document | ||
end | ||
|
||
# This method will install a theme, given a repository url | ||
def self.install repository_url | ||
`cd #{RAILS_ROOT}/themes; git clone #{repository_url}` | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace :admin do |admin| | ||
admin.resources :ansuz_theme_installers, :collection => [:install] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
AnsuzThemeRepository | ||
=================== | ||
|
||
This plugin provides the ability for an ansuz site to serve as a theme repository for other ansuz sites. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
|
||
desc 'Default: run unit tests.' | ||
task :default => :test | ||
|
||
desc 'Test the ansuz_content_section plugin.' | ||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = true | ||
end | ||
|
||
desc 'Generate documentation for the ansuz_content_section plugin.' | ||
Rake::RDocTask.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'AnsuzContentSection' | ||
rdoc.options << '--line-numbers' << '--inline-source' | ||
rdoc.rdoc_files.include('README') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end |
56 changes: 56 additions & 0 deletions
56
vendor/plugins/ansuz_theme_repository/app/controllers/admin/ansuz_themes_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
class Admin::AnsuzThemesController < Admin::BaseController | ||
unloadable # This is required if you subclass a controller provided by the base rails app | ||
|
||
layout 'admin' | ||
before_filter :load_ansuz_theme, :only => [:show, :edit, :update] | ||
before_filter :load_new_ansuz_theme, :only => [:new, :create] | ||
before_filter :load_ansuz_themes, :only => [:index] | ||
|
||
protected | ||
def load_ansuz_theme | ||
@ansuz_theme = Ansuz::JAdams::AnsuzTheme.find(params[:id]) | ||
end | ||
|
||
def load_new_ansuz_theme | ||
@ansuz_theme = Ansuz::JAdams::AnsuzTheme.new(params[:ansuz_theme]) | ||
end | ||
|
||
def load_ansuz_themes | ||
@ansuz_themes = Ansuz::JAdams::AnsuzTheme.find(:all, :order => 'name DESC') | ||
end | ||
public | ||
def new | ||
end | ||
|
||
def create | ||
if @ansuz_theme.save | ||
flash[:notice] = "Ansuz Theme was created successfully." | ||
redirect_to admin_ansuz_themes_path | ||
else | ||
flash.now[:error] = "There was a problem creating the ansuz theme." | ||
render :action => 'new' | ||
end | ||
end | ||
|
||
def show | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
if @ansuz_theme.update_attributes(params[:ansuz_theme]) | ||
flash[:notice] = "Ansuz Theme has been updated." | ||
redirect_to admin_ansuz_themes_path | ||
else | ||
flash.now[:error] = "There was a problem updating the Ansuz Theme. Please try again." | ||
render :action => 'edit' | ||
end | ||
end | ||
|
||
def destroy | ||
@ansuz_theme.destroy | ||
flash[:notice] = "Ansuz Theme was deleted." | ||
redirect_to admin_ansuz_themes_path | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
vendor/plugins/ansuz_theme_repository/app/controllers/ansuz_themes_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class AnsuzThemesController < ApplicationController | ||
unloadable # This is required if you subclass a controller provided by the base rails app | ||
|
||
before_filter :load_ansuz_themes, :only => [:index] | ||
|
||
protected | ||
def load_ansuz_themes | ||
@ansuz_themes = Ansuz::JAdams::AnsuzTheme.find(:all) | ||
end | ||
|
||
public | ||
|
||
def index | ||
respond_to do |format| | ||
format.xml{ render } | ||
end | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
vendor/plugins/ansuz_theme_repository/app/models/ansuz_theme.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Ansuz | ||
class JAdams | ||
class AnsuzTheme < ActiveRecord::Base | ||
validates_uniqueness_of :name | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
vendor/plugins/ansuz_theme_repository/app/models/menu_entry.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Ansuz | ||
class JAdams | ||
class MenuEntry < ActiveRecord::Base | ||
acts_as_tree :order => 'position' | ||
def self.root_entries | ||
Ansuz::JAdams::MenuEntry.find(:all, :conditions => "parent_id IS NULL", :order => 'position') | ||
end | ||
end | ||
end | ||
end |
2 changes: 2 additions & 0 deletions
2
vendor/plugins/ansuz_theme_repository/app/views/admin/ansuz_themes/_form.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Name: <%= f.text_field(:name) -%><br /> | ||
Repository URL: <%= f.text_field(:repository_url) -%><br /> |
8 changes: 8 additions & 0 deletions
8
vendor/plugins/ansuz_theme_repository/app/views/admin/ansuz_themes/edit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<%= title "Edit Ansuz Theme: #{@ansuz_theme}" -%> | ||
<% content_for :sidebar do -%> | ||
<%= link_to "All Ansuz Themes", admin_ansuz_themes_path -%> | ||
<% end -%> | ||
<% form_for :ansuz_theme, :url => admin_ansuz_theme_path(@ansuz_theme), :html => { :method => :put } do |f| -%> | ||
<%= render :partial => 'form', :locals => { :f => f } -%> | ||
<%= submit_tag("Update Ansuz Theme") -%> or <%= link_to "Cancel", admin_ansuz_themes_path -%> | ||
<% end -%> |
28 changes: 28 additions & 0 deletions
28
vendor/plugins/ansuz_theme_repository/app/views/admin/ansuz_themes/index.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<%= title "Ansuz Themes" -%> | ||
<% content_for :sidebar do -%> | ||
<%= link_to "New Ansuz Theme", new_admin_ansuz_theme_path -%><br /> | ||
<%= link_to "Themes Feed", ansuz_themes_path(:format => 'xml') -%> | ||
<% end -%> | ||
<table class='subdued'> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Repository URL</th> | ||
<th>Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @ansuz_themes.each do |ansuz_theme| -%> | ||
<tr class='<%= cycle('odd', 'even') -%>'> | ||
<td><%= link_to h(ansuz_theme.name), admin_ansuz_theme_path(ansuz_theme) -%></td> | ||
<td><%= ansuz_theme.repository_url -%></td> | ||
<td> | ||
<ul class='admin_actions'> | ||
<li><%= link_to "Edit", edit_admin_ansuz_theme_path(ansuz_theme) -%></li> | ||
<li><%= link_to "Delete", admin_ansuz_theme_path(ansuz_theme), :method => :delete, :confirm => "Are you sure you want to delete this ansuz theme?" -%></li> | ||
</ul> | ||
</td> | ||
</tr> | ||
<% end -%> | ||
</tbody> | ||
</table> |
8 changes: 8 additions & 0 deletions
8
vendor/plugins/ansuz_theme_repository/app/views/admin/ansuz_themes/new.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<%= title "New Ansuz Theme" -%> | ||
<% content_for :sidebar do -%> | ||
<%= link_to "All Ansuz Themes", admin_ansuz_themes_path -%> | ||
<% end -%> | ||
<% form_for :ansuz_theme, :url => admin_ansuz_themes_path do |f| -%> | ||
<%= render :partial => 'form', :locals => { :f => f } -%> | ||
<%= submit_tag("Create Ansuz Theme") -%> or <%= link_to "Cancel", admin_ansuz_themes_path -%> | ||
<% end -%> |
8 changes: 8 additions & 0 deletions
8
vendor/plugins/ansuz_theme_repository/app/views/ansuz_themes/index.xml.builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
xml.themes do | ||
@ansuz_themes.each do |theme| | ||
xml.theme do | ||
xml.name theme.name | ||
xml.repository_url theme.repository_url | ||
end | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
vendor/plugins/ansuz_theme_repository/db/migrate/001_create_ansuz_themes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreateAnsuzThemes < ActiveRecord::Migration | ||
def self.up | ||
create_table "ansuz_themes", :force => true do |t| | ||
t.string "name" | ||
t.string "repository_url" | ||
t.timestamps | ||
end | ||
end | ||
|
||
def self.end | ||
drop_table "ansuz_themes" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Include hook code here | ||
require 'ansuz_theme' | ||
Ansuz::PluginManagerInstance.register_admin_plugin_nav('Theme Repository', '/admin/ansuz_themes') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace :admin do |admin| | ||
admin.resources :ansuz_themes | ||
end | ||
resources :ansuz_themes |