fones 0.1.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.
Files changed (97) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/CHANGELOG.md +8 -0
  4. data/Gemfile +28 -0
  5. data/Gemfile.lock +108 -0
  6. data/LICENSE +20 -0
  7. data/README.md +61 -0
  8. data/Rakefile +54 -0
  9. data/VERSION +1 -0
  10. data/bin/fones +12 -0
  11. data/features/step_definitions/fones_steps.rb +38 -0
  12. data/features/support/env.rb +17 -0
  13. data/fones.gemspec +187 -0
  14. data/layouts/config/config.tt +19 -0
  15. data/layouts/default/css/_1030up.scss.erb +8 -0
  16. data/layouts/default/css/_1240up.scss.erb +8 -0
  17. data/layouts/default/css/_2x.scss.erb +40 -0
  18. data/layouts/default/css/_481up.scss.erb +109 -0
  19. data/layouts/default/css/_768up.scss.erb +280 -0
  20. data/layouts/default/css/_base.scss.erb +836 -0
  21. data/layouts/default/css/_grid.scss.erb +48 -0
  22. data/layouts/default/css/_header.scss.erb +18 -0
  23. data/layouts/default/css/_mixins.scss.erb +248 -0
  24. data/layouts/default/css/_normalize.scss.erb +536 -0
  25. data/layouts/default/css/_print.scss.erb +80 -0
  26. data/layouts/default/css/ie.scss.erb +52 -0
  27. data/layouts/default/css/login.scss.erb +65 -0
  28. data/layouts/default/css/style.css.scss.erb +111 -0
  29. data/layouts/default/functions/functions.php.erb +166 -0
  30. data/layouts/default/functions/library/admin.php.erb +131 -0
  31. data/layouts/default/functions/library/bones.php.erb +397 -0
  32. data/layouts/default/functions/library/custom-post-type.php.erb +122 -0
  33. data/layouts/default/functions/library/translation/README +18 -0
  34. data/layouts/default/functions/library/translation/da_DK.po +374 -0
  35. data/layouts/default/functions/library/translation/de_DE.po +385 -0
  36. data/layouts/default/functions/library/translation/default.po +372 -0
  37. data/layouts/default/functions/library/translation/es_ES.po +380 -0
  38. data/layouts/default/functions/library/translation/fr_FR.po +579 -0
  39. data/layouts/default/functions/library/translation/he_IL.po +382 -0
  40. data/layouts/default/functions/library/translation/hr.po +548 -0
  41. data/layouts/default/functions/library/translation/it_IT.po +376 -0
  42. data/layouts/default/functions/library/translation/ja.po +492 -0
  43. data/layouts/default/functions/library/translation/nb_NO.po +380 -0
  44. data/layouts/default/functions/library/translation/nl_NL.po +376 -0
  45. data/layouts/default/functions/library/translation/pl_PL.po +371 -0
  46. data/layouts/default/functions/library/translation/pt_PT.po +376 -0
  47. data/layouts/default/functions/library/translation/ru_RU.po +358 -0
  48. data/layouts/default/functions/library/translation/sv_SE.po +380 -0
  49. data/layouts/default/functions/library/translation/translation.php.erb +18 -0
  50. data/layouts/default/functions/library/translation/zh_CN.po +382 -0
  51. data/layouts/default/img/apple-icon-touch.png +0 -0
  52. data/layouts/default/img/custom-post-icon.png +0 -0
  53. data/layouts/default/img/favicon.ico +0 -0
  54. data/layouts/default/img/favicon.png +0 -0
  55. data/layouts/default/img/login-logo.png +0 -0
  56. data/layouts/default/img/nothing.gif +0 -0
  57. data/layouts/default/img/nothumb.gif +0 -0
  58. data/layouts/default/img/screenshot.png +0 -0
  59. data/layouts/default/img/win8-tile-icon.png +0 -0
  60. data/layouts/default/js/admin.js +1 -0
  61. data/layouts/default/js/libs/modernizr.custom.min.js +4 -0
  62. data/layouts/default/js/scripts.js +108 -0
  63. data/layouts/default/js/theme.js +2 -0
  64. data/layouts/default/templates/404.php.erb +43 -0
  65. data/layouts/default/templates/archive-custom_type.php.erb +73 -0
  66. data/layouts/default/templates/archive.php.erb +108 -0
  67. data/layouts/default/templates/attachment.php.erb +32 -0
  68. data/layouts/default/templates/comments.php.erb +121 -0
  69. data/layouts/default/templates/footer.php.erb +22 -0
  70. data/layouts/default/templates/header.php.erb +63 -0
  71. data/layouts/default/templates/index.php.erb +72 -0
  72. data/layouts/default/templates/page-custom.php.erb +66 -0
  73. data/layouts/default/templates/page.php.erb +60 -0
  74. data/layouts/default/templates/search.php.erb +71 -0
  75. data/layouts/default/templates/sidebar.php.erb +17 -0
  76. data/layouts/default/templates/single-custom_type.php.erb +78 -0
  77. data/layouts/default/templates/single.php.erb +61 -0
  78. data/layouts/default/templates/taxonomy-custom_cat.php.erb +87 -0
  79. data/lib/fones.rb +11 -0
  80. data/lib/forge/builder.rb +269 -0
  81. data/lib/forge/cli.rb +86 -0
  82. data/lib/forge/config.rb +61 -0
  83. data/lib/forge/engines.rb +12 -0
  84. data/lib/forge/error.rb +8 -0
  85. data/lib/forge/generator.rb +144 -0
  86. data/lib/forge/guard.rb +65 -0
  87. data/lib/forge/project.rb +162 -0
  88. data/lib/forge/version.rb +3 -0
  89. data/lib/guard/forge/assets.rb +31 -0
  90. data/lib/guard/forge/config.rb +34 -0
  91. data/lib/guard/forge/functions.rb +33 -0
  92. data/lib/guard/forge/templates.rb +28 -0
  93. data/pkg/fones-0.1.0.gem +0 -0
  94. data/spec/lib/forge/config_spec.rb +79 -0
  95. data/spec/lib/forge/project_spec.rb +34 -0
  96. data/spec/spec_helper.rb +13 -0
  97. metadata +437 -0
@@ -0,0 +1,144 @@
1
+
2
+ module Fones
3
+ class Generator
4
+ class << self
5
+ def run(project, layout='default')
6
+ generator = self.new(project, layout)
7
+ generator.run
8
+ end
9
+ end
10
+
11
+ def initialize(project, layout='default')
12
+ @project = project
13
+ @task = project.task
14
+ @layout = layout
15
+ end
16
+
17
+ def create_structure
18
+ # Create the build directory for Fones output
19
+ @task.empty_directory @project.build_path
20
+
21
+ source_paths = [
22
+ ['assets', 'img'],
23
+ ['assets', 'js', 'libs'],
24
+ ['assets', 'css'],
25
+
26
+ ['functions', 'library', 'translation'],
27
+
28
+ ['includes'],
29
+
30
+ ['templates', 'pages'],
31
+ ['templates', 'partials'],
32
+ ]
33
+
34
+ # Build out Fones structure in the source directory
35
+ source_paths.each do |path|
36
+ @task.empty_directory File.join(@project.source_path, path)
37
+ end
38
+
39
+ self
40
+ end
41
+
42
+ def copy_images
43
+ source = File.expand_path(File.join(self.layout_path, 'img'))
44
+ target = File.expand_path(File.join(@project.assets_path, 'img'))
45
+
46
+ render_directory(source, target)
47
+ end
48
+
49
+ def copy_stylesheets
50
+ source = File.expand_path(File.join(self.layout_path, 'css'))
51
+ target = File.expand_path(File.join(@project.assets_path, 'css'))
52
+
53
+ render_directory(source, target)
54
+
55
+ self
56
+ end
57
+
58
+ def copy_javascript
59
+ source = File.expand_path(File.join(self.layout_path, 'js'))
60
+ target = File.expand_path(File.join(@project.assets_path, 'js'))
61
+
62
+ render_directory(source, target)
63
+
64
+ self
65
+ end
66
+
67
+ def copy_templates
68
+ source = File.expand_path(File.join(self.layout_path, 'templates'))
69
+ target = File.expand_path(File.join(@project.source_path, 'templates'))
70
+
71
+ render_directory(source, target)
72
+
73
+ self
74
+ end
75
+
76
+ def copy_functions
77
+ source = File.expand_path(File.join(self.layout_path, 'functions'))
78
+ target = File.expand_path(File.join(@project.source_path, 'functions'))
79
+
80
+ render_directory(source, target)
81
+ end
82
+
83
+ def layout_path
84
+ @layout_path ||= File.join(Fones::ROOT, 'layouts', @layout)
85
+ end
86
+
87
+ def run
88
+ write_config
89
+ create_structure
90
+ copy_images
91
+ copy_stylesheets
92
+ copy_javascript
93
+ copy_templates
94
+ copy_functions
95
+ return self
96
+ end
97
+
98
+ def write_config
99
+ unless File.exists?(@project.global_config_file)
100
+ @task.shell.mute do
101
+ @task.create_file(@project.global_config_file) do
102
+ "# Place your global configuration values here\n# config[:livereload] = true"
103
+ end
104
+ end
105
+ end
106
+
107
+ write_template(['config', 'config.tt'], @project.config_file)
108
+
109
+ self
110
+ end
111
+
112
+ def write_template(source, target)
113
+ source = File.join(source)
114
+ template = File.expand_path(@task.find_in_source_paths((source)))
115
+ target = File.expand_path(File.join(target))
116
+
117
+ @task.create_file target do
118
+ @project.parse_erb(template)
119
+ end
120
+ end
121
+
122
+ protected
123
+ def render_directory(source, target)
124
+ Dir.glob("#{source}/**/*") do |file|
125
+ unless File.directory?(file)
126
+ source_file = file.gsub(source, '')
127
+ target_file = File.join(target, source_file)
128
+
129
+ if source_file.end_with? ".erb"
130
+ target_file = target_file.slice(0..-5)
131
+
132
+ content = @project.parse_erb(file)
133
+ else
134
+ content = File.open(file).read
135
+ end
136
+
137
+ @task.create_file target_file do
138
+ content
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,65 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+
4
+ module Fones
5
+ module Guard
6
+
7
+ class << self
8
+ attr_accessor :project, :task, :builder
9
+ end
10
+
11
+ def self.add_guard(&block)
12
+ @additional_guards ||= []
13
+ @additional_guards << block
14
+ end
15
+
16
+ def self.start(project, task, options={}, livereload={})
17
+ @project = project
18
+ @task = task
19
+ @builder = Builder.new(project)
20
+
21
+ options_hash = ""
22
+ options.each do |k, v|
23
+ options_hash << ", :#{k} => '#{v}'"
24
+ end
25
+
26
+ assets_path = @project.assets_path.gsub(/#{@project.root}\//, '')
27
+ source_path = @project.source_path.gsub(/#{@project.root}\//, '')
28
+ config_file = @project.config_file.gsub(/#{@project.root}\//, '')
29
+
30
+ guardfile_contents = %Q{
31
+ guard 'forgeconfig'#{options_hash} do
32
+ watch("#{config_file}")
33
+ end
34
+ guard 'forgeassets' do
35
+ watch(%r{#{assets_path}/js/*})
36
+ watch(%r{#{assets_path}/css/*})
37
+ watch(%r{#{assets_path}/img/*})
38
+ end
39
+ guard 'forgetemplates' do
40
+ watch(%r{#{source_path}/templates/*})
41
+ watch(%r{#{source_path}/partials/*})
42
+ end
43
+ guard 'forgefunctions' do
44
+ watch(%r{#{source_path}/functions/*})
45
+ watch(%r{#{source_path}/includes/*})
46
+ end
47
+ }
48
+
49
+ if @project.config[:livereload]
50
+ guardfile_contents << %Q{
51
+ guard 'livereload' do
52
+ watch(%r{#{source_path}/*})
53
+ end
54
+ }
55
+ end
56
+
57
+ (@additional_guards || []).each do |block|
58
+ result = block.call(options, livereload)
59
+ guardfile_contents << result unless result.nil?
60
+ end
61
+
62
+ ::Guard.start({:guardfile_contents => guardfile_contents})
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,162 @@
1
+ require 'pathname'
2
+ require 'compass'
3
+
4
+ module Fones
5
+ class Project
6
+ class << self
7
+ def create(root, config, task)
8
+ root = File.expand_path(root)
9
+
10
+ project = self.new(root, task, config)
11
+ Generator.run(project)
12
+
13
+ project
14
+ end
15
+ end
16
+
17
+ attr_accessor :root, :config, :task
18
+
19
+ def initialize(root, task, config={}, config_file=nil)
20
+ @root = File.expand_path(root)
21
+ @config = config || {}
22
+ @task = task
23
+ @config_file = config_file
24
+
25
+ self.load_config if @config.empty?
26
+ end
27
+
28
+ def assets_path
29
+ @assets_path ||= File.join(self.source_path, 'assets')
30
+ end
31
+
32
+ def build_path
33
+ File.join(self.root, '.forge', 'build')
34
+ end
35
+
36
+ def source_path
37
+ File.join(self.root, 'source')
38
+ end
39
+
40
+ def package_path
41
+ File.join(self.root, 'package')
42
+ end
43
+
44
+ def templates_path
45
+ File.join(self.source_path, 'templates')
46
+ end
47
+
48
+ def functions_path
49
+ File.join(self.source_path, 'functions')
50
+ end
51
+
52
+ def includes_path
53
+ File.join(self.source_path, 'includes')
54
+ end
55
+
56
+ def images_path
57
+ File.join(self.source_path, 'img')
58
+ end
59
+
60
+ def config_file
61
+ @config_file ||= File.join(self.root, 'config.rb')
62
+ end
63
+
64
+ def global_config_file
65
+ @global_config_file ||= File.join(ENV['HOME'], '.forge', 'config.rb')
66
+ end
67
+
68
+ # Create a symlink from source to the project build dir
69
+ def link(source)
70
+ source = File.expand_path(source)
71
+
72
+ unless File.directory?(File.dirname(source))
73
+ raise Fones::LinkSourceDirNotFound
74
+ end
75
+
76
+ @task.link_file build_path, source
77
+ end
78
+
79
+ def theme_id
80
+ File.basename(self.root).gsub(/\W/, '_')
81
+ end
82
+
83
+ def load_config
84
+ config = {}
85
+
86
+ # Check for global (user) config.rb
87
+ if File.exists?(self.global_config_file)
88
+ config.merge!(load_ruby_config(self.global_config_file))
89
+ end
90
+
91
+ # Check for config.rb
92
+ if File.exists?(self.config_file)
93
+ config.merge!(load_ruby_config(self.config_file))
94
+ else
95
+ # Old format of config file
96
+ if File.exists?(File.join(self.root, 'config.json'))
97
+ config.merge!(convert_old_config)
98
+ else
99
+ raise Error, "Could not find the config file, are you sure you're in a
100
+ forge project directory?"
101
+ end
102
+ end
103
+
104
+ @config = config
105
+ end
106
+
107
+ def get_binding
108
+ binding
109
+ end
110
+
111
+ def parse_erb(file)
112
+ ERB.new(::File.binread(file), nil, '-', '@output_buffer').result(binding)
113
+ end
114
+
115
+ private
116
+
117
+ def convert_old_config
118
+ require 'json'
119
+
120
+ # Let the user know what is going to happen
121
+ @task.say("It looks like you are using the old JSON-format config. Fones will now try converting your config to the new Ruby format.")
122
+ @task.ask(" Press any key to continue...")
123
+
124
+ begin
125
+ old_file_name = File.join(self.root, 'config.json')
126
+ # Parse the old config format, convert keys to symbols
127
+ @config = JSON.parse(File.open(old_file_name).read).inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
128
+
129
+ @task.create_file(@config_file) do
130
+ # Find the config.tt template, and parse it using ERB
131
+ config_template_path = @task.find_in_source_paths(File.join(['config', 'config.tt']))
132
+ parse_erb(File.expand_path(config_template_path))
133
+ end
134
+ rescue Exception => e
135
+ @task.say "Error while building new config file:", Thor::Shell::Color::RED
136
+ @task.say e.message, Thor::Shell::Color::RED
137
+ @task.say "You'll need to either fix the error and try again, or manually convert your config.json file to Ruby format (config.rb)"
138
+ exit
139
+ end
140
+
141
+ @task.say "Success! Double-check that all your config values were moved over, and you can now delete config.json.", Thor::Shell::Color::GREEN
142
+
143
+ # We now have a Ruby config file, so we can continue loading as normal
144
+ return load_ruby_config(self.config_file)
145
+ end
146
+
147
+ def load_ruby_config(file)
148
+ config = {}
149
+
150
+ begin
151
+ # Config file is just executed as straight ruby
152
+ eval(File.read(file))
153
+ rescue Exception => e
154
+ @task.say "Error while evaluating config file:"
155
+ @task.say e.message, Thor::Shell::Color::RED
156
+ end
157
+
158
+ return config
159
+ end
160
+
161
+ end
162
+ end
@@ -0,0 +1,3 @@
1
+ module Forge
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,31 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+
4
+ module Guard
5
+ class ForgeAssets < ::Guard::Guard
6
+
7
+ def initialize(watchers=[], options={})
8
+ super
9
+ end
10
+
11
+ def start
12
+ UI.info "Building all assets"
13
+ ::Fones::Guard.builder.build_assets
14
+ end
15
+
16
+ # Called on Ctrl-\ signal
17
+ # This method should be principally used for long action like running all specs/tests/...
18
+ def run_all
19
+ UI.info "Rebuilding all assets"
20
+ ::Fones::Guard.builder.clean_images
21
+ ::Fones::Guard.builder.build_assets
22
+ end
23
+
24
+ # Called on file(s) modifications
25
+ def run_on_change(paths)
26
+ UI.info "Assets have changed, rebuilding..."
27
+ ::Fones::Guard.builder.clean_images
28
+ ::Fones::Guard.builder.build_assets
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,34 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+
4
+ module Guard
5
+ class ForgeConfig < ::Guard::Guard
6
+ def initialize(watchers=[], options={})
7
+ super
8
+ end
9
+
10
+ # Called on Ctrl-Z signal
11
+ # This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
12
+ def reload
13
+ UI.info "Reloading project config"
14
+ ::Fones::Guard.project.load_config
15
+ end
16
+
17
+ # Called on Ctrl-\ signal
18
+ # This method should be principally used for long action like running all specs/tests/...
19
+ def run_all
20
+ UI.info "Reloading project config"
21
+ ::Fones::Guard.project.load_config
22
+ true
23
+ end
24
+
25
+ # Called on file(s) modifications
26
+ def run_on_change(paths)
27
+ UI.info "Project config changed, reloading"
28
+ ::Fones::Guard.project.load_config
29
+ ::Fones::Guard.builder = ::Fones::Builder.new(::Fones::Guard.project)
30
+ # Rebuild everything if the config changes
31
+ ::Fones::Guard.builder.build
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,33 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+
4
+ module Guard
5
+ class ForgeFunctions < ::Guard::Guard
6
+ def initialize(watchers=[], options={})
7
+ super
8
+ end
9
+
10
+ def start
11
+ UI.info "Copying functions over"
12
+ ::Fones::Guard.builder.copy_functions
13
+ ::Fones::Guard.builder.copy_includes
14
+ end
15
+
16
+ def run_all
17
+ UI.info "Rebuilding all functions"
18
+ ::Fones::Guard.builder.clean_functions
19
+ ::Fones::Guard.builder.copy_functions
20
+ ::Fones::Guard.builder.clean_includes
21
+ ::Fones::Guard.builder.copy_includes
22
+ end
23
+
24
+ # Called on file(s) modifications
25
+ def run_on_change(paths)
26
+ UI.info "Functions have changed, copying over"
27
+ ::Fones::Guard.builder.clean_functions
28
+ ::Fones::Guard.builder.copy_functions
29
+ ::Fones::Guard.builder.clean_includes
30
+ ::Fones::Guard.builder.copy_includes
31
+ end
32
+ end
33
+ end