halfling 0.0.1
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.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +7 -0
- data/Gemfile +3 -0
- data/LICENSE +23 -0
- data/README.md +17 -0
- data/Rakefile +2 -0
- data/data/app_structure/Gemfile +49 -0
- data/data/app_structure/app/assets/.gitkeep +0 -0
- data/data/app_structure/app/controllers/.gitkeep +0 -0
- data/data/app_structure/app/models/.gitkeep +0 -0
- data/data/app_structure/app/views/layouts/application.haml +9 -0
- data/data/app_structure/config.ru.tt +4 -0
- data/data/app_structure/config/application.rb.tt +30 -0
- data/data/app_structure/config/env.yml +5 -0
- data/data/app_structure/config/initializers/.gitkeep +0 -0
- data/data/app_structure/unicorn.rb.tt +69 -0
- data/exe/halfling +40 -0
- data/halfling.gemspec +52 -0
- data/lib/halfling.rb +4 -0
- data/lib/halfling/base.rb +153 -0
- data/lib/halfling/response.rb +14 -0
- data/lib/halfling/version.rb +3 -0
- metadata +207 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 60af41861262deea4db31889c565acee9e4ea7d0
|
|
4
|
+
data.tar.gz: 90046eb9bab88f07ad6ed368eead6ed07a764548
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 04b99b435b8efdb6b73d1ef8aae47a6001f47acddab639a1c362795721bf148b017d1a53fad706248c820f927996cffbecb0e02b84b3d6f1473c117c5142e09c
|
|
7
|
+
data.tar.gz: 1523479f035bb4eb767053faead0acbe915a6728a62a5f8af66b5cf09d8b2aa60b7cefb50b55869eb155ffa993eec6a8224d9370ed45a715f2092a7090d5971d
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
In the spirit of inclusiveness, cooperation and community, this software is
|
|
2
|
+
distributed with the strictly enforced CYHTFYW Code of Conduct. Failure to
|
|
3
|
+
comply with this code may result in punitive action and loss of privilege.
|
|
4
|
+
|
|
5
|
+
## CYHTFYW Code of Conduct:
|
|
6
|
+
|
|
7
|
+
1. Conduct yourself however the fuck you want.
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Hobbit Copyright (c) 2013 Patricio Mac Adden
|
|
2
|
+
Halfling cobbled together by slact in 2017
|
|
3
|
+
|
|
4
|
+
MIT License
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
a copy of this software and associated documentation files (the
|
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
12
|
+
the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Halfling
|
|
2
|
+
|
|
3
|
+
A structured wrapper for Hobbit, a minimalistic microframework built on top of [Rack](http://rack.github.io/). A nice blend of `hobbit` and `hobbit-contrib`, with automatic template discovery, controller mapping, and some assumptions about app filesystem layout.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'halfling'
|
|
11
|
+
# or this if you want to use hobbit master
|
|
12
|
+
# gem 'halfling', github: 'slact/halfling'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Why even is?
|
|
16
|
+
|
|
17
|
+
For convenience. I like Hobbit, but it lacks a couple of things.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
source 'https://rubygems.org'
|
|
3
|
+
gem 'unicorn'
|
|
4
|
+
|
|
5
|
+
#rack stuff
|
|
6
|
+
gem 'warden'
|
|
7
|
+
gem 'rack-contrib'
|
|
8
|
+
gem 'rack-abstract-format'
|
|
9
|
+
gem 'rack-respond_to'
|
|
10
|
+
gem 'rack-referrals'
|
|
11
|
+
gem 'muster'
|
|
12
|
+
gem 'rack-attack'
|
|
13
|
+
gem 'chrome_logger'
|
|
14
|
+
gem 'rack-detect-tor'
|
|
15
|
+
gem 'haml'
|
|
16
|
+
gem 'racksh'
|
|
17
|
+
gem 'redis-rack'
|
|
18
|
+
|
|
19
|
+
#rack reloader
|
|
20
|
+
gem "mr-sparkle"
|
|
21
|
+
|
|
22
|
+
#gem 'hiredis'
|
|
23
|
+
#gem 'redis', :require => ["redis/connection/hiredis", "redis"]
|
|
24
|
+
|
|
25
|
+
#gem 'i18n'
|
|
26
|
+
gem "halfling", github: 'slact/halfling'
|
|
27
|
+
|
|
28
|
+
group :development do
|
|
29
|
+
#mmm... pry...
|
|
30
|
+
gem "pry"
|
|
31
|
+
gem "pry-coolline"
|
|
32
|
+
gem "pry-doc"
|
|
33
|
+
gem "pry-remote"
|
|
34
|
+
#gem "pry-rescue"
|
|
35
|
+
gem "pry-git"
|
|
36
|
+
gem "pry-theme"
|
|
37
|
+
gem "pry-byebug", "~> 1.3.3"
|
|
38
|
+
|
|
39
|
+
gem 'awesome_print'
|
|
40
|
+
gem 'better_errors', github: 'grekko/better_errors'
|
|
41
|
+
gem 'binding_of_caller'
|
|
42
|
+
gem 'rake'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
group :test do
|
|
46
|
+
gem 'minitest', require: 'minitest/autorun'
|
|
47
|
+
gem 'minitest-reporters'
|
|
48
|
+
gem 'rack-test', require: 'rack/test'
|
|
49
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
require "halfling"
|
|
3
|
+
Bundler.require :default, ENV['RACK_ENV'].to_sym
|
|
4
|
+
|
|
5
|
+
module <%=classname%>
|
|
6
|
+
class Application < Hobbit::Base
|
|
7
|
+
#include Hobbit::Session
|
|
8
|
+
#include Hobbit::Filter
|
|
9
|
+
|
|
10
|
+
use Rack::MethodOverride
|
|
11
|
+
|
|
12
|
+
if development?
|
|
13
|
+
#use PryRescue::Rack
|
|
14
|
+
#use BetterErrors::Middleware
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
#use Rack::Session::Redis
|
|
18
|
+
# must be used after Rack::Session::Cookie
|
|
19
|
+
#use Rack::Protection, except: :http_origin
|
|
20
|
+
|
|
21
|
+
#convenience methods
|
|
22
|
+
#def user
|
|
23
|
+
# env['warden'].user
|
|
24
|
+
#end
|
|
25
|
+
|
|
26
|
+
#static resources
|
|
27
|
+
#use Rack::Static, root: 'app/assets/', urls: ['/js', '/css', '/img', '/icons', '/documents']
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Sample verbose configuration file for Unicorn (not Rack)
|
|
2
|
+
#
|
|
3
|
+
# This configuration file documents many features of Unicorn
|
|
4
|
+
# that may not be needed for some applications. See
|
|
5
|
+
# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
|
|
6
|
+
# for a much simpler configuration file.
|
|
7
|
+
#
|
|
8
|
+
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
|
|
9
|
+
# documentation.
|
|
10
|
+
|
|
11
|
+
# Use at least one worker per core if you're on a dedicated server,
|
|
12
|
+
# more will usually help for _short_ waits on databases/caches.
|
|
13
|
+
worker_processes 4
|
|
14
|
+
|
|
15
|
+
# Help ensure your application will always spawn in the symlinked
|
|
16
|
+
# "current" directory that Capistrano sets up.
|
|
17
|
+
#working_directory "/path/to/app/current" # available in 0.94.0+
|
|
18
|
+
|
|
19
|
+
# listen on both a Unix domain socket and a TCP port,
|
|
20
|
+
# we use a shorter backlog for quicker failover when busy
|
|
21
|
+
listen "/tmp/<%=dirname%>_unicorn.sock", :backlog => 64
|
|
22
|
+
listen 9293, :tcp_nopush => true
|
|
23
|
+
|
|
24
|
+
# nuke workers after 30 seconds instead of 60 seconds (the default)
|
|
25
|
+
timeout 30
|
|
26
|
+
|
|
27
|
+
# feel free to point this anywhere accessible on the filesystem
|
|
28
|
+
pid "/tmp/<%=dirname%>_unicorn.pid"
|
|
29
|
+
|
|
30
|
+
# By default, the Unicorn logger will write to stderr.
|
|
31
|
+
# Additionally, some applications/frameworks log to stderr or stdout,
|
|
32
|
+
# so prevent them from going to /dev/null when daemonized here:
|
|
33
|
+
#stderr_path "/var/log/<%=dirname%>/unicorn.stderr.log"
|
|
34
|
+
#stdout_path "/var/log/<%=dirname%>/unicorn.stdout.log"
|
|
35
|
+
|
|
36
|
+
# combine Ruby 2.0.0+ with "preload_app true" for memory savings
|
|
37
|
+
preload_app true
|
|
38
|
+
GC.respond_to?(:copy_on_write_friendly=) and
|
|
39
|
+
GC.copy_on_write_friendly = true
|
|
40
|
+
|
|
41
|
+
# Enable this flag to have unicorn test client connections by writing the
|
|
42
|
+
# beginning of the HTTP headers before calling the application. This
|
|
43
|
+
# prevents calling the application for connections that have disconnected
|
|
44
|
+
# while queued. This is only guaranteed to detect clients on the same
|
|
45
|
+
# host unicorn runs on, and unlikely to detect disconnects even on a
|
|
46
|
+
# fast LAN.
|
|
47
|
+
check_client_connection false
|
|
48
|
+
|
|
49
|
+
# local variable to guard against running a hook multiple times
|
|
50
|
+
run_once = true
|
|
51
|
+
|
|
52
|
+
before_fork do |server, worker|
|
|
53
|
+
if run_once
|
|
54
|
+
# do_something_once_here ...
|
|
55
|
+
run_once = false # prevent from firing again
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
after_fork do |server, worker|
|
|
60
|
+
if worker.nr + 1 == server.worker_processes
|
|
61
|
+
#loaded last worker. kill old unicorn master if necessary
|
|
62
|
+
begin
|
|
63
|
+
oldpid = File.read "#{server.pid}.oldbin"
|
|
64
|
+
Process.kill(:QUIT, oldpid.to_i)
|
|
65
|
+
rescue Errno::ENOENT
|
|
66
|
+
#no problem
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
data/exe/halfling
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'halfling'
|
|
3
|
+
require "optparse"
|
|
4
|
+
require 'erb'
|
|
5
|
+
|
|
6
|
+
arg=OptionParser.new do |opts|
|
|
7
|
+
opts.on("--new [AppName]", "create new Halfling app") do |name|
|
|
8
|
+
require "fileutils"
|
|
9
|
+
|
|
10
|
+
cur_pwd = Dir.pwd
|
|
11
|
+
dirname = name.downcase
|
|
12
|
+
root = File.join(cur_pwd, dirname)
|
|
13
|
+
classname = name.split(/[-_]/).map.with_index{|x,i| i > 0 ? x.capitalize : x}.join
|
|
14
|
+
|
|
15
|
+
Dir.mkdir root rescue Errno::EEXIST
|
|
16
|
+
|
|
17
|
+
Dir.chdir File.join(File.dirname(__FILE__),'../data/app_structure')
|
|
18
|
+
skelly = Dir['**/*']
|
|
19
|
+
|
|
20
|
+
puts root
|
|
21
|
+
|
|
22
|
+
skelly.each do |f|
|
|
23
|
+
if File.directory?(f)
|
|
24
|
+
FileUtils.mkdir File.join(root, f) rescue Errno::EEXIST
|
|
25
|
+
elsif f.match(/\.tt$/)
|
|
26
|
+
erb = ERB.new(File.read(f))
|
|
27
|
+
File.open(File.join(root, f.chomp(File.extname(f))), 'w') { |file| file.write(erb.result(binding)) }
|
|
28
|
+
else
|
|
29
|
+
FileUtils.cp(f, File.dirname(File.join(root, f)))
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
arg.banner=<<EOS
|
|
36
|
+
Halfling stuff
|
|
37
|
+
EOS
|
|
38
|
+
arg.version=Halfling::VERSION
|
|
39
|
+
|
|
40
|
+
arg.parse!
|
data/halfling.gemspec
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'halfling/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "halfling"
|
|
8
|
+
spec.version = Halfling::VERSION
|
|
9
|
+
spec.authors = ["Leo P."]
|
|
10
|
+
spec.email = ["junk@slact.net"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Halfling - a Hobbit with some Railsy structure}
|
|
13
|
+
spec.description = %q{Use hobbit with some template niceties and other conveniences.}
|
|
14
|
+
spec.homepage = "https://github.com/slact/halfling"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
|
19
|
+
if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
|
21
|
+
else
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
|
|
30
|
+
dependencies = [
|
|
31
|
+
[:runtime, "hobbit"],
|
|
32
|
+
[:runtime, "hobbit-contrib"],
|
|
33
|
+
[:runtime, "i18n"],
|
|
34
|
+
[:runtime, 'rack-protection'],
|
|
35
|
+
[:runtime, 'sprockets'],
|
|
36
|
+
[:runtime, 'tilt'],
|
|
37
|
+
[:runtime, 'thin'],
|
|
38
|
+
|
|
39
|
+
[:development, "bundler"],
|
|
40
|
+
[:development, "rake"],
|
|
41
|
+
[:development, "pry"]
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
dependencies.each do |type, name, version|
|
|
45
|
+
if spec.respond_to?("add_#{type}_dependency")
|
|
46
|
+
spec.send("add_#{type}_dependency", name, version)
|
|
47
|
+
else
|
|
48
|
+
spec.add_dependency(name, version)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
data/lib/halfling.rb
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
require "hobbit"
|
|
2
|
+
require "hobbit/base"
|
|
3
|
+
require "yaml"
|
|
4
|
+
require "halfling/request"
|
|
5
|
+
require "halfling/response"
|
|
6
|
+
|
|
7
|
+
module Hobbit
|
|
8
|
+
class Base
|
|
9
|
+
include Hobbit::Render
|
|
10
|
+
include Hobbit::Environment
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
INITIALIZERS_PATH='config/initializers/**/*.rb'
|
|
14
|
+
MODELS_PATH='app/models/**/*.rb'
|
|
15
|
+
VIEWS_PATH='app/views'
|
|
16
|
+
CONTROLLERS_PATH='app/controllers/**/*.rb'
|
|
17
|
+
|
|
18
|
+
def inherited(sub)
|
|
19
|
+
puts "inherited #{sub}, #{sub.superclass}, #{Base}"
|
|
20
|
+
|
|
21
|
+
if sub.superclass == Base
|
|
22
|
+
#config stuff
|
|
23
|
+
if File.exists?('config/env.yml')
|
|
24
|
+
all_conf=YAML.load_file 'config/env.yml'
|
|
25
|
+
conf=all_conf[ENV['RACK_ENV']]
|
|
26
|
+
@@config=conf
|
|
27
|
+
@@application=sub
|
|
28
|
+
use Rack::Config do |env|
|
|
29
|
+
conf.each do |cf, val|
|
|
30
|
+
env[cf.to_sym]=val
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
class << sub
|
|
36
|
+
def inherited(sub)
|
|
37
|
+
puts "#{self} REALLY inherited from #{sub}"
|
|
38
|
+
|
|
39
|
+
name=sub.name.match(".*?::(.*)Controller")[1].downcase!
|
|
40
|
+
if name == "root"
|
|
41
|
+
@@root_controller = sub
|
|
42
|
+
else
|
|
43
|
+
@@controller_routes ||= {}
|
|
44
|
+
@@controller_routes["/#{name}"]=sub
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
#standard paths and stuff
|
|
49
|
+
paths = [INITIALIZERS_PATH, MODELS_PATH, CONTROLLERS_PATH]
|
|
50
|
+
paths.each do |path|
|
|
51
|
+
Dir[path].sort!.each {|f| require File.expand_path(f) }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
#templates
|
|
56
|
+
reload_templates
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def config
|
|
61
|
+
@@config
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def any(path, verbs, &block)
|
|
65
|
+
verbs.each do |verb|
|
|
66
|
+
routes[verb.to_s.upcase] << compile_route(path, &block)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def reload_templates
|
|
71
|
+
#find and remember all known templates
|
|
72
|
+
@@templates={}
|
|
73
|
+
Dir["#{VIEWS_PATH}/**/*.*"].each do |f|
|
|
74
|
+
m=f.match(/^#{VIEWS_PATH}\/(?<tmpl>.*)\.\w+/)
|
|
75
|
+
k=m[:tmpl].to_sym
|
|
76
|
+
if @@templates[k]
|
|
77
|
+
raise "Template for #{k} already present, should not overwrite. (wanted to replace #{@@templates[k]} with #{f})"
|
|
78
|
+
end
|
|
79
|
+
@@templates[k]=f
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
private
|
|
84
|
+
old_compile_route = instance_method(:compile_route)
|
|
85
|
+
define_method :compile_route do |path, &block|
|
|
86
|
+
route = { block: block, compiled_path: nil, extra_params: [], path: path }
|
|
87
|
+
|
|
88
|
+
if Regexp === path
|
|
89
|
+
compiled_path = path
|
|
90
|
+
path.named_captures.each do |k, v|
|
|
91
|
+
route[:extra_params] << k
|
|
92
|
+
end
|
|
93
|
+
route[:compiled_path] = compiled_path
|
|
94
|
+
else
|
|
95
|
+
route = old_compile_route.bind(self).(path, &block)
|
|
96
|
+
end
|
|
97
|
+
route
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def initialize
|
|
102
|
+
if @@controller_routes
|
|
103
|
+
@@controller_routes.each do |route, controller|
|
|
104
|
+
puts "map #{route} to #{controller.name}"
|
|
105
|
+
@@application.map(route) do
|
|
106
|
+
run controller.new
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
@@controller_routes = nil
|
|
110
|
+
end
|
|
111
|
+
if @@root_controller
|
|
112
|
+
puts "map root / to #{@@root_controller.name}"
|
|
113
|
+
root_controller = @@root_controller
|
|
114
|
+
@@application.map("/") do
|
|
115
|
+
run root_controller.new
|
|
116
|
+
end
|
|
117
|
+
@@root_controller = nil
|
|
118
|
+
end
|
|
119
|
+
super
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
#template stuff
|
|
123
|
+
def find_template(template)
|
|
124
|
+
tmpl_path=@@templates[template.to_sym]
|
|
125
|
+
raise "template #{template} not found" unless tmpl_path
|
|
126
|
+
tmpl_path
|
|
127
|
+
end
|
|
128
|
+
def default_layout
|
|
129
|
+
find_template :"layouts/application"
|
|
130
|
+
end
|
|
131
|
+
def template_engine
|
|
132
|
+
raise "template_engine shouldn't be called"
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
#convenience stuff
|
|
137
|
+
def set_content_type (val)
|
|
138
|
+
response.headers["Content-Type"]=val
|
|
139
|
+
end
|
|
140
|
+
def json_response!
|
|
141
|
+
set_content_type "application/json"
|
|
142
|
+
end
|
|
143
|
+
def js_response!
|
|
144
|
+
set_content_type "application/javascript"
|
|
145
|
+
end
|
|
146
|
+
def params
|
|
147
|
+
request.params
|
|
148
|
+
end
|
|
149
|
+
def param(name)
|
|
150
|
+
params[name]
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'hobbit/response'
|
|
2
|
+
|
|
3
|
+
module Hobbit
|
|
4
|
+
class Response
|
|
5
|
+
def finish
|
|
6
|
+
if status == 204 || status == 205 || status == 304 || (100..199).include?(status)
|
|
7
|
+
headers.delete 'Content-Type'
|
|
8
|
+
else
|
|
9
|
+
headers['Content-Length'] = @length.to_s
|
|
10
|
+
end
|
|
11
|
+
[status, headers, body]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: halfling
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Leo P.
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-01-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: hobbit
|
|
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: hobbit-contrib
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: i18n
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rack-protection
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: sprockets
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: tilt
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: thin
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: bundler
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: rake
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: pry
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
153
|
+
description: Use hobbit with some template niceties and other conveniences.
|
|
154
|
+
email:
|
|
155
|
+
- junk@slact.net
|
|
156
|
+
executables:
|
|
157
|
+
- halfling
|
|
158
|
+
extensions: []
|
|
159
|
+
extra_rdoc_files: []
|
|
160
|
+
files:
|
|
161
|
+
- CODE_OF_CONDUCT.md
|
|
162
|
+
- Gemfile
|
|
163
|
+
- LICENSE
|
|
164
|
+
- README.md
|
|
165
|
+
- Rakefile
|
|
166
|
+
- data/app_structure/Gemfile
|
|
167
|
+
- data/app_structure/app/assets/.gitkeep
|
|
168
|
+
- data/app_structure/app/controllers/.gitkeep
|
|
169
|
+
- data/app_structure/app/models/.gitkeep
|
|
170
|
+
- data/app_structure/app/views/layouts/application.haml
|
|
171
|
+
- data/app_structure/config.ru.tt
|
|
172
|
+
- data/app_structure/config/application.rb.tt
|
|
173
|
+
- data/app_structure/config/env.yml
|
|
174
|
+
- data/app_structure/config/initializers/.gitkeep
|
|
175
|
+
- data/app_structure/unicorn.rb.tt
|
|
176
|
+
- exe/halfling
|
|
177
|
+
- halfling.gemspec
|
|
178
|
+
- lib/halfling.rb
|
|
179
|
+
- lib/halfling/base.rb
|
|
180
|
+
- lib/halfling/response.rb
|
|
181
|
+
- lib/halfling/version.rb
|
|
182
|
+
homepage: https://github.com/slact/halfling
|
|
183
|
+
licenses:
|
|
184
|
+
- MIT
|
|
185
|
+
metadata:
|
|
186
|
+
allowed_push_host: https://rubygems.org
|
|
187
|
+
post_install_message:
|
|
188
|
+
rdoc_options: []
|
|
189
|
+
require_paths:
|
|
190
|
+
- lib
|
|
191
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
|
+
requirements:
|
|
193
|
+
- - ">="
|
|
194
|
+
- !ruby/object:Gem::Version
|
|
195
|
+
version: '0'
|
|
196
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
|
+
requirements:
|
|
198
|
+
- - ">="
|
|
199
|
+
- !ruby/object:Gem::Version
|
|
200
|
+
version: '0'
|
|
201
|
+
requirements: []
|
|
202
|
+
rubyforge_project:
|
|
203
|
+
rubygems_version: 2.6.8
|
|
204
|
+
signing_key:
|
|
205
|
+
specification_version: 4
|
|
206
|
+
summary: Halfling - a Hobbit with some Railsy structure
|
|
207
|
+
test_files: []
|