styleyt 0.2.0
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/README.textile +52 -0
- data/Rakefile +58 -0
- data/VERSION +1 -0
- data/lib/generators/styleyt/preview_generator.rb +79 -0
- data/lib/generators/styleyt/styleyt_helper.rb +60 -0
- data/lib/generators/styleyt/theme_generator.rb +40 -0
- data/test/helper.rb +10 -0
- data/test/test_styleyt.rb +7 -0
- metadata +113 -0
data/README.textile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
h1. Styleyt
|
2
|
+
|
3
|
+
h2. Goal of the project
|
4
|
+
|
5
|
+
* A general styling who could be easily be applied to the different CyT projects.
|
6
|
+
* The styling must be theme based and be easily to change and modify.
|
7
|
+
** It must have a color theme.
|
8
|
+
** It must have a icon theme.
|
9
|
+
** It must have a look and feel theme.
|
10
|
+
|
11
|
+
h2. Realisation
|
12
|
+
|
13
|
+
* It must be usable as an rails extension.
|
14
|
+
* Installation should be installed via "rails generate styleyt:install" or "rails generate styleyt:install:[theme]"
|
15
|
+
** "rails generate styleyt:install" must be after generation configured by hand -> colors etc.
|
16
|
+
|
17
|
+
h2. Documentation
|
18
|
+
|
19
|
+
Documentation is maintained in a "Wiki":http://redmine.cyt.ch/projects/styleyt/wiki.
|
20
|
+
|
21
|
+
h2. Contributing
|
22
|
+
|
23
|
+
Code is available at "github":http://github.com/CyTeam/styleyt.
|
24
|
+
|
25
|
+
Issue tracking is done using "Redmine":http://redmine.cyt.ch/projects/mailyt/issues.
|
26
|
+
|
27
|
+
To get an idea on what we're currently focus on visit the "Roadmap":http://redmine.cyt.ch/projects/styleyt/issues.
|
28
|
+
|
29
|
+
h2. License
|
30
|
+
|
31
|
+
Read the "human-readable summary":http://creativecommons.org/licenses/GPL/2.0 to get an idea
|
32
|
+
of your right to use this software.
|
33
|
+
|
34
|
+
Copyright 2007-2010 Simon Hürlimann <simon.huerlimann@cyt.ch>
|
35
|
+
Copyright 2010 Ramon Egloff <ramon.egloff@cyt.ch>
|
36
|
+
Copyright 2010 Roman Simecek <roman.simecek@cyt.ch>
|
37
|
+
|
38
|
+
This program is free software; you can redistribute it and/or
|
39
|
+
modify it under the terms of the GNU General Public License
|
40
|
+
as published by the Free Software Foundation; either version 2
|
41
|
+
of the License, or (at your option) any later version.
|
42
|
+
|
43
|
+
This program is distributed in the hope that it will be useful,
|
44
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
45
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
46
|
+
GNU General Public License for more details.
|
47
|
+
|
48
|
+
You should have received a copy of the GNU General Public License
|
49
|
+
along with this program; if not, write to the Free Software
|
50
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
51
|
+
USA.
|
52
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "styleyt"
|
8
|
+
gem.summary = %Q{Style generator for cyt projects.}
|
9
|
+
gem.description = %Q{Generates styles for cyt projects.}
|
10
|
+
gem.email = "roman.simecek@screenconcept.ch"
|
11
|
+
gem.homepage = "http://github.com/CyTeam/styleyt"
|
12
|
+
gem.authors = ["Roman Simecek"]
|
13
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
+
gem.rubyforge_project = gem.name
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
gem.files = Dir["{lib,test}/**/*", "[A-Z]*"]
|
17
|
+
gem.require_path = 'lib'
|
18
|
+
gem.add_dependency 'rails', '3.0.0.rc'
|
19
|
+
gem.add_dependency 'haml'
|
20
|
+
end
|
21
|
+
Jeweler::GemcutterTasks.new
|
22
|
+
rescue LoadError
|
23
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'rake/testtask'
|
27
|
+
Rake::TestTask.new(:test) do |test|
|
28
|
+
test.libs << 'lib' << 'test'
|
29
|
+
test.pattern = 'test/**/test_*.rb'
|
30
|
+
test.verbose = true
|
31
|
+
end
|
32
|
+
|
33
|
+
begin
|
34
|
+
require 'rcov/rcovtask'
|
35
|
+
Rcov::RcovTask.new do |test|
|
36
|
+
test.libs << 'test'
|
37
|
+
test.pattern = 'test/**/test_*.rb'
|
38
|
+
test.verbose = true
|
39
|
+
end
|
40
|
+
rescue LoadError
|
41
|
+
task :rcov do
|
42
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
task :test => :check_dependencies
|
47
|
+
|
48
|
+
task :default => :test
|
49
|
+
|
50
|
+
require 'rake/rdoctask'
|
51
|
+
Rake::RDocTask.new do |rdoc|
|
52
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
53
|
+
|
54
|
+
rdoc.rdoc_dir = 'rdoc'
|
55
|
+
rdoc.title = "styleyt_gem #{version}"
|
56
|
+
rdoc.rdoc_files.include('README*')
|
57
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
58
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
require File.join(File.dirname(__FILE__), 'styleyt_helper')
|
3
|
+
require 'haml'
|
4
|
+
require 'compass'
|
5
|
+
|
6
|
+
module Styleyt
|
7
|
+
class PreviewGenerator < Rails::Generators::Base
|
8
|
+
|
9
|
+
include StyleytHelper
|
10
|
+
|
11
|
+
PARTIALS_DIR = 'partials/'
|
12
|
+
COMPILED_DIR_REL = '../preview/compiled/'
|
13
|
+
|
14
|
+
def self.source_root
|
15
|
+
File.join(File.dirname(__FILE__), COMPILED_PREVIEW_DIRECTORY)
|
16
|
+
end
|
17
|
+
|
18
|
+
def install
|
19
|
+
theme = ask_for_theme
|
20
|
+
generate_preview(theme)
|
21
|
+
end
|
22
|
+
|
23
|
+
no_tasks do
|
24
|
+
#
|
25
|
+
# Generates the selected theme preview
|
26
|
+
#
|
27
|
+
def generate_preview(theme)
|
28
|
+
generate_haml_preview(theme)
|
29
|
+
generate_css_preview(theme)
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Compiles the index.html of the preview and puts it in the public folder preview-#{selected theme}
|
34
|
+
#
|
35
|
+
def generate_haml_preview(theme)
|
36
|
+
Dir.chdir(File.join(File.dirname(__FILE__), PREVIEW_DIRECTORY))
|
37
|
+
Dir.glob(HAML_FILES).each { |haml|
|
38
|
+
create_file "public/preview-#{theme}/index.html" do
|
39
|
+
Haml::Engine.new(File.read(haml)).render
|
40
|
+
end
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# Compiles the css of the preview and puts it in the public folder preview-#{selected theme}
|
46
|
+
#
|
47
|
+
def generate_css_preview(theme)
|
48
|
+
prepare_sass(theme)
|
49
|
+
Dir.chdir(File.join(File.dirname(__FILE__), COMPILED_PREVIEW_DIRECTORY))
|
50
|
+
Dir.glob(SASS_FILES).each { |sass|
|
51
|
+
create_file "public/preview-#{theme}/#{remove_file_suffix(sass)}.css" do
|
52
|
+
Sass::Engine.new(File.read(sass), Compass.sass_engine_options.merge(:style => :scss)).render
|
53
|
+
end
|
54
|
+
}
|
55
|
+
clean_up_sass
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# Moves the sass temporaly to a folder for compilation
|
60
|
+
#
|
61
|
+
def prepare_sass(theme)
|
62
|
+
Dir.chdir(src_root_dir)
|
63
|
+
Dir.glob(SASS_FILES).each { |f| FileUtils.copy(f, COMPILED_DIR_REL + f) }
|
64
|
+
FileUtils.cp_r(PARTIALS_DIR, COMPILED_DIR_REL + PARTIALS_DIR)
|
65
|
+
Dir.chdir(theme_directory(theme))
|
66
|
+
Dir.glob(SASS_FILES).each { |f|
|
67
|
+
FileUtils.cp(f, '../../' + COMPILED_DIR_REL + PARTIALS_DIR + f)
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
def clean_up_sass
|
72
|
+
Dir.chdir(File.join(File.dirname(__FILE__), COMPILED_PREVIEW_DIRECTORY))
|
73
|
+
Dir.glob(SASS_FILES).each { |f| File.delete(f) }
|
74
|
+
FileUtils.rm_r(PARTIALS_DIR)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Styleyt
|
2
|
+
module StyleytHelper
|
3
|
+
|
4
|
+
#
|
5
|
+
# Path to the sass template directory
|
6
|
+
#
|
7
|
+
SASS_TEMPLATES_DIRECTORY = '../../../templates/stylesheets'
|
8
|
+
|
9
|
+
#
|
10
|
+
# Path to the preview directory
|
11
|
+
#
|
12
|
+
PREVIEW_DIRECTORY = '../../../templates/preview'
|
13
|
+
|
14
|
+
COMPILED_PREVIEW_DIRECTORY = PREVIEW_DIRECTORY + '/compiled'
|
15
|
+
|
16
|
+
HAML_FILES = '*.haml'
|
17
|
+
SASS_FILES = '*.s[c|a]ss'
|
18
|
+
|
19
|
+
#
|
20
|
+
# Asks which theme should be used.
|
21
|
+
#
|
22
|
+
def ask_for_theme
|
23
|
+
theme = ask "Available themes: #{available_themes}\nWhich theme do you like?"
|
24
|
+
theme = 'default' if theme.empty?
|
25
|
+
|
26
|
+
theme
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Returns the avaible themes
|
31
|
+
#
|
32
|
+
def available_themes
|
33
|
+
Dir.chdir(File.join(File.dirname(__FILE__), SASS_TEMPLATES_DIRECTORY, 'themes'))
|
34
|
+
themes = Dir.glob("*").inject("") {|themes, file| themes << file + ','}
|
35
|
+
|
36
|
+
themes[0..themes.length-2]
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Returns the theme directorys
|
41
|
+
#
|
42
|
+
def theme_directory(theme)
|
43
|
+
File.join(File.dirname(__FILE__), SASS_TEMPLATES_DIRECTORY, 'themes', theme)
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# Returns the source route directory
|
48
|
+
#
|
49
|
+
def src_root_dir
|
50
|
+
File.join(File.dirname(__FILE__), SASS_TEMPLATES_DIRECTORY)
|
51
|
+
end
|
52
|
+
|
53
|
+
def remove_file_suffix(file)
|
54
|
+
file = file.split('.')
|
55
|
+
|
56
|
+
file.first
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
require File.join(File.dirname(__FILE__), 'styleyt_helper')
|
3
|
+
|
4
|
+
module Styleyt
|
5
|
+
class ThemeGenerator < Rails::Generators::Base
|
6
|
+
|
7
|
+
include StyleytHelper
|
8
|
+
|
9
|
+
def self.source_root
|
10
|
+
File.join(File.dirname(__FILE__), SASS_TEMPLATES_DIRECTORY)
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "install the default layout"
|
14
|
+
def install
|
15
|
+
theme = ask_for_theme
|
16
|
+
copy_default_sass
|
17
|
+
copy_theme_sass(theme)
|
18
|
+
end
|
19
|
+
|
20
|
+
no_tasks do
|
21
|
+
#
|
22
|
+
# Copies the default sass to app/stylesheets
|
23
|
+
#
|
24
|
+
def copy_default_sass
|
25
|
+
Dir.chdir(src_root_dir)
|
26
|
+
Dir.glob(SASS_FILES).each{|file| copy_file "#{file}", "app/stylesheets/#{file}" }
|
27
|
+
directory 'partials', 'app/stylesheets/partials'
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# Copies the sass definition files of the theme
|
32
|
+
#
|
33
|
+
def copy_theme_sass(theme)
|
34
|
+
Dir.chdir(theme_directory(theme))
|
35
|
+
Dir.glob(SASS_FILES).each{|file| copy_file "themes/#{theme}/#{file}", "app/stylesheets/partials/#{file}" }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: styleyt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Roman Simecek
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-09-03 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: thoughtbot-shoulda
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :development
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rails
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - "="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 3
|
43
|
+
- 0
|
44
|
+
- 0
|
45
|
+
- rc
|
46
|
+
version: 3.0.0.rc
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: haml
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
description: Generates styles for cyt projects.
|
63
|
+
email: roman.simecek@screenconcept.ch
|
64
|
+
executables: []
|
65
|
+
|
66
|
+
extensions: []
|
67
|
+
|
68
|
+
extra_rdoc_files:
|
69
|
+
- README.textile
|
70
|
+
files:
|
71
|
+
- README.textile
|
72
|
+
- Rakefile
|
73
|
+
- VERSION
|
74
|
+
- lib/generators/styleyt/preview_generator.rb
|
75
|
+
- lib/generators/styleyt/styleyt_helper.rb
|
76
|
+
- lib/generators/styleyt/theme_generator.rb
|
77
|
+
- test/helper.rb
|
78
|
+
- test/test_styleyt.rb
|
79
|
+
has_rdoc: true
|
80
|
+
homepage: http://github.com/CyTeam/styleyt
|
81
|
+
licenses: []
|
82
|
+
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options:
|
85
|
+
- --charset=UTF-8
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
version: "0"
|
104
|
+
requirements: []
|
105
|
+
|
106
|
+
rubyforge_project: styleyt
|
107
|
+
rubygems_version: 1.3.7
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: Style generator for cyt projects.
|
111
|
+
test_files:
|
112
|
+
- test/helper.rb
|
113
|
+
- test/test_styleyt.rb
|