Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Organizing plugin into features (essential, visualize, and teleport)
- Loading branch information
1 parent
c881ebd
commit 9f7e3e6
Showing
25 changed files
with
446 additions
and
301 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 |
---|---|---|
@@ -1,4 +1 @@ | ||
require 'silverline' | ||
require 'generator' | ||
|
||
Generator.register | ||
require 'silverline' |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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,11 @@ | ||
module Silverline::Essential | ||
# Nothing on purpose =) | ||
end | ||
|
||
require 'silverline/essential/generator' | ||
Silverline::Essential::Generator.register | ||
|
||
require 'silverline/essential/html' | ||
ActionView::Base.class_eval do | ||
include Silverline::Essential::Html | ||
end |
11 changes: 5 additions & 6 deletions
11
vendor/plugins/silverline/lib/generator.rb → ...ine/lib/silverline/essential/generator.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
58 changes: 58 additions & 0 deletions
58
vendor/plugins/silverline/lib/silverline/essential/html.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,58 @@ | ||
module Silverline::Essential::Html | ||
|
||
def silverlight_include_tag(options) | ||
templatify("head.html.erb", binding) | ||
end | ||
|
||
def silverlight_object(options = {}) | ||
require 'erb' | ||
defaults = { | ||
:start => "app", | ||
:debug => true, | ||
:reportErrors => "errorLocation", | ||
:properties => { | ||
:width => 1, | ||
:height => 1, | ||
:background => "#ffffffff", | ||
:windowless => true | ||
} | ||
} | ||
options = defaults.merge(options) | ||
options[:start] << ".rb" | ||
retval = "" | ||
if options[:properties][:width].to_i < 2 || options[:properties][:height].to_i < 2 | ||
retval << %Q( | ||
<style type='text/css'> | ||
#SilverlightControlHost { | ||
position: absolute; | ||
} | ||
</style> | ||
) | ||
end | ||
retval << templatify("body.html.erb", binding) | ||
end | ||
|
||
private | ||
|
||
def http_host | ||
session.cgi.instance_variable_get(:"@request").params["HTTP_HOST"] | ||
end | ||
|
||
def generate_init_params(options) | ||
options.delete(:properties) | ||
p = options.collect { |k,v| "#{k.to_s}=#{v.to_s}" }.join(", ") | ||
p << ", http_host=#{http_host}" | ||
end | ||
|
||
def public_xap_file | ||
"/#{Silverline::XAP_FILE.split("/").last}" | ||
end | ||
|
||
def jsonify(o) | ||
o.to_json.gsub("\"", "'").gsub(",", "==>") | ||
end | ||
|
||
def templatify(path, b) | ||
ERB.new(File.open("#{Silverline::PLUGIN_ROOT}/templates/#{path}"){|f| f.read}).result(b) | ||
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,86 @@ | ||
module Silverline::Essential | ||
|
||
# Handles packaging the Silverlight application. | ||
class XAP | ||
|
||
# require rubyzip (gem install rubyzip | http://rubyzip.sourceforge.net/) | ||
require 'zip/zipfilesystem' | ||
require 'erb' | ||
|
||
def initialize(file, directory) | ||
@file = file | ||
@directory = directory | ||
@files = [] | ||
end | ||
|
||
def generate | ||
Zip::ZipFile.open @file, Zip::ZipFile::CREATE do |zip| | ||
xap zip, @directory | ||
zip.file.open "AppManifest.xaml", 'w' do |m| | ||
m.puts manifest | ||
@files << "AppManifest.xaml" | ||
end | ||
end | ||
# Remove temp files left behind by rubyzip | ||
# Bug: http://sourceforge.net/tracker/index.php?func=detail&aid=1702240&group_id=43107&atid=435170 | ||
@files.each do |file| | ||
file = file.split("/").last | ||
Dir["public/#{file}.*"].each do |f| | ||
File.delete f | ||
end | ||
end | ||
@files = [] | ||
end | ||
|
||
private | ||
|
||
def manifest | ||
@assembly_path = "/public/ironruby" | ||
# Note: Silverlight entry-point assembly must be the first in this list | ||
# (Microsoft.Scripting.Silverlight in this case) | ||
@assemblies = %w(Microsoft.Scripting.Silverlight Microsoft.Scripting IronRuby IronRuby.Libraries) | ||
@entry_point_type = "Microsoft.Scripting.Silverlight.DynamicSilverlight" | ||
file = File.open("#{PLUGIN_ROOT}/templates/AppManifest.xaml.erb", 'r'){|f| f.read } | ||
xaml = ERB.new(file). | ||
xaml.run(binding) | ||
end | ||
|
||
def xap(zip, dir) | ||
xap_helper(zip, dir) | ||
end | ||
|
||
def xap_helper(zip, dir, root = dir) | ||
Dir["#{dir}/*"].each do |client| | ||
short_client = client.split(root).last | ||
if File.directory? client | ||
zip.dir.mkdir short_client | ||
xap_helper zip, client, root | ||
else | ||
zip.file.open short_client, 'w' do |zf| | ||
f = File.open client | ||
zf.puts f.read | ||
f.close | ||
end | ||
end | ||
@files << short_client | ||
end | ||
end | ||
|
||
end | ||
|
||
# Handles packaging the Silverlight application with Chiron, a .NET console | ||
# application written in C#. It handles generation of the AppManifest.xaml, as | ||
# well as packaging the app and including language assemblies if needed. | ||
# Note: because Chiron is a .NET application, it requires mono to run on | ||
# Mac/Linux. If you don't want to install mono, use the pure-ruby XAP module. | ||
class XAPChiron < XAP | ||
|
||
def generate | ||
cmd = "public/ironruby/Chiron.exe /s /d:#{@directory} /z:#{@file}" | ||
# TODO: Should I do some platform detection rather than trial&error? | ||
system "#{cmd}" unless system "mono #{cmd}" | ||
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,14 @@ | ||
module Silverline::Teleport | ||
# Nothing on purpose =) | ||
end | ||
|
||
require 'silverline/teleport/controller' | ||
require 'silverline/teleport/view' | ||
require 'silverline/teleport/html' | ||
ActionController::Base.class_eval do | ||
include Silverline::Teleport::Controller | ||
end | ||
ActionView::Base.class_eval do | ||
include Silverline::Teleport::View | ||
include Silverline::Teleport::Html | ||
end |
Oops, something went wrong.