tonic 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile.lock +10 -17
- data/README.md +113 -28
- data/TODO.md +9 -0
- data/bin/tonic +2 -8
- data/lib/tonic.rb +20 -49
- data/lib/tonic/config.rb +0 -0
- data/lib/tonic/gh_pages.rb +71 -0
- data/lib/tonic/shell.rb +2 -0
- data/lib/tonic/template.rb +45 -0
- data/lib/tonic/version.rb +1 -1
- data/template/.tonic +0 -0
- data/template/Gemfile.lock +50 -3
- data/template/Rakefile +128 -1
- data/template/assets/coffee/application.coffee +7 -0
- data/template/assets/coffee/open_source.coffee +56 -0
- data/template/assets/images/octocat.png +0 -0
- data/template/assets/images/tonic.png +0 -0
- data/template/assets/sass/_base.sass +1 -0
- data/template/assets/sass/application.css.sass +147 -0
- data/template/assets/templates/index.html.haml +11 -0
- data/template/assets/templates/layout/layout.html.haml +36 -0
- data/tonic.gemspec +1 -1
- metadata +19 -8
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile.lock
CHANGED
@@ -2,32 +2,25 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
tonic (0.0.1)
|
5
|
-
github
|
6
5
|
|
7
6
|
GEM
|
8
7
|
remote: http://rubygems.org/
|
9
8
|
specs:
|
10
|
-
|
11
|
-
github (0.7.2)
|
12
|
-
highline (~> 1.6)
|
13
|
-
json_pure (~> 1.5.1)
|
14
|
-
launchy (~> 2.0.2)
|
15
|
-
text-format (= 1.0.0)
|
16
|
-
text-hyphen (= 1.0.0)
|
17
|
-
highline (1.6.11)
|
18
|
-
json_pure (1.5.4)
|
19
|
-
spruz (~> 0.2.8)
|
20
|
-
launchy (2.0.5)
|
21
|
-
addressable (~> 2.2.6)
|
9
|
+
diff-lcs (1.1.3)
|
22
10
|
rake (0.9.2.2)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
11
|
+
rspec (2.9.0)
|
12
|
+
rspec-core (~> 2.9.0)
|
13
|
+
rspec-expectations (~> 2.9.0)
|
14
|
+
rspec-mocks (~> 2.9.0)
|
15
|
+
rspec-core (2.9.0)
|
16
|
+
rspec-expectations (2.9.0)
|
17
|
+
diff-lcs (~> 1.1.3)
|
18
|
+
rspec-mocks (2.9.0)
|
27
19
|
|
28
20
|
PLATFORMS
|
29
21
|
ruby
|
30
22
|
|
31
23
|
DEPENDENCIES
|
32
24
|
rake
|
25
|
+
rspec
|
33
26
|
tonic!
|
data/README.md
CHANGED
@@ -1,54 +1,139 @@
|
|
1
|
-
# Tonic gem — add some tonus for your
|
1
|
+
# Tonic gem — add some tonus for your development :)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
## I tell you - this is pre-beta. There are no tests!!! Watch it but don't use it yet ;)
|
3
|
+
### This is beta now
|
6
4
|
|
7
5
|
### Build Status ![http://travis-ci.org/gazay/gon](https://secure.travis-ci.org/gazay/tonic.png)
|
8
6
|
|
9
|
-
If you want to
|
7
|
+
If you want to create your simple static application,
|
8
|
+
and want to use for that sass-compass/haml/coffee/something
|
9
|
+
THIS GEM FOR YOU
|
10
|
+
|
11
|
+
If you want to easily create custom gh-pages for your application,
|
12
|
+
and again - want to use for that the same technologies
|
13
|
+
THIS GEM TOTALY FOR YOU
|
14
|
+
|
15
|
+
## Why?
|
16
|
+
|
17
|
+
Because make html as html is too mainstream. Now you should know all
|
18
|
+
benefits of using haml, coffee and sass. And of course other template engines for
|
19
|
+
other or the same purposes. You should know and I think you love it.
|
20
|
+
|
21
|
+
And what will you do if you need to create simple, one-page application?
|
22
|
+
With static html, with not too big js and styles?
|
23
|
+
Maybe I don't know something, but you sigh maybe about your
|
24
|
+
lovely haml/sass/coffee and go to do all this stuff like in nineteens.
|
25
|
+
|
26
|
+
Because for one single page you will not to run compass, compile each coffeescript and haml file.
|
27
|
+
You just sit and write pure html/css/js.
|
28
|
+
|
29
|
+
So I thought about it a little and made this gem.
|
30
|
+
|
31
|
+
Ar first it was gem just for create gh-pages branch with some content (because I'm too lazy sometimes).
|
32
|
+
But then I decided to do more - and now it will do all stuff for you. You just need write some nice code :)
|
33
|
+
|
10
34
|
|
11
|
-
##
|
35
|
+
## How?
|
12
36
|
|
13
|
-
|
14
|
-
or you already have them and don't want to change something -
|
15
|
-
this gem not for you. Tell friends about it and forget about it until you change your mind.
|
37
|
+
This gem have two functions inside:
|
16
38
|
|
17
|
-
|
39
|
+
1. tonic-template
|
40
|
+
2. tonic for gh-pages
|
18
41
|
|
19
|
-
|
20
|
-
|
42
|
+
Tonic-template more important here, because it is that thing for easy developing!
|
43
|
+
Tonic-template uses for it's work several gems, like template engines, rake and sprockets.
|
44
|
+
Sprockets make this template look like rails assets folder.
|
21
45
|
|
22
|
-
|
23
|
-
|
24
|
-
html in html, css in css, js in js.
|
46
|
+
You don't need every time run some command in terminal or push somewhere.
|
47
|
+
You need just write `rake watch`
|
25
48
|
|
26
|
-
|
49
|
+
Tonic for gh-pages is simplier, because it uses only ruby-lang libraries like open3 and pathname,
|
50
|
+
and it's general purpose - is create new branch `gh-pages`, copy there tonic-template and run bundler.
|
27
51
|
|
28
|
-
|
29
|
-
And we don't want to create whole rake app manualy to make dreams true.
|
52
|
+
### Using tonic-template
|
30
53
|
|
31
|
-
|
54
|
+
For create template for one-page static application you need to do this:
|
32
55
|
|
33
56
|
```bash
|
34
57
|
$ gem install tonic
|
58
|
+
$ tonic new my_app
|
35
59
|
```
|
36
60
|
|
37
|
-
And
|
61
|
+
This will create for you directory with template files, gemfile and rakefile. And it will run bundler for you.
|
62
|
+
|
63
|
+
Then you can do two things:
|
64
|
+
|
65
|
+
1. build template files:
|
66
|
+
|
67
|
+
```bash
|
68
|
+
bundle exec rake build
|
69
|
+
```
|
70
|
+
|
71
|
+
2. watch your assets directory for rebuilding on changes:
|
72
|
+
|
73
|
+
```bash
|
74
|
+
bundle exec rake watch
|
75
|
+
```
|
76
|
+
|
77
|
+
Later I will add comands with tonic, but now I tired :)
|
78
|
+
And I want to add comands to open needed files from terminal.
|
79
|
+
|
80
|
+
### Using tonic for gh-pages
|
81
|
+
|
82
|
+
You should be in your repo, for which you want to create gh-pages.
|
83
|
+
You shouldn't have in this repo this branch already.
|
84
|
+
So you just run:
|
38
85
|
|
39
86
|
```bash
|
40
|
-
$
|
87
|
+
$ gem install tonic
|
41
88
|
$ tonic
|
42
89
|
```
|
43
90
|
|
44
|
-
|
45
|
-
and
|
91
|
+
It will ask you - do you really want blahblahblah. You say `y` and there is it!
|
92
|
+
Will be created branch gh-pages, then you checkout there and remove from there all files.
|
93
|
+
Then tonic will copy tonic-template to this branch and run bundle install.
|
94
|
+
|
95
|
+
Then you just work with this template like with ordinary tonic-template.
|
96
|
+
|
97
|
+
## What?
|
98
|
+
|
99
|
+
In template used next gems for make it work:
|
100
|
+
|
101
|
+
[rake](https://github.com/jimweirich/rake)
|
102
|
+
[bundler](https://github.com/carlhuda/bundler)
|
103
|
+
[uglifier](https://github.com/lautis/uglifier)
|
104
|
+
[sprockets](https://github.com/sstephenson/sprockets)
|
105
|
+
[haml](https://github.com/nex3/haml)
|
106
|
+
[compass](https://github.com/chriseppstein/compass)
|
107
|
+
|
108
|
+
Lot of code for rakefile of template and for octocat in test page
|
109
|
+
I get from one-page project of my friend @ai [easings.net](https://github.com/ai/easings.net)
|
110
|
+
|
111
|
+
## Who?
|
112
|
+
|
113
|
+
I did it myself, but use some advices of people and code from their repos:
|
114
|
+
|
115
|
+
### Contributors
|
116
|
+
|
117
|
+
* @gazay
|
118
|
+
|
119
|
+
### A lot of thanks
|
120
|
+
|
121
|
+
* @ai for his almost ready template and cool 3d transformations in [easings.net](https://github.com/ai/easings.net)
|
122
|
+
|
123
|
+
* @defunkt with his [github-gem](https://github.com/defunkt/github-gem), which I plan to use in future for do things right
|
124
|
+
and from which I get Shell class for sh command
|
125
|
+
|
126
|
+
* @brainopia for style advices
|
127
|
+
|
128
|
+
## License
|
129
|
+
|
130
|
+
The MIT License
|
131
|
+
|
132
|
+
Copyright (c) 2012 gazay
|
46
133
|
|
47
|
-
|
134
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
48
135
|
|
49
|
-
|
136
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
50
137
|
|
51
|
-
|
138
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
52
139
|
|
53
|
-
If you in development mode - run :watch and look at your files in public directory,
|
54
|
-
how they change when you change templates.
|
data/TODO.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Here is TODOs and plans for future features:
|
2
|
+
|
3
|
+
1. SPECS
|
4
|
+
2. Need to deal with different templates with Tilt
|
5
|
+
3. Add checkings everywhere, where executed dangerous code like `rm` or `git checkout`
|
6
|
+
4. Add config file implementation through dot files `.tonic` and `.tonic_global` (or just `.tonic` in `~`)
|
7
|
+
5. Think about replace Shell with just backquotes - works almoust the same for my purposes, but lightweight
|
8
|
+
6. Deal with template files. Maybe another branch? Or directory. dunno
|
9
|
+
7. Draw some more nice instead of my tonic gh-page XD
|
data/bin/tonic
CHANGED
@@ -1,12 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift lib_dir if File.directory?(lib_dir)
|
5
|
-
|
3
|
+
require 'rubygems'
|
6
4
|
require 'tonic'
|
7
5
|
|
8
|
-
|
9
|
-
Tonic.activate
|
10
|
-
else ARGV.first == 'push'
|
11
|
-
Tonic.push_pages
|
12
|
-
end
|
6
|
+
Tonic.activate ARGV
|
data/lib/tonic.rb
CHANGED
@@ -1,64 +1,35 @@
|
|
1
|
-
require '
|
1
|
+
require 'tonic/gh_pages.rb'
|
2
|
+
require 'tonic/template'
|
3
|
+
require 'tonic/shell'
|
4
|
+
require 'tonic/config'
|
2
5
|
|
3
6
|
module Tonic
|
4
7
|
class << self
|
5
8
|
|
6
|
-
def activate
|
7
|
-
|
8
|
-
if branch_exists?
|
9
|
-
raise 'You shall no pass. First you should delete gh-pages branch'
|
10
|
-
end
|
11
|
-
|
12
|
-
create_branch
|
13
|
-
remove_all_files
|
14
|
-
copy_template
|
15
|
-
commit_changes
|
16
|
-
end
|
17
|
-
|
18
|
-
def push_pages
|
19
|
-
raise "I told you - it's not working yet. Bear a little patience"
|
20
|
-
if in_gh_pages_branch?
|
21
|
-
sh 'git push -f origin gh-pages'
|
22
|
-
else
|
23
|
-
puts 'Forget about it bro'
|
24
|
-
end
|
9
|
+
def activate(args)
|
10
|
+
deal_with_args(args)
|
25
11
|
end
|
26
12
|
|
27
13
|
private
|
28
14
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
# TODO: Later I will think about how to do it through github-gem properly
|
40
|
-
def create_branch
|
41
|
-
sh 'git branch gh-pages'
|
42
|
-
sh 'git checkout gh-pages'
|
43
|
-
end
|
44
|
-
|
45
|
-
def remove_all_files
|
46
|
-
sh 'rm -rf ./*'
|
47
|
-
end
|
48
|
-
|
49
|
-
def commit_changes
|
50
|
-
sh "git add ."
|
51
|
-
sh "git commit -am 'Init github pages'"
|
15
|
+
def deal_with_args(args)
|
16
|
+
if args.empty?
|
17
|
+
Tonic::GhPages.activate
|
18
|
+
elsif want_to_create?(args)
|
19
|
+
Tonic::Template.create args[1]
|
20
|
+
elsif want_to_push?(args)
|
21
|
+
Tonic::GhPages.push_pages
|
22
|
+
else
|
23
|
+
raise ArgumentError.new 'Strange argument you sent to tonic'
|
24
|
+
end
|
52
25
|
end
|
53
26
|
|
54
|
-
def
|
55
|
-
|
56
|
-
puts path
|
57
|
-
sh "cp -r #{path}/* ./"
|
27
|
+
def want_to_create?(args)
|
28
|
+
args.size == 2 and args.first == 'new'
|
58
29
|
end
|
59
30
|
|
60
|
-
def
|
61
|
-
|
31
|
+
def want_to_push?(args)
|
32
|
+
args[0] == 'push'
|
62
33
|
end
|
63
34
|
|
64
35
|
end
|
data/lib/tonic/config.rb
ADDED
File without changes
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Tonic
|
2
|
+
module GhPages
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def activate
|
6
|
+
gh_pages
|
7
|
+
end
|
8
|
+
|
9
|
+
def push_pages
|
10
|
+
if in_gh_pages_branch?
|
11
|
+
exec 'git push -f origin gh-pages'
|
12
|
+
else
|
13
|
+
puts 'Forget about it bro'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def in_gh_pages_branch?
|
20
|
+
branches = sh('git branch')
|
21
|
+
branches.lines.any? { |it| it =~ /\* gh-pages/ }
|
22
|
+
end
|
23
|
+
|
24
|
+
def gh_pages
|
25
|
+
if branch_exists?
|
26
|
+
abort 'You shall no pass. First you should delete gh-pages branch'
|
27
|
+
end
|
28
|
+
|
29
|
+
puts 'Do you really want to create gh-pages branch with tonic? [y/n]'
|
30
|
+
if gets.chomp =~ /y/i
|
31
|
+
check_status
|
32
|
+
create_branch
|
33
|
+
remove_all_files
|
34
|
+
Template.create
|
35
|
+
commit_changes
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def branch_exists?
|
40
|
+
branches = sh('git branch')
|
41
|
+
branches.lines.any? { |it| it =~ /gh-pages/ }
|
42
|
+
end
|
43
|
+
|
44
|
+
def check_status
|
45
|
+
unless sh('git status -s').to_s.empty?
|
46
|
+
abort "You have uncommited changes. I don't want to you to loose it."
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# TODO: Later I will think about how to do it through github-gem properly
|
51
|
+
def create_branch
|
52
|
+
sh 'git branch gh-pages'
|
53
|
+
sh 'git checkout gh-pages'
|
54
|
+
end
|
55
|
+
|
56
|
+
def remove_all_files
|
57
|
+
sh 'rm -rf ./*'
|
58
|
+
end
|
59
|
+
|
60
|
+
def commit_changes
|
61
|
+
sh "git add ."
|
62
|
+
sh "git commit -am 'Init github pages'"
|
63
|
+
end
|
64
|
+
|
65
|
+
def sh(*command)
|
66
|
+
Tonic::Shell.run(*command)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/tonic/shell.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
module Tonic
|
2
|
+
module Template
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def create(name = "")
|
6
|
+
if name.empty?
|
7
|
+
copy_template
|
8
|
+
else
|
9
|
+
sh "mkdir #{name}"
|
10
|
+
copy_template(name)
|
11
|
+
end
|
12
|
+
|
13
|
+
log_files
|
14
|
+
bundle_install(name)
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def copy_template(new_path = "")
|
20
|
+
path = File.expand_path('../../../template', __FILE__)
|
21
|
+
puts path
|
22
|
+
sh "cp #{path}/.* ./#{new_path}"
|
23
|
+
sh "cp -r #{path}/* ./#{new_path}"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def sh(*command)
|
29
|
+
Tonic::Shell.run(*command)
|
30
|
+
end
|
31
|
+
|
32
|
+
def log_files
|
33
|
+
puts 'Created files:'
|
34
|
+
Dir[File.expand_path '../../../template/**/*', __FILE__].each {|it| puts it }
|
35
|
+
end
|
36
|
+
|
37
|
+
def bundle_install(name = "")
|
38
|
+
puts 'Running bundle install'
|
39
|
+
sh "cd ./#{name}"
|
40
|
+
sh "bundle install"
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/tonic/version.rb
CHANGED
data/template/.tonic
ADDED
File without changes
|
data/template/Gemfile.lock
CHANGED
@@ -1,4 +1,51 @@
|
|
1
|
-
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
chunky_png (1.2.5)
|
5
|
+
coffee-script (2.2.0)
|
6
|
+
coffee-script-source
|
7
|
+
execjs
|
8
|
+
coffee-script-source (1.2.0)
|
9
|
+
compass (0.12.1)
|
10
|
+
chunky_png (~> 1.2)
|
11
|
+
fssm (>= 0.2.7)
|
12
|
+
sass (~> 3.1)
|
13
|
+
execjs (1.3.0)
|
14
|
+
multi_json (~> 1.0)
|
15
|
+
fssm (0.2.8.1)
|
16
|
+
haml (3.1.4)
|
17
|
+
hike (1.2.1)
|
18
|
+
libv8 (3.3.10.4)
|
19
|
+
multi_json (1.2.0)
|
20
|
+
rack (1.4.1)
|
21
|
+
rake (0.9.2.2)
|
22
|
+
sass (3.1.15)
|
23
|
+
slim (1.2.0)
|
24
|
+
temple (~> 0.4.0)
|
25
|
+
tilt (~> 1.3.3)
|
26
|
+
sprockets (2.4.0)
|
27
|
+
hike (~> 1.2)
|
28
|
+
multi_json (~> 1.0)
|
29
|
+
rack (~> 1.0)
|
30
|
+
tilt (~> 1.1, != 1.3.0)
|
31
|
+
temple (0.4.0)
|
32
|
+
therubyracer (0.10.0)
|
33
|
+
libv8 (~> 3.3.10)
|
34
|
+
tilt (1.3.3)
|
35
|
+
uglifier (1.2.4)
|
36
|
+
execjs (>= 0.3.0)
|
37
|
+
multi_json (>= 1.0.2)
|
2
38
|
|
3
|
-
|
4
|
-
|
39
|
+
PLATFORMS
|
40
|
+
ruby
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
coffee-script
|
44
|
+
compass
|
45
|
+
fssm
|
46
|
+
haml
|
47
|
+
rake
|
48
|
+
slim
|
49
|
+
sprockets
|
50
|
+
therubyracer
|
51
|
+
uglifier
|
data/template/Rakefile
CHANGED
@@ -1,9 +1,136 @@
|
|
1
|
+
# Most of all of this code from @ai (Andrey Sitnik) one-page site engine
|
2
|
+
# https://github.com/ai/easings.net
|
3
|
+
|
1
4
|
require 'rubygems'
|
5
|
+
require 'pathname'
|
2
6
|
require 'rake'
|
3
7
|
require 'bundler'
|
4
|
-
|
8
|
+
require 'uglifier'
|
9
|
+
require 'sprockets'
|
10
|
+
require 'haml'
|
11
|
+
|
12
|
+
require 'compass'
|
13
|
+
|
14
|
+
ROOT = Pathname(__FILE__).dirname
|
15
|
+
COMPILED_PATHS = {
|
16
|
+
# TODO: Here we need configurable params
|
17
|
+
:img => ROOT.join('images/'),
|
18
|
+
:js => ROOT.join('javascripts/'),
|
19
|
+
:html => ROOT,
|
20
|
+
:css => ROOT.join('stylesheets/')
|
21
|
+
}
|
22
|
+
|
23
|
+
ASSETS_ROOT = ROOT.join('assets/')
|
24
|
+
TEMPLATE_PATHS = {
|
25
|
+
:coffee => ASSETS_ROOT.join('coffee/'),
|
26
|
+
:templates => ASSETS_ROOT.join('templates/'),
|
27
|
+
:layout => ASSETS_ROOT.join('templates/layout/'),
|
28
|
+
:sass => ASSETS_ROOT.join('sass/'),
|
29
|
+
:images => ASSETS_ROOT.join('images/')
|
30
|
+
}
|
31
|
+
|
32
|
+
Compass.configuration.images_path = TEMPLATE_PATHS[:images].to_s
|
33
|
+
|
34
|
+
class Pathname
|
35
|
+
def glob(pattern, &block)
|
36
|
+
Pathname.glob(self.join(pattern), &block)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Helper
|
41
|
+
|
42
|
+
attr_accessor :path
|
43
|
+
|
44
|
+
def initialize(env)
|
45
|
+
@env = env
|
46
|
+
end
|
47
|
+
|
48
|
+
def assets
|
49
|
+
@sprockets ||= begin
|
50
|
+
Sprockets::Environment.new(ROOT) do |env|
|
51
|
+
TEMPLATE_PATHS.values.each { |it| env.append_path it }
|
52
|
+
|
53
|
+
compass = Gem.loaded_specs['compass'].full_gem_path
|
54
|
+
env.append_path("#{compass}/frameworks/compass/stylesheets")
|
55
|
+
|
56
|
+
if @env == :production
|
57
|
+
env.js_compressor = Uglifier.new(copyright: false)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def render(haml, &block)
|
64
|
+
options = { format: :html5 }
|
65
|
+
options[:ugly] = true if @env == :production
|
66
|
+
Haml::Engine.new(haml, options).render(self, &block)
|
67
|
+
end
|
68
|
+
|
69
|
+
def production?
|
70
|
+
@env == :production
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
environment = nil
|
76
|
+
|
77
|
+
desc 'Build all assets'
|
78
|
+
task :build do |t, args|
|
79
|
+
environment ||= :production
|
80
|
+
|
81
|
+
puts 'build'
|
82
|
+
|
83
|
+
layout = TEMPLATE_PATHS[:layout].join('layout.html.haml').read
|
84
|
+
|
85
|
+
helper = Helper.new environment
|
86
|
+
|
87
|
+
TEMPLATE_PATHS[:templates].glob('**/*.html.haml') do |template|
|
88
|
+
next if template.basename.to_s == 'layout.html.haml'
|
89
|
+
|
90
|
+
path = template.
|
91
|
+
relative_path_from(TEMPLATE_PATHS[:templates]).
|
92
|
+
sub_ext('').sub_ext('').to_s
|
93
|
+
file = ROOT.join(path + ".html")
|
94
|
+
|
95
|
+
helper.path = path
|
96
|
+
|
97
|
+
file.open('w') do |html|
|
98
|
+
html << helper.render(layout) { helper.render(template.read) }
|
99
|
+
end
|
100
|
+
|
101
|
+
`gzip --best -c #{file} > #{file}.gz` if helper.production?
|
102
|
+
|
103
|
+
print '.'
|
104
|
+
end
|
105
|
+
|
106
|
+
print "\n"
|
107
|
+
end
|
108
|
+
|
109
|
+
desc 'Rebuild files on every changes'
|
110
|
+
task :watch do
|
111
|
+
environment ||= :development
|
112
|
+
Rake::Task['build'].execute
|
113
|
+
|
114
|
+
def rebuild
|
115
|
+
print 're'
|
116
|
+
Rake::Task['build'].execute
|
117
|
+
rescue Exception => e
|
118
|
+
puts
|
119
|
+
puts "ERROR: #{e.message}"
|
120
|
+
end
|
121
|
+
|
122
|
+
require 'fssm'
|
123
|
+
FSSM.monitor(ASSETS_ROOT, '**/*') do
|
124
|
+
update { rebuild }
|
125
|
+
delete { rebuild }
|
126
|
+
create { rebuild }
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
### Rake tasks ###
|
5
131
|
|
6
132
|
desc 'Run all tests by default'
|
7
133
|
task :default do
|
8
134
|
system("rspec spec")
|
9
135
|
end
|
136
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
after = (ms, fn) -> setTimeout(fn, ms)
|
2
|
+
|
3
|
+
jQuery ($) ->
|
4
|
+
# Detect 3D support
|
5
|
+
|
6
|
+
prefix = 'moz' if $.browser.mozilla
|
7
|
+
prefix = 'webkit' if $.browser.webkit
|
8
|
+
prefix = 'o' if $.browser.opera
|
9
|
+
prefix = 'ms' if $.browser.msie
|
10
|
+
|
11
|
+
detect3d = ->
|
12
|
+
return true if document.body.style.MozPerspective?
|
13
|
+
return false unless window.matchMedia?
|
14
|
+
|
15
|
+
result = matchMedia("all and (transform-3d)")
|
16
|
+
return true if result.matches
|
17
|
+
matchMedia("all and (-#{prefix}-transform-3d)").matches
|
18
|
+
|
19
|
+
support3d = detect3d()
|
20
|
+
$('body').addClass(if support3d then 'transform3d' else 'transform2d')
|
21
|
+
|
22
|
+
# Open source corner animation
|
23
|
+
|
24
|
+
if support3d
|
25
|
+
corner = $('.open-source')
|
26
|
+
shadow = corner.find('.shadow')
|
27
|
+
translate = corner.find('.translate')
|
28
|
+
rotator = corner.find('.rotator')
|
29
|
+
|
30
|
+
duration = rotator.css('transition-duration')
|
31
|
+
duration ||= rotator.css("-#{prefix}-transition-duration")
|
32
|
+
duration = parseFloat(duration) * 1000
|
33
|
+
|
34
|
+
shadowing = ->
|
35
|
+
if shadow.is(':animated')
|
36
|
+
shadow.stop(true).animate(opacity: 0, (duration / 2), 'linear')
|
37
|
+
else
|
38
|
+
shadow.animate(opacity: 1, (duration / 2), 'linear').
|
39
|
+
animate(opacity: 0, (duration / 2), 'linear')
|
40
|
+
|
41
|
+
corner.mouseenter ->
|
42
|
+
shadowing()
|
43
|
+
after duration, ->
|
44
|
+
translate.addClass('show') if corner.is(':hover')
|
45
|
+
corner.mouseleave ->
|
46
|
+
shadowing()
|
47
|
+
translate.removeClass('show')
|
48
|
+
|
49
|
+
# FF backface-visibility fix
|
50
|
+
|
51
|
+
if $.browser.mozilla
|
52
|
+
back = corner.find('.text, .border')
|
53
|
+
corner.mouseenter ->
|
54
|
+
back.stop(true).delay(duration / 2).hide(1)
|
55
|
+
corner.mouseleave ->
|
56
|
+
back.stop(true).delay(duration / 2).show(1)
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
@import 'compass'
|
@@ -0,0 +1,147 @@
|
|
1
|
+
// You should replace all this content with your styles :)
|
2
|
+
// Of course you can grab from here something you like :)
|
3
|
+
|
4
|
+
@import 'base'
|
5
|
+
|
6
|
+
body
|
7
|
+
text-align: center
|
8
|
+
background: white
|
9
|
+
color: black
|
10
|
+
font-size: 16px
|
11
|
+
font-family: sans-serif
|
12
|
+
|
13
|
+
a
|
14
|
+
color: darkGray
|
15
|
+
&:hover
|
16
|
+
color: red
|
17
|
+
|
18
|
+
.tonic-logo
|
19
|
+
margin: 50px auto 0 auto
|
20
|
+
width: +image-width("tonic.png")
|
21
|
+
height: +image-height("tonic.png")
|
22
|
+
background: inline-image("tonic.png")
|
23
|
+
|
24
|
+
// Octocat corner styles
|
25
|
+
.open-source
|
26
|
+
display: block
|
27
|
+
position: absolute
|
28
|
+
width: 80px
|
29
|
+
height: 80px
|
30
|
+
top: 0
|
31
|
+
right: 0
|
32
|
+
text-decoration: none
|
33
|
+
&:active
|
34
|
+
.background
|
35
|
+
background: #ddd
|
36
|
+
.crop
|
37
|
+
position: absolute
|
38
|
+
top: 0
|
39
|
+
left: -10px
|
40
|
+
width: 90px
|
41
|
+
height: 90px
|
42
|
+
overflow: hidden
|
43
|
+
.background, .corner
|
44
|
+
position: absolute
|
45
|
+
top: -65px
|
46
|
+
left: 32px
|
47
|
+
width: 120px
|
48
|
+
height: 120px
|
49
|
+
+rotate(45deg)
|
50
|
+
.background
|
51
|
+
background: #e8e8e8
|
52
|
+
+box-shadow(rgba(0, 0, 0, 0.5) 0 -7px 7px -7px inset)
|
53
|
+
.source
|
54
|
+
position: absolute
|
55
|
+
color: black
|
56
|
+
text-shadow: white 0 1px 0
|
57
|
+
left: 40px
|
58
|
+
line-height: 1.1
|
59
|
+
code
|
60
|
+
font-size: 10px
|
61
|
+
.source-crop
|
62
|
+
position: absolute
|
63
|
+
width: 120px
|
64
|
+
height: 120px
|
65
|
+
background: white
|
66
|
+
top: 22px
|
67
|
+
left: -50px
|
68
|
+
+rotate(45deg)
|
69
|
+
.octocat
|
70
|
+
position: absolute
|
71
|
+
width: +image-width("octocat.png")
|
72
|
+
height: +image-height("octocat.png")
|
73
|
+
background: inline-image("octocat.png")
|
74
|
+
+rotate(45deg)
|
75
|
+
top: 24px
|
76
|
+
left: 43px
|
77
|
+
+box-shadow(rgba(0, 0, 0, 0.4) 0 -5px 5px -5px inset)
|
78
|
+
.corner
|
79
|
+
position: absolute
|
80
|
+
overflow: hidden
|
81
|
+
left: 21px
|
82
|
+
top: -66px
|
83
|
+
.title
|
84
|
+
position: absolute
|
85
|
+
top: 82px
|
86
|
+
left: 23px
|
87
|
+
width: 82px
|
88
|
+
height: 80px
|
89
|
+
+rotate(45deg)
|
90
|
+
background: white
|
91
|
+
+box-shadow(rgba(0, 0, 0, 0.5) 0 0 3px)
|
92
|
+
.border, .text
|
93
|
+
position: absolute
|
94
|
+
bottom: 0
|
95
|
+
width: 100%
|
96
|
+
.border
|
97
|
+
border-top: 1px dashed #999
|
98
|
+
.text
|
99
|
+
bottom: 4px
|
100
|
+
text-align: center
|
101
|
+
font-size: 12px
|
102
|
+
color: #666
|
103
|
+
padding-left: 5px
|
104
|
+
.rotator
|
105
|
+
position: absolute
|
106
|
+
width: 80px
|
107
|
+
height: 80px
|
108
|
+
left: 10px
|
109
|
+
z-index: 3
|
110
|
+
.translate
|
111
|
+
position: absolute
|
112
|
+
top: 90px
|
113
|
+
text-align: center
|
114
|
+
color: #666
|
115
|
+
font-size: 13px
|
116
|
+
opacity: 0
|
117
|
+
+transition(opacity 400ms)
|
118
|
+
&.show
|
119
|
+
opacity: 1
|
120
|
+
|
121
|
+
.transform3d
|
122
|
+
.open-source
|
123
|
+
.text, .border
|
124
|
+
+backface-visibility(hidden)
|
125
|
+
.rotator
|
126
|
+
+transition(all 600ms cubic-bezier(0.455, 0.030, 0.515, 0.955))
|
127
|
+
.shadow
|
128
|
+
position: absolute
|
129
|
+
top: 0
|
130
|
+
left: 0
|
131
|
+
right: 0
|
132
|
+
bottom: 0
|
133
|
+
background: rgba(0, 0, 0, 0.1)
|
134
|
+
opacity: 0
|
135
|
+
&:hover
|
136
|
+
.rotator
|
137
|
+
+rotate3d(1, 1, 0, 180deg)
|
138
|
+
|
139
|
+
.transform2d
|
140
|
+
.open-source
|
141
|
+
&:hover
|
142
|
+
.text, .border
|
143
|
+
display: none
|
144
|
+
.rotator
|
145
|
+
+rotate(180deg)
|
146
|
+
.translate
|
147
|
+
opacity: 1
|
@@ -0,0 +1,11 @@
|
|
1
|
+
// You should replace all this content with your styles :)
|
2
|
+
// Of course you can grab from here something you like :)
|
3
|
+
|
4
|
+
%h1
|
5
|
+
%a( href='https://github.com/gazay/tonic' ) This is tonic gem gh-page
|
6
|
+
|
7
|
+
%h2 Which was made with tonic-template: sass(with compass)/haml/coffee.
|
8
|
+
|
9
|
+
.tonic-logo
|
10
|
+
|
11
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%meta( charset="UTF-8" )
|
5
|
+
%title= "Thank you for using tonic!"
|
6
|
+
%meta( name="description" content="tonic gem gh-pages" )
|
7
|
+
%script( src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery#{production? ? '.min' : ''}.js" )
|
8
|
+
%script= assets['application.js']
|
9
|
+
%link( rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Mono" )
|
10
|
+
%style= assets['application.css']
|
11
|
+
%body
|
12
|
+
.root
|
13
|
+
= yield
|
14
|
+
|
15
|
+
// Octocat corner
|
16
|
+
%a.open-source( href="https://github.com/gazay/tonic" )
|
17
|
+
.crop
|
18
|
+
.background
|
19
|
+
%pre.source
|
20
|
+
%code
|
21
|
+
:preserve
|
22
|
+
%html
|
23
|
+
%meta( charset="UTF-8" )
|
24
|
+
%title= title
|
25
|
+
%script
|
26
|
+
.source-crop
|
27
|
+
.octocat
|
28
|
+
.rotator
|
29
|
+
.corner
|
30
|
+
.title
|
31
|
+
.shadow
|
32
|
+
.border
|
33
|
+
.text open source
|
34
|
+
.translate Help me to make this thing better!
|
35
|
+
|
36
|
+
%script= assets['action.js']
|
data/tonic.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib", "bin"]
|
21
|
-
s.add_dependency "github"
|
22
21
|
|
22
|
+
s.add_development_dependency "rspec"
|
23
23
|
s.add_development_dependency "rake"
|
24
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tonic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: &
|
15
|
+
name: rspec
|
16
|
+
requirement: &70292517141580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '0'
|
22
|
-
type: :
|
22
|
+
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70292517141580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70292517140780 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70292517140780
|
36
36
|
description: You don't need to write your github pages in html and css anymore - now
|
37
37
|
it's simple to use your favorite technologies with tonic!
|
38
38
|
email:
|
@@ -42,24 +42,35 @@ executables:
|
|
42
42
|
extensions: []
|
43
43
|
extra_rdoc_files: []
|
44
44
|
files:
|
45
|
+
- .gitignore
|
45
46
|
- .travis.yml
|
46
47
|
- Gemfile
|
47
48
|
- Gemfile.lock
|
48
49
|
- README.md
|
49
50
|
- Rakefile
|
51
|
+
- TODO.md
|
50
52
|
- bin/tonic
|
51
53
|
- lib/tonic.rb
|
54
|
+
- lib/tonic/config.rb
|
55
|
+
- lib/tonic/gh_pages.rb
|
52
56
|
- lib/tonic/shell.rb
|
57
|
+
- lib/tonic/template.rb
|
53
58
|
- lib/tonic/version.rb
|
54
59
|
- spec/tonic/fail_spec.rb
|
55
60
|
- spec/tonic/tonic_spec.rb
|
61
|
+
- template/.tonic
|
56
62
|
- template/Gemfile
|
57
63
|
- template/Gemfile.lock
|
58
64
|
- template/Rakefile
|
59
65
|
- template/assets/coffee/application.coffee
|
66
|
+
- template/assets/coffee/open_source.coffee
|
67
|
+
- template/assets/images/octocat.png
|
68
|
+
- template/assets/images/tonic.png
|
69
|
+
- template/assets/sass/_base.sass
|
60
70
|
- template/assets/sass/application.css.sass
|
61
71
|
- template/assets/templates/index.html.haml
|
62
72
|
- template/assets/templates/index.html.slim
|
73
|
+
- template/assets/templates/layout/layout.html.haml
|
63
74
|
- tonic.gemspec
|
64
75
|
homepage: https://github.com/gazay/tonic
|
65
76
|
licenses: []
|