This repository has been archived by the owner on Aug 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
got plugin installation, enabling working
- Loading branch information
Josh Adams
committed
Feb 15, 2009
1 parent
583cb1b
commit 6404beb
Showing
14 changed files
with
240 additions
and
0 deletions.
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 @@ | ||
This directory is used as a holding directory for ansuz plugins. When you install a plugin, it is placed here. When you enable a plugin, it is copied from here to vendor/plugins |
Submodule ansuz_blog
added at
abbc72
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
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 @@ | ||
module PluginsManagementHelper | ||
def list_plugins | ||
plugins_dir.entries.sort.delete_if{|e| e =~ /^\.$|^\.\.$/ } | ||
end | ||
|
||
def plugins_dir | ||
Dir.new(plugins_root) | ||
end | ||
|
||
def plugins_root | ||
"#{RAILS_ROOT}/ansuz_installed_plugins" | ||
end | ||
end |
Submodule ansuz_blog
added at
abbc72
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 @@ | ||
AnsuzPluginInstaller | ||
=================== | ||
|
||
This plugin provides the ability to install themes from remote repositories. |
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
...lugins/ansuz_plugin_installer/app/controllers/admin/ansuz_plugin_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,56 @@ | ||
class Admin::AnsuzPluginInstallersController < Admin::BaseController | ||
unloadable # This is required if you subclass a controller provided by the base rails app | ||
include PluginsManagementHelper | ||
helper :plugins_management | ||
|
||
layout 'admin' | ||
|
||
before_filter :load_plugins_listing_var | ||
before_filter :load_plugins, :only => [:index] | ||
|
||
protected | ||
def load_plugins_listing_var | ||
@plugins_util = Ansuz::JAdams::AnsuzPluginsListing | ||
end | ||
|
||
def load_plugins | ||
@plugins = @plugins_util.listing | ||
end | ||
|
||
public | ||
def index | ||
end | ||
|
||
# TODO: These should be REST actions probably | ||
def install | ||
@plugins_util.install(params[:repository_url], params[:name]) | ||
flash[:notice] = "Plugin installed successfully." | ||
redirect_to admin_ansuz_plugin_installers_path | ||
end | ||
|
||
# expects a params[:name] | ||
def enable | ||
@plugins_util.enable(params[:name]) | ||
flash[:notice] = "Plugin has been enabled." | ||
redirect_to admin_ansuz_plugin_installers_path | ||
end | ||
|
||
# expects a params[:name] | ||
def disable | ||
@plugins_util.disable(params[:name]) | ||
flash[:notice] = "Plugin has been disabled." | ||
redirect_to admin_ansuz_plugin_installers_path | ||
end | ||
|
||
def update | ||
@plugins_util.update(params[:id]) | ||
flash[:notice] = "Plugin updated successfully." | ||
redirect_to admin_ansuz_plugin_installers_path | ||
end | ||
|
||
def destroy | ||
@plugins_util.delete(params[:id]) | ||
flash[:notice] = "Plugin deleted successfully." | ||
redirect_to admin_ansuz_plugin_installers_path | ||
end | ||
end |
38 changes: 38 additions & 0 deletions
38
vendor/plugins/ansuz_plugin_installer/app/views/admin/ansuz_plugin_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,38 @@ | ||
<%= title "Install Plugins" -%> | ||
<% content_for :sidebar do -%> | ||
<div class='note'> | ||
To install a plugin, just click on its "Install" link.<br /><br /> | ||
|
||
At the moment, the only repository available to you is the master plugin repository at www.ansuzcms.com. This is hard coded in, and there's currently no interface for adding new plugin repositories (but one's coming!). If you're adventurous and desperate, ansuz's main repository is the same code you've got, so you could easily change the hardcoded value to your own instance of ansuz and be off and running.<br /><br /> | ||
</div> | ||
<% end -%> | ||
<div class='fullwidth'> | ||
<table class='subdued'> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @plugins.each do |plugin| -%> | ||
<tr class="<%= cycle('odd', 'even') %>"> | ||
<td><%= plugin[0] %></td> | ||
<td> | ||
<% if @plugins_util.installed?(plugin[0]) %> | ||
<% if @plugins_util.enabled?(plugin[0]) %> | ||
<%= link_to("Disable", disable_admin_ansuz_plugin_installers_path(:name => plugin[0])) -%> | | ||
<% else %> | ||
<%= link_to("Enable", enable_admin_ansuz_plugin_installers_path(:name => plugin[0])) -%> | | ||
<% end %> | ||
<%= link_to("Update", admin_ansuz_plugin_installer_path(plugin[0]), :method => :put) -%> | | ||
<%= link_to("Uninstall", admin_ansuz_plugin_installer_path(plugin[0]), :method => :delete, :confirm => "Are you sure?") -%> | ||
<% else %> | ||
<%= link_to("Install", install_admin_ansuz_plugin_installers_path(:repository_url => plugin[1], :name => plugin[0])) -%> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end -%> | ||
</tbody> | ||
</table> | ||
</div> |
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 @@ | ||
Ansuz::PluginManagerInstance.register_admin_menu_entry('Manage', 'Plugins', '/admin/ansuz_plugin_installers', { :span_options => { :note => "Install plugins from remote repositories."} }) |
82 changes: 82 additions & 0 deletions
82
vendor/plugins/ansuz_plugin_installer/lib/ansuz/j_adams/ansuz_plugins_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,82 @@ | ||
require 'open-uri' | ||
module Ansuz | ||
module JAdams | ||
class AnsuzPluginsListing | ||
#REPOSITORY = "http://ansuzcms.com/ansuz_plugins.xml" | ||
REPOSITORY = "http://localhost:3000/ansuz_plugins.xml" | ||
|
||
PLUGIN_HOLDING_DIR = 'ansuz_installed_plugins' | ||
|
||
# Returns an array of plugin arrays. A plugin array | ||
# looks like [name, repository_url] | ||
def self.listing | ||
ary = [] | ||
xml.elements.each("plugins/plugin") do |plugin| | ||
name = plugin.elements["name"].text | ||
repository_url = plugin.elements["repository_url"].text | ||
ary << [name, repository_url, install_dir_for_repo(repository_url)] | ||
end | ||
ary | ||
end | ||
|
||
def self.xml_document | ||
uri = URI.parse REPOSITORY | ||
uri.read | ||
end | ||
|
||
def self.install_dir_for_repo repo | ||
repo.split("/").last.split(".").first | ||
end | ||
|
||
def self.xml | ||
REXML::Document.new xml_document | ||
end | ||
|
||
# This method will install a plugin, given a repository url | ||
def self.install repository_url, name | ||
`cd #{RAILS_ROOT}/#{PLUGIN_HOLDING_DIR}; git clone #{repository_url} #{name}` | ||
end | ||
|
||
# this method will copy a given plugin from PLUGIN_HOLDING_DIR to plugins | ||
def self.enable name | ||
FileUtils.cp_r(File.join(RAILS_ROOT, PLUGIN_HOLDING_DIR, name), File.join(RAILS_ROOT, 'vendor', 'plugins', name)) | ||
restart_ansuz | ||
end | ||
|
||
# This method will disable a given plugin (i.e. rm from plugins dir) | ||
def self.disable name | ||
FileUtils.rm_r(File.join(RAILS_ROOT, 'vendor', 'plugins', name)) | ||
restart_ansuz | ||
end | ||
|
||
def self.update name | ||
`cd #{plugin_folder_for(name)}; git pull` | ||
end | ||
|
||
def self.delete name | ||
FileUtil.rm_r plugin_folder_for(name) | ||
FileUtil.rm_r installed_plugin_folder_for(name) | ||
end | ||
|
||
def self.installed?(name) | ||
File.exist?(plugin_folder_for(name)) | ||
end | ||
|
||
def self.enabled?(name) | ||
File.exist?(installed_plugin_folder_for(name)) | ||
end | ||
|
||
def self.plugin_folder_for name | ||
File.join(RAILS_ROOT, PLUGIN_HOLDING_DIR, name) | ||
end | ||
|
||
def self.installed_plugin_folder_for name | ||
File.join(RAILS_ROOT, 'vendor', 'plugins', name) | ||
end | ||
|
||
def self.restart_ansuz | ||
FileUtils.touch(File.join(RAILS_ROOT, 'tmp', 'restart.txt')) | ||
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_plugin_installers, :collection => [:install, :update, :delete, :enable, :disable] | ||
end |