chrome_packager 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +79 -0
- data/bin/chrome-packager +19 -0
- data/chrome_packager.gemspec +1 -1
- data/lib/chrome_packager/application.rb +12 -0
- data/lib/chrome_packager/version.rb +1 -1
- data/lib/templates/index.haml +2 -2
- metadata +2 -1
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Chrome packager: a simple tool to create chrome packaged applications
|
2
|
+
|
3
|
+
Don't you know what a chrome packaged application is? [read this first](http://developer.chrome.com/trunk/apps/about_apps.html).
|
4
|
+
|
5
|
+
Chrome packager brings all the goodness of the [Rails asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html) but without Rails, this is intended to write pure javascript applications.
|
6
|
+
|
7
|
+
What you can do with chrome packager:
|
8
|
+
|
9
|
+
- Write your apps as if you were writing it in the Rails asset pipeline
|
10
|
+
- Write your app with coffescript
|
11
|
+
- Write your stylesheets using sass
|
12
|
+
- Write your templates with hamljs(This is fixed now, but in the future you'll be able to use any sprockets compatible template engine)
|
13
|
+
- Once your app is ready, you can pack it with one command
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Install chrome packager form RubyGems:
|
18
|
+
|
19
|
+
gem install chrome_packager
|
20
|
+
|
21
|
+
## Creating a new application
|
22
|
+
|
23
|
+
Once you have installed the gem:
|
24
|
+
|
25
|
+
chrome-packager new [your app name]
|
26
|
+
|
27
|
+
You'll have the following file structure
|
28
|
+
|
29
|
+
-app
|
30
|
+
-assets
|
31
|
+
-javascripts
|
32
|
+
- application.js
|
33
|
+
-stylesheets
|
34
|
+
- application.css
|
35
|
+
-views
|
36
|
+
- index.haml
|
37
|
+
- background.js
|
38
|
+
- manifest.json
|
39
|
+
- config.ru
|
40
|
+
- Gemfile
|
41
|
+
- Gemfile.lock
|
42
|
+
|
43
|
+
Start writing your application, application.js and application.css are manifest files, you can use the [sprockets directive processor](https://github.com/sstephenson/sprockets#the-directive-processor) here, so you can manage your dependencies easily.
|
44
|
+
|
45
|
+
You must write your basic html inside the app/views/index.haml file, this is supposed to be a single page application so you don't need more files, all the markup should be inside javascript templates.
|
46
|
+
|
47
|
+
You'll also want to modify the [manifest.json](http://developer.chrome.com/trunk/apps/manifest.html) and [background.js](http://developer.chrome.com/trunk/apps/app_lifecycle.html) file to fix your needs.
|
48
|
+
|
49
|
+
## Running the application
|
50
|
+
|
51
|
+
Chrome packager creates a rack application, you only need to run this command:
|
52
|
+
|
53
|
+
rackup
|
54
|
+
|
55
|
+
After this, your application should be running in the 9292 port, now you can open it in your browser with the following url:
|
56
|
+
|
57
|
+
http://localhost:9292/
|
58
|
+
|
59
|
+
## Packing
|
60
|
+
|
61
|
+
Once you are done with your app or you want to try it as a chrome app, you have to pack it. Run the following command in the root of your app:
|
62
|
+
|
63
|
+
chrome-packager pack
|
64
|
+
|
65
|
+
This command will compile all your javascripts and css's and will put them in the packaged dir.
|
66
|
+
|
67
|
+
After this just follow [this instructions](http://developer.chrome.com/trunk/apps/first_app.html#five) and point chrome to your app dir.
|
68
|
+
|
69
|
+
## TODO
|
70
|
+
- Compile the index.haml view to html
|
71
|
+
- Integrate [Jasmine](http://pivotal.github.com/jasmine/)
|
72
|
+
- Every config is fixed now, add way to config the app will be good
|
73
|
+
|
74
|
+
## Contributing
|
75
|
+
|
76
|
+
I made this in one night, so I'm sure there will be bugs, feel free to fork and send a pull request.
|
77
|
+
|
78
|
+
|
79
|
+
|
data/bin/chrome-packager
CHANGED
@@ -6,11 +6,24 @@ require 'haml-sprockets'
|
|
6
6
|
require 'thor/group'
|
7
7
|
require 'thor/actions'
|
8
8
|
require 'fileutils'
|
9
|
+
require 'haml'
|
9
10
|
|
10
11
|
class Generator < Thor::Group
|
11
12
|
include Thor::Actions
|
12
13
|
end
|
13
14
|
|
15
|
+
module Haml
|
16
|
+
module Helpers
|
17
|
+
def stylesheet_link_tag(asset)
|
18
|
+
"<link href='/stylesheets/#{asset}.css' media='screen' rel='stylesheet' type='text/css'>"
|
19
|
+
end
|
20
|
+
|
21
|
+
def javascript_include_tag(asset)
|
22
|
+
"<script src='/javascripts/#{asset}.js'></script>"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
14
27
|
Generator.source_root File.expand_path('../lib/templates', File.dirname(__FILE__))
|
15
28
|
|
16
29
|
def pack
|
@@ -24,6 +37,7 @@ def pack
|
|
24
37
|
environment.find_asset("#{Dir.pwd}/app/assets/javascripts/application.js").to_s
|
25
38
|
generator.create_file 'packaged/stylesheets/application.css',
|
26
39
|
environment.find_asset("#{Dir.pwd}/app/assets/javascripts/application.css").to_s
|
40
|
+
generator.create_file 'packaged/index.html', parse_index
|
27
41
|
end
|
28
42
|
|
29
43
|
def create_new_app(name)
|
@@ -45,6 +59,11 @@ def create_new_app(name)
|
|
45
59
|
end
|
46
60
|
end
|
47
61
|
|
62
|
+
def parse_index
|
63
|
+
file = File.read "#{Dir.pwd}/app/views/index.haml"
|
64
|
+
Haml::Engine.new(file).render
|
65
|
+
end
|
66
|
+
|
48
67
|
case
|
49
68
|
when ARGV[0] == 'new'
|
50
69
|
if ARGV.size == 2 && !ARGV[1].empty?
|
data/chrome_packager.gemspec
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
require 'haml'
|
2
2
|
require 'sinatra'
|
3
3
|
|
4
|
+
module Haml
|
5
|
+
module Helpers
|
6
|
+
def stylesheet_link_tag(asset)
|
7
|
+
"<link href='/assets/#{asset}.css' media='screen' rel='stylesheet' type='text/css'>"
|
8
|
+
end
|
9
|
+
|
10
|
+
def javascript_include_tag(asset)
|
11
|
+
"<script src='/assets/#{asset}.js'></script>"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
4
16
|
module ChromePackager
|
5
17
|
class Application < Sinatra::Base
|
6
18
|
set :root, 'app'
|
data/lib/templates/index.haml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
%html
|
3
3
|
%head
|
4
4
|
%title Chrome packaged app
|
5
|
-
|
6
|
-
|
5
|
+
= javascript_include_tag 'application'
|
6
|
+
= stylesheet_link_tag 'application'
|
7
7
|
%body
|
8
8
|
%h1 Hello world
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chrome_packager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -132,6 +132,7 @@ extra_rdoc_files: []
|
|
132
132
|
files:
|
133
133
|
- .gitignore
|
134
134
|
- Gemfile
|
135
|
+
- README.md
|
135
136
|
- Rakefile
|
136
137
|
- bin/chrome-packager
|
137
138
|
- chrome_packager.gemspec
|