tipsy 0.1.3 → 0.1.4
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/lib/templates/site/Gemfile +3 -3
- data/lib/templates/site/assets/javascripts/site.js +0 -0
- data/lib/templates/site/layouts/default.html.erb +42 -42
- data/lib/tipsy/handler/php.rb +33 -15
- data/lib/tipsy/runner.rb +18 -3
- data/lib/tipsy/runners/compiler.rb +14 -2
- data/lib/tipsy/server.rb +4 -4
- data/lib/tipsy/site.rb +4 -0
- data/lib/tipsy/version.rb +1 -1
- data/lib/tipsy/view.rb +1 -1
- data/lib/tipsy/view/base.rb +1 -1
- data/lib/tipsy/view/path.rb +4 -0
- metadata +4 -3
data/lib/templates/site/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
gem "rack", "~> 1.
|
3
|
+
gem "rack", "~> 1.4"
|
4
4
|
gem "tilt", "~> 1.3"
|
5
5
|
gem "i18n", "~> 0.6"
|
6
6
|
gem "sass", "~> 3.1"
|
@@ -8,7 +8,7 @@ gem "activesupport", ">= 3.1"
|
|
8
8
|
gem "sprockets", "~> 2.0"
|
9
9
|
gem "erubis"
|
10
10
|
|
11
|
-
# Thin or
|
11
|
+
# Thin or puma are recommended over Webrick
|
12
12
|
# gem "thin"
|
13
13
|
|
14
14
|
# Uglifier is recommended for javascript compression. If unavailable, Google's online
|
@@ -16,4 +16,4 @@ gem "erubis"
|
|
16
16
|
# gem 'uglifier'
|
17
17
|
|
18
18
|
# Compass is automatically detected and configured if available
|
19
|
-
# gem "compass", "~> 0.
|
19
|
+
# gem "compass", "~> 0.12.2"
|
File without changes
|
@@ -5,51 +5,51 @@
|
|
5
5
|
<!--[if gt IE 8]><!-->
|
6
6
|
<html class="no-js" lang="en"><!--<![endif]-->
|
7
7
|
<head>
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
8
|
+
<meta charset="utf-8">
|
9
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
10
|
+
<title><%= page_title %></title>
|
11
|
+
<meta name="description" content="">
|
12
|
+
<meta name="keywords" content="">
|
13
|
+
<meta name="author" content="" />
|
14
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
15
|
+
<!-- pre-fetch dns info for external sites -->
|
16
|
+
<link rel="dns-prefetch" href="//ajax.googleapis.com" />
|
17
|
+
<!-- 'pinned' sites in IE ( see: http://html5boilerplate.com/docs/head-Tips/ ) -->
|
18
|
+
<meta name="application-name" content="" />
|
19
|
+
<meta name="msapplication-tooltip" content="" />
|
20
|
+
<!-- Facebook open graph ( seff: http://developers.facebook.com/docs/share ) -->
|
21
|
+
<meta property="og:title" content="" />
|
22
|
+
<meta property="og:description" content="" />
|
23
|
+
<meta property="og:image" content="" />
|
24
|
+
<%= stylesheet_link_tag 'screen' %>
|
25
|
+
<!--[if lt IE 9]>
|
26
|
+
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
27
|
+
<![endif]-->
|
28
28
|
</head>
|
29
29
|
<body id="<%= page_id %>">
|
30
|
-
|
31
|
-
|
30
|
+
<div id="wrapper">
|
31
|
+
<header>
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
</header>
|
34
|
+
<div id="main" role="main">
|
35
|
+
<%= yield %>
|
36
|
+
</div>
|
37
|
+
<footer>
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
39
|
+
</footer>
|
40
|
+
</div>
|
41
|
+
<%= javascript_include_tag "//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" %>
|
42
|
+
<%= javascript_include_tag 'site' %>
|
43
|
+
<!-- <script>
|
44
|
+
// Replace UA-XXXXX-X with the proper analytics code
|
45
|
+
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
|
46
|
+
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
47
|
+
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
|
48
|
+
s.parentNode.insertBefore(g,s)}(document,'script'));
|
49
|
+
</script> -->
|
50
|
+
<!--[if lt IE 7 ]>
|
51
|
+
<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
|
52
|
+
<script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
|
53
|
+
<![endif]-->
|
54
54
|
</body>
|
55
55
|
</html>
|
data/lib/tipsy/handler/php.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'tilt'
|
2
|
+
require 'digest/md5'
|
2
3
|
|
3
4
|
module Tipsy
|
4
5
|
module Handler
|
@@ -15,32 +16,49 @@ module Tipsy
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def evaluate(scope, locals, &block)
|
19
|
+
@engine.template = scope.template.full_path
|
18
20
|
@output ||= @engine.render
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
24
|
class PhpProcessor
|
23
|
-
attr_accessor :data
|
25
|
+
attr_accessor :data, :template, :env
|
24
26
|
|
25
27
|
def initialize(d)
|
26
|
-
@data
|
28
|
+
@data = d
|
29
|
+
@cname = nil
|
30
|
+
unless Dir.exists?(compile_to)
|
31
|
+
FileUtils.mkdir(compile_to)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def compile_to
|
36
|
+
File.join(Tipsy.root, '.php-temp')
|
37
|
+
end
|
38
|
+
|
39
|
+
def cache_name
|
40
|
+
@cname ||= ::Digest::MD5.hexdigest(template.gsub(File.join(Tipsy.root, 'views'), ''))
|
41
|
+
end
|
42
|
+
|
43
|
+
def tempfile
|
44
|
+
File.join(compile_to, "#{cache_name}.php")
|
27
45
|
end
|
28
46
|
|
29
|
-
def render
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
47
|
+
def render
|
48
|
+
# if File.exists?(tempfile) && (File.mtime(tempfile) > File.mtime(template))
|
49
|
+
# return File.read(tempfile)
|
50
|
+
# end
|
51
|
+
puts "PARSE TEMPLATE #{template}"
|
52
|
+
File.open(tempfile, 'w') do |file|
|
53
|
+
file.puts(@data)
|
54
|
+
end
|
55
|
+
``
|
56
|
+
res = `php #{tempfile}`
|
57
|
+
puts res.to_s
|
58
|
+
res.to_s
|
41
59
|
end
|
60
|
+
|
42
61
|
end
|
43
|
-
|
44
62
|
end
|
45
63
|
end
|
46
64
|
|
data/lib/tipsy/runner.rb
CHANGED
@@ -27,8 +27,8 @@ module Tipsy
|
|
27
27
|
require 'rack'
|
28
28
|
|
29
29
|
conf = Tipsy::Site.config
|
30
|
-
missing_legacy_message
|
31
|
-
|
30
|
+
missing_legacy_message = "Rack::Legacy could not be loaded. Add it to your gemfile or set 'enable_php' to false in config.rb"
|
31
|
+
missing_rewrite_message = "Rack::Rewrite could not be loaded. Add it to your gemfile or remove 'rewrite_rules' from config.rb"
|
32
32
|
if conf.enable_php
|
33
33
|
begin
|
34
34
|
require 'rack-legacy'
|
@@ -41,6 +41,21 @@ module Tipsy
|
|
41
41
|
app = Rack::Builder.new {
|
42
42
|
use Rack::Reloader
|
43
43
|
use Rack::ShowStatus
|
44
|
+
|
45
|
+
unless conf.rewrite_rules.empty?
|
46
|
+
begin
|
47
|
+
require 'rack-rewrite'
|
48
|
+
puts "Enabling Rack Rewrite"
|
49
|
+
use Rack::Rewrite do
|
50
|
+
conf.rewrite_rules.each do |pair|
|
51
|
+
rewrite pair.first, pair.last
|
52
|
+
end
|
53
|
+
end
|
54
|
+
rescue LoadError
|
55
|
+
puts missing_rewrite_message
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
44
59
|
if conf.enable_php
|
45
60
|
begin
|
46
61
|
puts "PHP Enabled"
|
@@ -84,7 +99,7 @@ module Tipsy
|
|
84
99
|
# @usage From the command line, run `tipsy compile`
|
85
100
|
#
|
86
101
|
def compile
|
87
|
-
Tipsy::Runners::Compiler.new(args, @site)
|
102
|
+
Tipsy::Runners::Compiler.new(@args, @site)
|
88
103
|
end
|
89
104
|
|
90
105
|
|
@@ -11,14 +11,13 @@ module Tipsy
|
|
11
11
|
def initialize(args, site)
|
12
12
|
|
13
13
|
ENV['TIPSY_ENV'] = "compile"
|
14
|
-
|
15
14
|
@site = site
|
16
15
|
@source_path = normalize_path(config.public_path)
|
17
16
|
@dest_path = normalize_path(config.compile_to)
|
18
17
|
excluded = [excludes, config.compile.preserve].flatten.uniq
|
19
18
|
@_excludes = excluded
|
20
19
|
clean_existing!
|
21
|
-
|
20
|
+
requested_compilers(args).each do |m|
|
22
21
|
send(:"compile_#{m}!")
|
23
22
|
end
|
24
23
|
|
@@ -30,6 +29,19 @@ module Tipsy
|
|
30
29
|
Tipsy::Site.config
|
31
30
|
end
|
32
31
|
|
32
|
+
def requested_compilers(args)
|
33
|
+
args = [args].flatten.compact
|
34
|
+
return [:public, :images, :assets, :templates] if args.empty?
|
35
|
+
args.map!{ |a| a.to_s.strip.gsub(/^[-]+/, '') }
|
36
|
+
comps = []
|
37
|
+
comps.push('templates') if args.include?('html')
|
38
|
+
args.each do |arg|
|
39
|
+
next unless self.private_methods.include?(:"compile_#{arg.to_s}!")
|
40
|
+
comps << arg
|
41
|
+
end
|
42
|
+
comps
|
43
|
+
end
|
44
|
+
|
33
45
|
def skip_path?(src)
|
34
46
|
return false unless scope == :clean || scope == :public
|
35
47
|
end
|
data/lib/tipsy/server.rb
CHANGED
@@ -4,7 +4,7 @@ require 'hike'
|
|
4
4
|
module Tipsy
|
5
5
|
##
|
6
6
|
# Rack server implementation.
|
7
|
-
# Tipsy::Server will run any Rack::Builder compatable format. If thin or
|
7
|
+
# Tipsy::Server will run any Rack::Builder compatable format. If thin or puma
|
8
8
|
# are availble, they will be used first, and in that order, with a fallback to webrick.
|
9
9
|
#
|
10
10
|
class Server
|
@@ -26,9 +26,9 @@ module Tipsy
|
|
26
26
|
exit(0)
|
27
27
|
rescue LoadError
|
28
28
|
begin
|
29
|
-
handler = Rack::Handler.get('
|
29
|
+
handler = Rack::Handler.get('puma')
|
30
30
|
handler.run app, options do |server|
|
31
|
-
banner("
|
31
|
+
banner("Puma (#{Puma::Const::PUMA_VERSION})", options[:Port])
|
32
32
|
puts "-----------------------------------------------------------------"
|
33
33
|
puts ""
|
34
34
|
end
|
@@ -37,7 +37,7 @@ module Tipsy
|
|
37
37
|
handler = Rack::Handler.get('webrick')
|
38
38
|
handler.run app, options do |server|
|
39
39
|
banner("Webrick", options[:Port])
|
40
|
-
puts " To use
|
40
|
+
puts " To use Puma or Thin (recommended), add them to your Gemfile"
|
41
41
|
puts "-----------------------------------------------------------------"
|
42
42
|
puts ""
|
43
43
|
trap("INT"){ server.shutdown }
|
data/lib/tipsy/site.rb
CHANGED
@@ -56,10 +56,14 @@ module Tipsy
|
|
56
56
|
config.compass.http_images_path = "/#{File.basename(config.images_path)}"
|
57
57
|
config.compass.relative_assets = false
|
58
58
|
config.compass.line_comments = false
|
59
|
+
|
59
60
|
|
60
61
|
# enables php processing during development.
|
61
62
|
# at compile time, php code is left in-tact
|
62
63
|
config.enable_php = false
|
64
|
+
|
65
|
+
# enables rack-rewriting
|
66
|
+
config.rewrite_rules = []
|
63
67
|
|
64
68
|
def self.configure!
|
65
69
|
@_callbacks = { :before => [], :after => [] }
|
data/lib/tipsy/version.rb
CHANGED
data/lib/tipsy/view.rb
CHANGED
@@ -21,5 +21,5 @@ require 'tipsy/view/base'
|
|
21
21
|
require 'tipsy/view/context'
|
22
22
|
require 'tipsy/view/path'
|
23
23
|
|
24
|
-
#Tipsy::View.register_handler(Tipsy::Handler::PhpHandler, 'php
|
24
|
+
#Tipsy::View.register_handler(Tipsy::Handler::PhpHandler, 'php')
|
25
25
|
Tipsy::View.register_handler(Tipsy::Handler::ErbHandler, 'erb')
|
data/lib/tipsy/view/base.rb
CHANGED
@@ -19,10 +19,10 @@ module Tipsy
|
|
19
19
|
end
|
20
20
|
|
21
21
|
@view_context = Tipsy::View::Context.new(request, lookup_context, File.dirname(template), lookup_context)
|
22
|
-
|
23
22
|
handler = Tilt[template]
|
24
23
|
tilt = handler.new(template, nil, :outvar => '@output_buffer')
|
25
24
|
result = tilt.render(view_context)
|
25
|
+
|
26
26
|
unless view_context.layout == false
|
27
27
|
layout = lookup_context.locate_layout(view_context.layout)
|
28
28
|
raise Tipsy::View::LayoutMissing.new("Missing layout '#{view_context.layout}'") and return if layout.nil?
|
data/lib/tipsy/view/path.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tipsy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- bin/tipsy
|
188
188
|
- lib/templates/server/htaccess.erb
|
189
189
|
- lib/templates/site/Gemfile
|
190
|
+
- lib/templates/site/assets/javascripts/site.js
|
190
191
|
- lib/templates/site/assets/stylesheets/_config.css.scss
|
191
192
|
- lib/templates/site/assets/stylesheets/screen.css.scss
|
192
193
|
- lib/templates/site/compiled/.gitkeep
|
@@ -269,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
269
270
|
version: '0'
|
270
271
|
requirements: []
|
271
272
|
rubyforge_project: tipsy
|
272
|
-
rubygems_version: 1.8.
|
273
|
+
rubygems_version: 1.8.23
|
273
274
|
signing_key:
|
274
275
|
specification_version: 3
|
275
276
|
summary: A mini Rack application server for developing static sites.
|