merb_laszlo 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README +4 -0
- data/Rakefile +87 -0
- data/lib/merb-laszlo/controllers.rb +53 -0
- data/lib/merb-laszlo/helpers.rb +45 -0
- data/lib/merb-laszlo/merbtasks.rb +6 -0
- data/lib/merb-laszlo.rb +38 -0
- metadata +70 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Yehuda Katz
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/specification'
|
3
|
+
require 'date'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
require "extlib"
|
6
|
+
require 'merb-core/tasks/merb_rake_helper'
|
7
|
+
require "spec/rake/spectask"
|
8
|
+
|
9
|
+
##############################################################################
|
10
|
+
# Package && release
|
11
|
+
##############################################################################
|
12
|
+
RUBY_FORGE_PROJECT = "merb"
|
13
|
+
PROJECT_URL = "http://merbivore.com"
|
14
|
+
PROJECT_SUMMARY = "Merb plugin that provides support for Laszlo."
|
15
|
+
PROJECT_DESCRIPTION = PROJECT_SUMMARY
|
16
|
+
|
17
|
+
GEM_AUTHOR = "Yehuda Katz"
|
18
|
+
GEM_EMAIL = "ykatz@engineyard.com"
|
19
|
+
|
20
|
+
GEM_NAME = "merb_laszlo"
|
21
|
+
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
22
|
+
GEM_VERSION = "0.5.0" + PKG_BUILD
|
23
|
+
|
24
|
+
RELEASE_NAME = "REL #{GEM_VERSION}"
|
25
|
+
|
26
|
+
require "extlib/tasks/release"
|
27
|
+
|
28
|
+
spec = Gem::Specification.new do |s|
|
29
|
+
s.rubyforge_project = RUBY_FORGE_PROJECT
|
30
|
+
s.name = GEM_NAME
|
31
|
+
s.version = GEM_VERSION
|
32
|
+
s.platform = Gem::Platform::RUBY
|
33
|
+
s.has_rdoc = true
|
34
|
+
s.extra_rdoc_files = ["README", "LICENSE"]
|
35
|
+
s.summary = PROJECT_SUMMARY
|
36
|
+
s.description = PROJECT_DESCRIPTION
|
37
|
+
s.author = GEM_AUTHOR
|
38
|
+
s.email = GEM_EMAIL
|
39
|
+
s.homepage = PROJECT_URL
|
40
|
+
s.add_dependency('merb-core', '>= 0.9.4')
|
41
|
+
s.require_path = 'lib'
|
42
|
+
s.files = %w(LICENSE README Rakefile) + Dir.glob("{lib,specs}/**/*")
|
43
|
+
end
|
44
|
+
|
45
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
46
|
+
pkg.gem_spec = spec
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "create a gemspec file"
|
50
|
+
task :make_spec do
|
51
|
+
File.open("#{NAME}.gemspec", "w") do |file|
|
52
|
+
file.puts spec.to_ruby
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
##############################################################################
|
57
|
+
# Installation
|
58
|
+
##############################################################################
|
59
|
+
|
60
|
+
task :install => [:package] do
|
61
|
+
sh %{#{sudo} gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources}
|
62
|
+
end
|
63
|
+
|
64
|
+
namespace :jruby do
|
65
|
+
"Run :package and install the resulting .gem with jruby"
|
66
|
+
task :install => :package do
|
67
|
+
sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
##############################################################################
|
72
|
+
# Specs
|
73
|
+
##############################################################################
|
74
|
+
desc "Run all specs"
|
75
|
+
Spec::Rake::SpecTask.new("specs") do |t|
|
76
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
77
|
+
t.spec_files = Dir["spec/**/*_spec.rb"].sort
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "Run all specs and generate an rcov report"
|
81
|
+
Spec::Rake::SpecTask.new('rcov') do |t|
|
82
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
83
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
84
|
+
t.rcov = true
|
85
|
+
t.rcov_dir = 'coverage'
|
86
|
+
t.rcov_opts = ['--exclude', 'gems', '--exclude', 'spec']
|
87
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "pathname"
|
2
|
+
module Merb
|
3
|
+
class Controller
|
4
|
+
|
5
|
+
def laszlo(str)
|
6
|
+
@lz_resources ||= []
|
7
|
+
|
8
|
+
root, template_location = self.class._template_roots.last
|
9
|
+
resource_dir = root / send(template_location, "resources")[0...-1]
|
10
|
+
Merb.logger.info! "Resource dir: #{resource_dir}"
|
11
|
+
|
12
|
+
zip_filename = "#{Laszlo.file_name}.zip"
|
13
|
+
FileUtils.mkdir_p(Merb.root / "tmp")
|
14
|
+
Zip::ZipFile.open(Merb.root / "tmp" / zip_filename, Zip::ZipFile::CREATE) do |zipfile|
|
15
|
+
zipfile.get_output_stream("#{action_name}.lzx") do |f|
|
16
|
+
f.puts str
|
17
|
+
end
|
18
|
+
@lz_resources.each do |resource|
|
19
|
+
filepath = resource.split("/")
|
20
|
+
dir = filepath[1...-1].join("/").gsub(/^#{Merb.root}/, "")
|
21
|
+
filename = filepath[-1]
|
22
|
+
zipfile.mkdir(dir) unless zipfile.find_entry(dir) || dir.empty?
|
23
|
+
Merb.logger.info! "Looking for #{resource_dir / resource}"
|
24
|
+
if File.file?(resource_dir / resource)
|
25
|
+
zipfile.add(resource, resource_dir / resource)
|
26
|
+
elsif File.file?(root / resource)
|
27
|
+
zipfile.add(resource, root / resource)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
c = Curl::Easy.new
|
32
|
+
|
33
|
+
c.url = "#{Laszlo.url}/file_upload.jsp"
|
34
|
+
c.multipart_form_post = true
|
35
|
+
|
36
|
+
file = Curl::PostField.file("myFile", Merb.root / "tmp" / zip_filename, zip_filename)
|
37
|
+
file.content_type = "application/zip"
|
38
|
+
|
39
|
+
c.http_post(
|
40
|
+
file,
|
41
|
+
Curl::PostField.content("uid", "#{Laszlo.app_name}__#{controller_name}"))
|
42
|
+
|
43
|
+
File.delete(Merb.root / "tmp" / zip_filename)
|
44
|
+
|
45
|
+
if c.response_code == 200
|
46
|
+
redirect("#{Laszlo.url}/my-apps/#{Laszlo.app_name}__#{controller_name}/#{action_name}.lzx")
|
47
|
+
else
|
48
|
+
raise NotAcceptable
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Merb
|
2
|
+
module GlobalHelpers
|
3
|
+
|
4
|
+
def lz(name, *args, &blk)
|
5
|
+
send("lz_#{name}", *args, &blk)
|
6
|
+
end
|
7
|
+
|
8
|
+
def lz_reload_button
|
9
|
+
contents = "Reload" +
|
10
|
+
tag(:handler, %{LzBrowser.loadJS("window.location = \\\"#{request.full_uri}\\\"")}, :name => "onclick") +
|
11
|
+
tag(:handler, %{this.bringToFront()}, :name => "oninit")
|
12
|
+
|
13
|
+
tag(:button, contents, :valign => "bottom", :align => "right")
|
14
|
+
end
|
15
|
+
|
16
|
+
def lz_class(name, extends = nil, opts = {}, &blk)
|
17
|
+
opts.merge!(:name => name)
|
18
|
+
opts.merge!(:extends => extends) if extends
|
19
|
+
tag(:class, nil, opts, &blk)
|
20
|
+
end
|
21
|
+
|
22
|
+
def lz_text(text, opts = {})
|
23
|
+
self_closing_tag(:text, {:text => text}.merge(opts))
|
24
|
+
end
|
25
|
+
|
26
|
+
def lz_window(width, height, opts = {}, &blk)
|
27
|
+
opts = {:resizable => true, :width => width, :height => height}.merge!(opts)
|
28
|
+
tag(:window, nil, opts, &blk)
|
29
|
+
end
|
30
|
+
|
31
|
+
def lz_resource(name, src, opts = {})
|
32
|
+
@lz_resources ||= []
|
33
|
+
@lz_resources << src
|
34
|
+
opts.merge!(:name => name, :src => src)
|
35
|
+
self_closing_tag(:resource, opts)
|
36
|
+
end
|
37
|
+
|
38
|
+
def lz_on(name, options = {}, *args, &blk)
|
39
|
+
options.merge!(:name => "on#{name}")
|
40
|
+
options.merge!(:args => args.map {|x| x.to_s}.join(", ")) unless args.empty?
|
41
|
+
tag(:handler, capture(&blk), options)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
data/lib/merb-laszlo.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "digest/md5"
|
2
|
+
require "fileutils"
|
3
|
+
require "curb"
|
4
|
+
require "zip/zip"
|
5
|
+
srand(Time.now.to_i)
|
6
|
+
|
7
|
+
class Laszlo
|
8
|
+
def self.file_name
|
9
|
+
Digest::MD5.hexdigest(rand(Time.now.to_i).to_s)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.app_name
|
13
|
+
File.basename(File.expand_path(Merb.root))
|
14
|
+
end
|
15
|
+
|
16
|
+
cattr_accessor :url
|
17
|
+
end
|
18
|
+
|
19
|
+
require "haml"
|
20
|
+
|
21
|
+
module Haml
|
22
|
+
module Filters
|
23
|
+
module Cdata
|
24
|
+
include Haml::Filters::Base
|
25
|
+
|
26
|
+
def render(text)
|
27
|
+
"<![CDATA[#{("\n" + text).rstrip.gsub("\n", "\n ")}\n]]>"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Merb::Config[:haml] ||= {}
|
34
|
+
Merb::Config[:haml][:filters] ||= {}
|
35
|
+
Merb::Config[:haml][:filters].merge!("cdata" => Haml::Filters::Cdata)
|
36
|
+
|
37
|
+
require "merb-laszlo/controllers"
|
38
|
+
require "merb-laszlo/helpers"
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: merb_laszlo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yehuda Katz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-08-03 00:00:00 +03:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb-core
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.9.4
|
24
|
+
version:
|
25
|
+
description: Merb plugin that provides support for Laszlo.
|
26
|
+
email: ykatz@engineyard.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README
|
33
|
+
- LICENSE
|
34
|
+
files:
|
35
|
+
- LICENSE
|
36
|
+
- README
|
37
|
+
- Rakefile
|
38
|
+
- lib/merb-laszlo
|
39
|
+
- lib/merb-laszlo/controllers.rb
|
40
|
+
- lib/merb-laszlo/helpers.rb
|
41
|
+
- lib/merb-laszlo/merbtasks.rb
|
42
|
+
- lib/merb-laszlo.rb
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: http://merbivore.com
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
rubyforge_project: merb
|
65
|
+
rubygems_version: 1.2.0
|
66
|
+
signing_key:
|
67
|
+
specification_version: 2
|
68
|
+
summary: Merb plugin that provides support for Laszlo.
|
69
|
+
test_files: []
|
70
|
+
|