bits2life-estyle 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,13 +1,14 @@
1
- eStyle
2
- ======
1
+ = eStyle
3
2
 
4
3
  This project is mainly to simplify my personal stylesheet management, and as
5
4
  such, I have yet to write any useful documentation. Basically, it merges css
6
5
  files from a number of directories into a single string which is displayed to
7
6
  the user. See code for further details.
8
7
 
9
- Installation
10
- ============
8
+ As an added bonus, it also does the exact same thing for Javascript files!
9
+
10
+
11
+ == Installation
11
12
 
12
13
  eStyle is only available as a GemPlugin. Use as a plugin like so:
13
14
 
@@ -16,20 +17,29 @@ eStyle is only available as a GemPlugin. Use as a plugin like so:
16
17
  Or as a gem like so:
17
18
 
18
19
  config.gem 'bits2life-estyle', :source => "http://gems.github.com", :lib => "estyle"
19
-
20
- Usage
21
- =====
20
+
21
+
22
+ == Usage
22
23
 
23
24
  First off, avoid having a controller named stylesheets, since one will be added by
24
25
  eStyle. Add a route to this controller in routes.rb
25
26
 
26
- map.resources :stylesheets
27
+ map.estyle-routes
27
28
 
28
- And then place your small, manageable stylesheets in /stylesheets. You're now done.
29
- Requesting /stylesheets/happy.css will now yield following files, merged:
29
+ Or, equivalently:
30
+
31
+ resources :styles
32
+ resources :scripts
33
+
34
+ And then place your small, manageable stylesheets in a directory of your choice. You're
35
+ now done. Requesting /styles/happy.css will now yield following files, merged:
36
+
37
+ /[style dir]/initial/*.css
38
+ /[style dir]/*.css
39
+ /[style dir]/happy/*.css
40
+
30
41
 
31
- /stylesheets/initial/*.css
32
- /stylesheets/*.css
33
- /stylesheets/happy/*.css
42
+ == Configuration
34
43
 
35
- Please note that there is currently no caching configured.
44
+ You can configure the directories by setting EStyle.script_dir and EStyle.style_dir
45
+ attributes. Default values are public/estyles and public/escripts
@@ -1,14 +1,16 @@
1
1
 
2
2
  module EStyle
3
3
 
4
- def self.build(dir, theme)
4
+ # Builds a string with the concatenation of files in the directories
5
+ # <em>dir</em>/initial, <em>dir</em> and <em>dir</em>/<em>theme</em>.
6
+ def self.build(dir, theme, ext = 'css')
5
7
  result = ""
6
8
  theme ||= 'default'
7
9
 
8
10
  [
9
- "#{dir}/initial/*.css",
10
- "#{dir}/*.css",
11
- "#{dir}/#{theme}/*.css"
11
+ "#{dir}/initial/*.#{ext}",
12
+ "#{dir}/*.#{ext}",
13
+ "#{dir}/#{theme}/*.#{ext}"
12
14
  ].each do |dir|
13
15
  Dir[dir].sort.each do |css|
14
16
  result += File.read css
data/lib/estyle.rb CHANGED
@@ -1 +1,14 @@
1
- require 'estyle/builder'
1
+ require 'estyle/builder'
2
+
3
+
4
+ module EStyle
5
+
6
+ class <<self
7
+ # The base directory used to serve scripts.
8
+ attr_accessor :script_dir
9
+
10
+ # The base directory used to serve stylesheets.
11
+ attr_accessor :style_dir
12
+ end
13
+
14
+ end
data/rails/init.rb CHANGED
@@ -1,4 +1,16 @@
1
1
  require 'estyle'
2
- require File.dirname(__FILE__) + "/controller"
2
+ require File.dirname(__FILE__) + "/scripts_controller"
3
+ require File.dirname(__FILE__) + "/styles_controller"
3
4
 
4
5
  RAILS_DEFAULT_LOGGER.info("** estyle: initialized")
6
+
7
+
8
+ module ActionController::Routing::RouteSet # :nodoc:
9
+ class Mapper
10
+ # Defines routes for styles and script resources to the eStyle controllers.
11
+ def estyle_routes
12
+ resources :styles
13
+ resources :scripts
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+
2
+ class ScriptsController < ActionController::Base
3
+
4
+ def show
5
+ script = EStyle.build((EStyle.script_dir || 'public/escripts'), params[:id], 'js')
6
+
7
+ respond_to do |format|
8
+ format.js { render :text => script }
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+
2
+ class StylesController < ActionController::Base
3
+
4
+ def show
5
+ styles = EStyle.build((EStyle.style_dir || 'public/estyles'), params[:id], 'css')
6
+
7
+ respond_to do |format|
8
+ format.css { render :text => styles }
9
+ end
10
+ end
11
+
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bits2life-estyle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Hansson
@@ -27,14 +27,20 @@ files:
27
27
  - init.rb
28
28
  - lib/estyle.rb
29
29
  - lib/estyle/builder.rb
30
- - rails/controller.rb
30
+ - rails/scripts_controller.rb
31
+ - rails/styles_controller.rb
31
32
  - rails/init.rb
32
33
  has_rdoc: true
33
34
  homepage: http://github.com/bits2life/estyle
34
35
  post_install_message:
35
36
  rdoc_options:
37
+ - --title
38
+ - eStyle -- glue for your stylesheets
36
39
  - --main
37
40
  - README
41
+ - README
42
+ - lib
43
+ - rails
38
44
  require_paths:
39
45
  - lib
40
46
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -55,6 +61,6 @@ rubyforge_project:
55
61
  rubygems_version: 1.2.0
56
62
  signing_key:
57
63
  specification_version: 2
58
- summary: Merges numerous small stylesheets into one large one.
64
+ summary: Merges numerous small stylesheets and/or javascripts into one large one.
59
65
  test_files: []
60
66
 
data/rails/controller.rb DELETED
@@ -1,12 +0,0 @@
1
-
2
- class StylesheetsController < ActionController::Base
3
-
4
- def show
5
- styles = EStyle.build 'public/stylesheets', params[:id]
6
-
7
- respond_to do |format|
8
- format.css { render :text => styles }
9
- end
10
- end
11
-
12
- end