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
Nov 23, 2008
1 parent
64a836f
commit 5981faf
Showing
4 changed files
with
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<themes> | ||
<theme> | ||
<name>foo</name> | ||
<repository_url>bar</repository_url> | ||
</theme> | ||
</themes> |
9 changes: 9 additions & 0 deletions
9
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 |
---|---|---|
@@ -1,7 +1,16 @@ | ||
require 'ansuz/jadams/theme_repository_manager' | ||
|
||
module Ansuz | ||
module JAdams | ||
class AnsuzTheme < ActiveRecord::Base | ||
validates_uniqueness_of :name | ||
|
||
after_save :update_theme_repository_xml | ||
# FIXME: The theme installer and repository plugins are intermingled and gross | ||
|
||
def update_theme_repository_xml | ||
Ansuz::JAdams::ThemeRepositoryManager.write_file | ||
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
26 changes: 26 additions & 0 deletions
26
vendor/plugins/ansuz_theme_repository/lib/ansuz/jadams/theme_repository_manager.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,26 @@ | ||
module Ansuz | ||
module JAdams | ||
class ThemeRepositoryManager | ||
def self.write_file | ||
@ansuz_themes = Ansuz::JAdams::AnsuzTheme.find(:all, :order => 'name DESC') | ||
|
||
out = "" | ||
xml = Builder::XmlMarkup.new(:target => out, :indent => 2) | ||
xml.instruct! | ||
|
||
xml.themes do | ||
@ansuz_themes.each do |theme| | ||
xml.theme do | ||
xml.name theme.name | ||
xml.repository_url theme.repository_url | ||
end | ||
end | ||
end | ||
|
||
File.open("#{RAILS_ROOT}/public/ansuz_themes.xml", "w") do |file| | ||
file << out | ||
end | ||
end | ||
end | ||
end | ||
end |