juggalo 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +2 -0
- data/juggalo.gemspec +25 -0
- data/lib/juggalo/layout.rb +34 -0
- data/lib/juggalo/page/loader/base.rb +12 -0
- data/lib/juggalo/page/loader/http.rb +12 -0
- data/lib/juggalo/page/loader/yaml.rb +24 -0
- data/lib/juggalo/page/loader.rb +17 -0
- data/lib/juggalo/page.rb +32 -0
- data/lib/juggalo/portlet.rb +22 -0
- data/lib/juggalo/version.rb +3 -0
- data/lib/juggalo.rb +16 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f8b50c5eb580f4cc53e634a4d042aefc679b750b
|
4
|
+
data.tar.gz: 1fdffdfe4b03a9f106a04a5d299fe9e2e90e29c5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1210823bee56f4dd2f5c9ebedc0b40ea7bf5b6fd51dbc3261b3fde8b1ee9122e75cae5a1a446fde805363538fee5f4e4806d83918b654310403c3bebde95c558
|
7
|
+
data.tar.gz: 7b20e6f4739af0a66eae8c1825b4e8f4fe24e6d91e1c944cbdcfddf940cacc966f03d7270d962fe38b38c40a679813fb74186a4bb827bb40daf25196ce295a1d
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Robert Kenny
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Juggalo
|
2
|
+
|
3
|
+
Experimenting with config driven web page composition
|
4
|
+
|
5
|
+
## TODO
|
6
|
+
|
7
|
+
- Load components into template
|
8
|
+
- Lots of other stuff ...
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'juggalo'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install juggalo
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
TODO: Write usage instructions here
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it ( https://github.com/[my-github-username]/juggalo/fork )
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/juggalo.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'juggalo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "juggalo"
|
8
|
+
spec.version = Juggalo::VERSION
|
9
|
+
spec.authors = ["Robert Kenny"]
|
10
|
+
spec.email = ["kenoir@gmail.com"]
|
11
|
+
spec.summary = %q{Config based page composition}
|
12
|
+
spec.description = %q{Work in progress}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "mustache"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'mustache'
|
2
|
+
|
3
|
+
module Juggalo
|
4
|
+
class Layout < Mustache
|
5
|
+
attr_accessor :regions
|
6
|
+
|
7
|
+
def initialize(template_location)
|
8
|
+
@regions={}
|
9
|
+
self.template_file = template_location
|
10
|
+
end
|
11
|
+
|
12
|
+
def method_missing(name, *args, &block)
|
13
|
+
return super unless respond_to? name.to_s
|
14
|
+
region @regions[name.to_s]
|
15
|
+
end
|
16
|
+
|
17
|
+
def respond_to?(method)
|
18
|
+
valid_regions.include? method.to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
def region(components)
|
22
|
+
components.map { |c| c.render }.join unless components.nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
def valid_regions
|
26
|
+
self.template.tokens.find_all { |token|
|
27
|
+
token.is_a?(Array) && token[0] == :mustache
|
28
|
+
}.map{ |token|
|
29
|
+
token[2][2][0].to_s
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'juggalo/page'
|
3
|
+
require 'juggalo/page/loader/base'
|
4
|
+
|
5
|
+
module Juggalo
|
6
|
+
class Page::Loader
|
7
|
+
class YAML < Base
|
8
|
+
def initialize(location)
|
9
|
+
@location = location
|
10
|
+
end
|
11
|
+
|
12
|
+
def components
|
13
|
+
page_hash["components"].map { |c| Juggalo::Portlet.new(c) }
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def page_hash
|
19
|
+
::YAML::load(File.open(@location))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
data/lib/juggalo/page.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Juggalo
|
2
|
+
class Page
|
3
|
+
attr_reader :components, :template
|
4
|
+
|
5
|
+
def initialize(layout, loader)
|
6
|
+
@layout = layout
|
7
|
+
@loader = loader
|
8
|
+
end
|
9
|
+
|
10
|
+
def compile
|
11
|
+
@layout.regions = compose
|
12
|
+
@layout.render
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def compose
|
18
|
+
@components ||= @loader.load
|
19
|
+
@regions ||= @components.reduce({}) do |regions, component|
|
20
|
+
regions.tap do |r|
|
21
|
+
if r[component.location].nil?
|
22
|
+
r[component.location] = [component]
|
23
|
+
else
|
24
|
+
r[component.location] << component
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Juggalo
|
2
|
+
class Portlet
|
3
|
+
attr_reader :id, :type, :opts, :location
|
4
|
+
|
5
|
+
def initialize(opts, loader = nil)
|
6
|
+
@opts = opts
|
7
|
+
|
8
|
+
@location = opts["location"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def render
|
12
|
+
"<div>#{opts}</div>"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Portlet::Loader
|
17
|
+
attr_reader :adapter
|
18
|
+
|
19
|
+
class HTTP; end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
data/lib/juggalo.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'juggalo/version'
|
2
|
+
require 'juggalo/page'
|
3
|
+
require 'juggalo/layout'
|
4
|
+
require 'juggalo/page/loader'
|
5
|
+
|
6
|
+
module Juggalo
|
7
|
+
def self.run(template_location, layout_location)
|
8
|
+
adapter = Page::Loader::YAML.new layout_location
|
9
|
+
loader = Page::Loader.new(adapter)
|
10
|
+
layout = Layout.new template_location
|
11
|
+
page = Page.new(layout, loader)
|
12
|
+
|
13
|
+
page.compile
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: juggalo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Kenny
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mustache
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Work in progress
|
56
|
+
email:
|
57
|
+
- kenoir@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- juggalo.gemspec
|
68
|
+
- lib/juggalo.rb
|
69
|
+
- lib/juggalo/layout.rb
|
70
|
+
- lib/juggalo/page.rb
|
71
|
+
- lib/juggalo/page/loader.rb
|
72
|
+
- lib/juggalo/page/loader/base.rb
|
73
|
+
- lib/juggalo/page/loader/http.rb
|
74
|
+
- lib/juggalo/page/loader/yaml.rb
|
75
|
+
- lib/juggalo/portlet.rb
|
76
|
+
- lib/juggalo/version.rb
|
77
|
+
homepage: ''
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.0.3
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Config based page composition
|
101
|
+
test_files: []
|