coolstrap-generator 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. data/.DS_Store +0 -0
  2. data/.gitignore +4 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +4 -0
  5. data/Rakefile +6 -0
  6. data/bin/coolstrap +5 -0
  7. data/coolstrap-generator.gemspec +42 -0
  8. data/lib/.DS_Store +0 -0
  9. data/lib/coolstrap-generator.rb +39 -0
  10. data/lib/coolstrap-generator/.DS_Store +0 -0
  11. data/lib/coolstrap-generator/builder/middleman.rb +0 -0
  12. data/lib/coolstrap-generator/cli.rb +71 -0
  13. data/lib/coolstrap-generator/generate/project.rb +96 -0
  14. data/lib/coolstrap-generator/generate/view.rb +54 -0
  15. data/lib/coolstrap-generator/logger.rb +13 -0
  16. data/lib/coolstrap-generator/middleman/helpers.rb +176 -0
  17. data/lib/coolstrap-generator/templates/.DS_Store +0 -0
  18. data/lib/coolstrap-generator/templates/app/.DS_Store +0 -0
  19. data/lib/coolstrap-generator/templates/app/assets/.DS_Store +0 -0
  20. data/lib/coolstrap-generator/templates/app/assets/fonts/fontawesome-webfont.eot +0 -0
  21. data/lib/coolstrap-generator/templates/app/assets/fonts/fontawesome-webfont.svg +255 -0
  22. data/lib/coolstrap-generator/templates/app/assets/fonts/fontawesome-webfont.ttf +0 -0
  23. data/lib/coolstrap-generator/templates/app/assets/fonts/fontawesome-webfont.woff +0 -0
  24. data/lib/coolstrap-generator/templates/app/assets/images/.DS_Store +0 -0
  25. data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/arrow-list.png +0 -0
  26. data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/arrow.png +0 -0
  27. data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/menu.png +0 -0
  28. data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/startup/smatphone.png +0 -0
  29. data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/startup/smatphone@2x.png +0 -0
  30. data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/startup/tablet-landscape.png +0 -0
  31. data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/startup/tablet-landscape@2x.png +0 -0
  32. data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/startup/tablet-portrait.png +0 -0
  33. data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/startup/tablet-portrait@2x.png +0 -0
  34. data/lib/coolstrap-generator/templates/app/assets/images/startup/smatphone.png +0 -0
  35. data/lib/coolstrap-generator/templates/app/assets/images/startup/smatphone@2x.png +0 -0
  36. data/lib/coolstrap-generator/templates/app/assets/images/startup/tablet-landscape.png +0 -0
  37. data/lib/coolstrap-generator/templates/app/assets/images/startup/tablet-landscape@2x.png +0 -0
  38. data/lib/coolstrap-generator/templates/app/assets/images/startup/tablet-portrait.png +0 -0
  39. data/lib/coolstrap-generator/templates/app/assets/images/startup/tablet-portrait@2x.png +0 -0
  40. data/lib/coolstrap-generator/templates/app/assets/javascripts/.DS_Store +0 -0
  41. data/lib/coolstrap-generator/templates/app/assets/javascripts/app.js +18 -0
  42. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/_Coolstrap.App.coffee +39 -0
  43. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/_Coolstrap.Console.coffee +49 -0
  44. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/_Coolstrap.Constants.coffee +89 -0
  45. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/_Coolstrap.js +13 -0
  46. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/build/_wrap-start.js +18 -0
  47. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/coolstrap-0.1.js +20 -0
  48. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/coolstrap-0.1.packed.js +23 -0
  49. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/fallback/_Coolstrap.Fallback.Android.coffee +53 -0
  50. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/fallback/_Coolstrap.Fallback.iOS.coffee +29 -0
  51. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/framework/_Coolstrap.Framework.Articles.coffee +34 -0
  52. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/framework/_Coolstrap.Framework.Dialogs.coffee +33 -0
  53. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/framework/_Coolstrap.Framework.Navigation.coffee +118 -0
  54. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/framework/_Coolstrap.Framework.Sections.coffee +60 -0
  55. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/lib/iscroll.js +1076 -0
  56. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/lib/modernizr-2.5.3.js +1265 -0
  57. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/lib/zepto-1.0rc1.js +1357 -0
  58. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/navigate/_Coolstrap.Navigate.History.coffee +164 -0
  59. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/navigate/_Coolstrap.Navigate.coffee +105 -0
  60. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/plugins/_Coolstrap.Plugins.coffee +157 -0
  61. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/util/_Coolstrap.Util.Core.coffee +54 -0
  62. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/util/_Coolstrap.Util.Platform.coffee +89 -0
  63. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/util/_Coolstrap.Util.UI.coffee +96 -0
  64. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/util/_Coolstrap.Util.coffee +41 -0
  65. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/view/_Coolstrap.View.Article.coffee +43 -0
  66. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/view/_Coolstrap.View.Aside.coffee +65 -0
  67. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/view/_Coolstrap.View.Dialog.coffee +129 -0
  68. data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/view/_Coolstrap.View.Scroll.coffee +191 -0
  69. data/lib/coolstrap-generator/templates/app/assets/stylesheets/.DS_Store +0 -0
  70. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/_structure.scss +8 -0
  71. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/coolstrap.css.scss +2 -0
  72. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/_components.scss +5 -0
  73. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/_layout.scss +4 -0
  74. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/_utilities.scss +6 -0
  75. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/components/_dialog.scss +122 -0
  76. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/components/_formelements.scss +89 -0
  77. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/components/_listview.scss +76 -0
  78. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/components/_navigations.scss +192 -0
  79. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/components/_tools.scss +169 -0
  80. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/layout/_layers.scss +57 -0
  81. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/layout/_layout.scss +62 -0
  82. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/layout/_positions.scss +38 -0
  83. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/layout/_transitions.scss +35 -0
  84. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/utilities/_animate.scss +63 -0
  85. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/utilities/_helpers.scss +82 -0
  86. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/utilities/_icons.scss +336 -0
  87. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/utilities/_mixins.scss +45 -0
  88. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/utilities/_reset.scss +367 -0
  89. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/utilities/_variables.scss +176 -0
  90. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/themes/_default.scss +255 -0
  91. data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/themes/coolstrap.css.scss +164 -0
  92. data/lib/coolstrap-generator/templates/app/assets/stylesheets/customtheme.css.scss +19 -0
  93. data/lib/coolstrap-generator/templates/app/components/_formelements.html.haml +130 -0
  94. data/lib/coolstrap-generator/templates/app/components/_tabbar.html.haml +343 -0
  95. data/lib/coolstrap-generator/templates/app/components/_toolbar.html.haml +463 -0
  96. data/lib/coolstrap-generator/templates/app/components/formelements.html.haml +196 -0
  97. data/lib/coolstrap-generator/templates/app/components/listview/_complexlistavatar.html.haml.erb +77 -0
  98. data/lib/coolstrap-generator/templates/app/components/listview/_simplelist.html.haml.erb +31 -0
  99. data/lib/coolstrap-generator/templates/app/components/tabbar.html.haml.erb +16 -0
  100. data/lib/coolstrap-generator/templates/app/components/toolbar.html.haml.erb +32 -0
  101. data/lib/coolstrap-generator/templates/app/index.html.haml.erb +21 -0
  102. data/lib/coolstrap-generator/templates/app/layout.haml.erb +79 -0
  103. data/lib/coolstrap-generator/templates/app/views/.DS_Store +0 -0
  104. data/lib/coolstrap-generator/templates/app/views/_home.haml.erb +31 -0
  105. data/lib/coolstrap-generator/templates/app/views/shared/_aside_onbottom.haml +2 -0
  106. data/lib/coolstrap-generator/templates/app/views/shared/_aside_onleft.haml +56 -0
  107. data/lib/coolstrap-generator/templates/app/views/shared/_aside_onright.haml +66 -0
  108. data/lib/coolstrap-generator/templates/app/views/shared/_aside_ontop.haml +19 -0
  109. data/lib/coolstrap-generator/templates/defaults/Gemfile.erb +3 -0
  110. data/lib/coolstrap-generator/templates/defaults/LICENSE.erb +1 -0
  111. data/lib/coolstrap-generator/templates/defaults/Readme.mkd.erb +1 -0
  112. data/lib/coolstrap-generator/templates/defaults/config.erb +42 -0
  113. data/lib/coolstrap-generator/templates/defaults/gitignore.erb +2 -0
  114. data/lib/coolstrap-generator/templates/rakefile +102 -0
  115. data/lib/coolstrap-generator/templates/specs/app_spec.coffee +3 -0
  116. data/lib/coolstrap-generator/utils.rb +82 -0
  117. data/lib/coolstrap-generator/version.rb +5 -0
  118. data/readme.md +107 -0
  119. data/spec/cli/command_spec.rb +88 -0
  120. data/spec/coolstrap-generator/generate/project_spec.rb +126 -0
  121. data/spec/coolstrap-generator/generate/view_spec.rb +26 -0
  122. data/spec/coolstrap-generator/logger_spec.rb +25 -0
  123. data/spec/coolstrap-generator/middleman/helpers_spec.rb +16 -0
  124. data/spec/coolstrap-generator/utils_spec.rb +120 -0
  125. data/spec/spec_helper.rb +39 -0
  126. metadata +321 -0
Binary file
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@coolstrap-generator
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in coolstrap-generator.gemspec
4
+ gemspec
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ desc "Open an irb session preloaded with this library"
4
+ task :console do
5
+ sh "irb -rubygems -I lib -r coolstrap-generator.rb"
6
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'coolstrap-generator'
4
+
5
+ Coolstrap::Generator::CLI.start
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "coolstrap-generator/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "coolstrap-generator"
7
+ s.version = Coolstrap::Generator::VERSION
8
+ s.authors = ["Miguel Michelson"]
9
+ s.email = ["miguelmichelson@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{App Generator for coolstrap mobile framework }
12
+ s.description = %q{App Generator for coolstrap mobile framework}
13
+
14
+ s.rubyforge_project = "coolstrap-generator"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+
25
+ s.add_runtime_dependency(%q<coffee-script>, ["~> 2.2.0"])
26
+
27
+ s.add_runtime_dependency(%q<colored>, ["~> 1.2"])
28
+ s.add_runtime_dependency(%q<rake>, ["~> 0.9.2"])
29
+ s.add_runtime_dependency(%q<nokogiri>, ["~> 1.4.4"])
30
+ s.add_runtime_dependency(%q<erubis>, ["~> 2.7.0"])
31
+ s.add_runtime_dependency(%q<rocco>, ["~> 0.7"])
32
+ s.add_runtime_dependency(%q<thor>, ["~> 0.14.6"])
33
+ s.add_runtime_dependency(%q<compass>, ["~> 0.7"])
34
+ s.add_runtime_dependency(%q<session>, ["~> 3.1"])
35
+ s.add_runtime_dependency(%q<middleman>, ["~> 2.0"])
36
+ s.add_runtime_dependency(%q<actionpack> )
37
+
38
+ # s.add_development_dependency(%q<bundler>, ["~> 1.0.14"])
39
+ s.add_development_dependency(%q<bundler>, ["~> 1.1.pre.10"])
40
+ s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
41
+
42
+ end
Binary file
@@ -0,0 +1,39 @@
1
+
2
+ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'rubygems'
5
+ require 'pathname'
6
+ require 'fileutils'
7
+ require 'rbconfig'
8
+ require 'colored'
9
+ require 'rocco'
10
+ require 'thor'
11
+ require 'erubis'
12
+ require 'nokogiri'
13
+
14
+ module Coolstrap
15
+ module Generator
16
+
17
+ ROOT_PATH = Pathname(__FILE__).dirname.expand_path
18
+
19
+ autoload :VERSION, 'coolstrap-generator/version.rb'
20
+ autoload :CLI, 'coolstrap-generator/cli.rb'
21
+ autoload :Logger, "coolstrap-generator/logger.rb"
22
+ autoload :Utils, "coolstrap-generator/utils.rb"
23
+
24
+ #module Builder
25
+ # autoload :Middleman, 'coolstrap-generator/builder/middleman.rb'
26
+ #end
27
+
28
+ module Generate
29
+ autoload :Project, "coolstrap-generator/generate/project.rb"
30
+ autoload :Model, "coolstrap-generator/generate/model.rb"
31
+ autoload :View, "coolstrap-generator/generate/view.rb"
32
+ autoload :Controller, "coolstrap-generator/generate/controller.rb"
33
+ end
34
+
35
+ def self.root
36
+ @root ||= Pathname(__FILE__).dirname.expand_path
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,71 @@
1
+ module Coolstrap::Generator
2
+ class CLI < Thor
3
+ include Utils
4
+
5
+ STATUS_TYPES = {:success => 0,
6
+ :general_error => 1,
7
+ :not_supported => 3,
8
+ :not_found => 4,
9
+ :incorrect_usage => 64,
10
+ }
11
+
12
+ no_tasks {
13
+ def cli_error(message, exit_status=nil)
14
+ $stderr.puts message
15
+ exit_status = STATUS_TYPES[exit_status] if exit_status.is_a?(Symbol)
16
+ exit(exit_status || 1)
17
+ end
18
+ }
19
+
20
+ ### TODO: When these commands list grows big, we need to move them into a seperate commands.rb file
21
+ map %w(--version -v) => 'info'
22
+ desc "info", "information about Coolstrap::Generator."
23
+ def info
24
+ say "Version #{::Coolstrap::Generator::VERSION}"
25
+ end
26
+
27
+ map %(n) => 'new'
28
+ desc "new <name> ", "generates a new Coolstrap project."
29
+ long_desc "Generates a new Coolstrap project. See 'coolstrap help new' for more information.
30
+ \n\nExample:
31
+ \n\ncoolstrap new demo ==> Creates a new project skeleton."
32
+ def new(name, device_id='org.mycompany.demo', platform='iphone')
33
+ ::Coolstrap::Generator::Generate::Project.create(name, device_id, platform)
34
+ end
35
+
36
+ map %w(s) => 'scaffold'
37
+ desc "scaffold <list/complexlist/tabbar/toolbar> <domain> <name>", "generate a scaffold for Coolstrap elements."
38
+ def scaffold(cs_type, domain, name)
39
+ ::Coolstrap::Generator::Generate::View.create(name, {
40
+ :domain => domain,
41
+ :cs_type => cs_type,
42
+ :name => name })
43
+ end
44
+
45
+ map %w(g) => 'generate'
46
+ #TODO: models, bridges
47
+ desc "generate <view> <name>", "generate a view"
48
+ def generate(type, name)
49
+ case
50
+ when type =~ /view/i
51
+ ::Coolstrap::Generator::Generate::View.create(name)
52
+ end
53
+ end
54
+
55
+ map %w(r) => 'server'
56
+ desc "server ", "run middleman app"
57
+ def server
58
+ system "echo == :::COOLSTRAP STARTING::: =="
59
+ system "bundle exec middleman server"
60
+ end
61
+
62
+ map %w(b) => 'build'
63
+ system "pwd"
64
+ desc "build ", "builds middleman app"
65
+ def build
66
+ system "echo ::== COOLSTRAP BUILD =="
67
+ system "middleman build"
68
+ end
69
+
70
+ end
71
+ end
@@ -0,0 +1,96 @@
1
+ require 'session'
2
+ module Coolstrap
3
+ module Generator
4
+ module Generate
5
+ class Project
6
+ class << self
7
+ attr_accessor :project_name, :device_platform, :app_id
8
+ include ::Coolstrap::Generator::Utils
9
+
10
+ # Coolstrap::Generator::Generate::Project.create('demo', 'org.codewranglers.demo', 'ipad')
11
+ def create(name, id, platform='iphone')
12
+ @project_name = name
13
+ @device_platform = platform
14
+ @app_id = id
15
+
16
+ begin
17
+ create_directories('tmp')
18
+ copy_defaults
19
+ remove_old_files
20
+ generate_files
21
+ log "Your Coolstrap project is ready for you to get coding!"
22
+ rescue => e
23
+ error "There was an error generating your Coolstrap project. #{e} #{e.backtrace}"
24
+ end
25
+ end
26
+
27
+
28
+ def copy_defaults
29
+ #FileUtils.cp(location.join("Resources/KS_nav_ui.png"), "/tmp/")
30
+ #FileUtils.cp(location.join("Resources/KS_nav_views.png"), "/tmp/")
31
+ end
32
+
33
+
34
+ def generate_files
35
+ create_project_directory
36
+ full_app_hash = {:app_name => @project_name, :app_name_underscore => underscore(@project_name), :platform => @device_platform}
37
+ create_with_template('.gitignore', 'defaults/gitignore', full_app_hash)
38
+ create_with_template('Gemfile', 'defaults/Gemfile', full_app_hash)
39
+ create_with_template('LICENSE', 'defaults/LICENSE', full_app_hash)
40
+
41
+ create_with_template('config.rb', 'defaults/config', full_app_hash)
42
+ default_templates = ['Readme.mkd']
43
+ default_templates.each do |tempfile|
44
+ create_with_template(tempfile, "defaults/#{tempfile}", full_app_hash)
45
+ end
46
+
47
+ FileUtils.cp_r(templates("app/views/shared/."), location.join("source/views/shared") )
48
+ FileUtils.cp_r(templates("app/assets/."), location.join("source/assets") )
49
+
50
+ create_with_template('source/index.html.haml', 'app/index.html.haml', full_app_hash)
51
+ create_with_template('source/layout.haml', 'app/layout.haml', full_app_hash)
52
+ create_with_template('source/views/_home.haml', 'app/views/_home.haml', full_app_hash)
53
+
54
+ end
55
+
56
+
57
+ def create_project_directory
58
+ create_directories('docs', 'spec',
59
+ "source/assets",
60
+ "source/assets/images",
61
+ "source/assets/fonts",
62
+ "source/assets/stylesheets",
63
+ "source/assets/javascripts",
64
+ "source/views",
65
+ "source/models")
66
+ end
67
+
68
+ def remove_old_files
69
+ #remove_files('README')
70
+ #remove_directories('Resources')
71
+ end
72
+
73
+ def location
74
+ base_location.join(@project_name)
75
+ end
76
+
77
+ #TODO: generate ios bridge here
78
+ def generate_titanium_project
79
+
80
+ platform = ::Config::CONFIG['host_os']
81
+ if platform =~ /linux/i || platform =~ /darwin/i
82
+ cmd = "titanium create --name=#{@project_name} --platform=#{@device_platform} --id=#{@app_id}"
83
+ # We need to use the session gem so that we can access the user's aliases
84
+ bash = Session::Bash::new 'program' => 'bash --login -i'
85
+ bash.execute(cmd) { |out, err| puts out }
86
+ else
87
+ error("Currently, your OS (#{::Config::CONFIG['host_os']}) is not supported.")
88
+ exit(0)
89
+ end
90
+ end
91
+
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,54 @@
1
+ module Coolstrap::Generator
2
+ module Generate
3
+ class View
4
+ class << self
5
+ include ::Coolstrap::Generator::Utils
6
+
7
+ def create(name, context={})
8
+ create_view_template(name, context)
9
+ end
10
+
11
+
12
+ def create_view_template(name, context)
13
+ log "Creating #{name} view using a template."
14
+ view_directory = "source/views"
15
+ context.merge!(:name => name)
16
+ #log "#{context.inspect}"
17
+ case context[:cs_type]
18
+ when 'list'
19
+ log("HINT! to use lists you should call them with href '##{name}' & data-target = 'section', and add the partial in index.html.haml ")
20
+ template = templates("app/components/listview/_simplelist.html.haml.erb")
21
+ when 'complexlist'
22
+ log("HINT! to use lists you should call them with href '##{name}' & data-target = 'section', and add the partial in index.html.haml ")
23
+ template = templates("app/components/listview/_complexlistavatar.html.haml.erb")
24
+ when 'tabbar'
25
+ view_directory = "source/views/tabbars"
26
+ log("HINT! tabbar partial generated, you could put partial in some header or footer element' ")
27
+ template = templates("app/components/tabbar.html.haml.erb")
28
+ when 'toolbar'
29
+ view_directory = "source/views/toolbars"
30
+ log("HINT! toolbar partial generated!, you could put partial in some header or footer element' ")
31
+ template = templates("app/components/toolbar.html.haml.erb")
32
+ else
33
+ log("HINT! to use lists you should call them with href '##{name}' & data-target = 'section', and add the partial in index.html.haml ")
34
+ template = templates("app/components/listview/_complexlistavatar.html.haml.erb")
35
+ end
36
+
37
+ payload = Pathname.new("#{view_directory}/#{(context[:domain] || '').downcase}")
38
+ contents = Erubis::Eruby.new(File.read(template)).result(context) if template
39
+
40
+ create_directories(payload) unless File.directory?(payload)
41
+ create_directories("spec/views") unless File.directory?("spec/views")
42
+
43
+ filename = payload.join("_#{name.downcase}.haml")
44
+ File.open(location.join(filename), 'w') { |f| f.write(contents) }
45
+
46
+ #create_new_file("spec/views/#{name}_spec.coffee", templates("specs/app_spec.coffee"))
47
+ #create_new_file("app/#{underscore(app_name)}/stylesheets/_#{(context[:domain] || '').downcase}.sass", templates("app/stylesheets/sample.sass"))
48
+ #append_to_router(context[:domain].capitalize, 'views')
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,13 @@
1
+ module Coolstrap::Generator
2
+ class Logger
3
+
4
+ def self.report(msg)
5
+ $stdout.puts(msg.green.bold)
6
+ end
7
+
8
+ def self.error(msg)
9
+ $stderr.puts(msg.red.bold)
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,176 @@
1
+ require "middleman"
2
+ require 'action_view'
3
+
4
+ module Middleman::Features::Helpers
5
+
6
+ class << self
7
+ def registered(app)
8
+ app.helpers HelperMethods
9
+ end
10
+ alias :included :registered
11
+ end
12
+
13
+ module HelperMethods
14
+
15
+ #TODO separate elements in specific classes:
16
+ # views, asides, articles, header, tabbar, toolbar etc...
17
+
18
+ def footer(opts={}, &block)
19
+ content_tag :footer , opts do
20
+ capture(&block)
21
+ end
22
+ end
23
+
24
+ def article(opts={}, &block)
25
+ content_tag :article , opts do
26
+ capture(&block)
27
+ end
28
+ end
29
+
30
+ def section(opts={}, &block)
31
+ content_tag :section , opts do
32
+ capture(&block)
33
+ end
34
+ end
35
+
36
+ def header(opts={}, &block)
37
+ content_tag :header , opts do
38
+ capture(&block)
39
+ end
40
+ end
41
+
42
+ def hgroup(opts={}, &block)
43
+ if block_given?
44
+ content_tag :hgroup, options do
45
+ capture(&block)
46
+ end
47
+ else
48
+ content_tag :hgroup do
49
+ content_tag( :h1 , opts[:title]).concat(
50
+ content_tag( :h2 , opts[:subtitle])
51
+ )
52
+ end
53
+ end
54
+ end
55
+
56
+ def list_view(opts={}, &block)
57
+ options = {:class=>opts[:class]}.merge({"data-type" => "listview"})
58
+ content_tag :ul, options do
59
+ capture(&block)
60
+ end
61
+ end
62
+
63
+ def list_item(opts={}, &block)
64
+ options = {:class=>opts[:class]}
65
+ options = options.merge({ :class=> "#{options[:class]} list-divider"}) if opts[:divider] == true
66
+ arrow = content_tag :div , :class=>"aside" do
67
+ content_tag( :i, "",{:class=>"icon-chevron-#{opts[:arrow]}"})
68
+ end if opts[:arrow].present?
69
+
70
+ if block_given?
71
+ content_tag :li, options do
72
+ capture(&block) << (arrow || "")
73
+ end
74
+ else
75
+ content_tag :li, options do
76
+ content_tag :h1 do
77
+ opts[:content]
78
+ end
79
+ end
80
+ end
81
+ end
82
+
83
+ def divider(opts={}, &block)
84
+ if block_given?
85
+ list_item({:divider=>true}.merge(opts)) do
86
+ capture(&block)
87
+ end
88
+ else
89
+ list_item({:divider=>true}.merge(opts))
90
+ end
91
+ end
92
+
93
+ def nav(opts={}, &block)
94
+ if block_given?
95
+ content_tag(:nav, opts) do
96
+ capture(&block)
97
+ end
98
+ else
99
+ end
100
+ end
101
+
102
+ def tabbar(opts={}, &block)
103
+ opts = opts.merge({"data-type" => "tabbar"})
104
+ nav(opts, &block)
105
+ end
106
+
107
+ def toolbar(opts={}, &block)
108
+ opts = opts.merge({"data-type" => "toolbar"})
109
+ if opts[:control]
110
+ auto = opts[:auto] ? "autoWidth" : ""
111
+ nav(opts.reject!{ |k| k == :control || k == :auto }) do
112
+ content_tag(:div, :class=>"control-group #{auto}") do
113
+ capture(&block)
114
+ end
115
+ end
116
+ else
117
+ nav(opts, &block)
118
+ end
119
+ end
120
+
121
+ def icon(type, opts={}, &block)
122
+ if block_given?
123
+ capture(&block) <<
124
+ content_tag( :i, "",{:class=>"icon-#{type}"})
125
+ else
126
+ name = opts[:text].present? ? content_tag( :span, opts[:text]) : ""
127
+ name <<
128
+ content_tag( :i, "",{:class=>"icon-#{type}"})
129
+ end
130
+ end
131
+
132
+ def render_tabbar(tabbar)
133
+ partial("views/tabbars/#{tabbar}")
134
+ end
135
+
136
+ def render_toolbar(tabbar)
137
+ partial("views/toolbars/#{tabbar}")
138
+ end
139
+
140
+ # dont use action view helpers, middleman already use padrino helpers :)
141
+ # https://github.com/middleman/middleman/blob/master/middleman-more/lib/middleman-more/core_extensions/default_helpers.rb
142
+ =begin
143
+ include ActionView::Helpers::DateHelper
144
+ include ActionView::Helpers::TagHelper
145
+ #include ActionView::Helpers::NumberHelper
146
+ include ActionView::Helpers::UrlHelper
147
+
148
+ module ActionView::Helpers::UrlHelper
149
+ # Returns the URL for the set of +options+ provided. See the valid options in link:classes/ActionController/Base.html#M000021
150
+ def url_for(options = {}, *parameters_for_method_reference)
151
+ if Hash === options then options = { :only_path => true }.merge(options) end
152
+ puts options
153
+ puts *parameters_for_method_reference
154
+ end
155
+ end
156
+
157
+ def time_ago_in_words(num)
158
+ #puts ActionView::Helpers::DateHelper.instance_methods
159
+ #ActionView::Helpers::DateHelper.send( "distance_of_time_in_words", Time.now)
160
+ end
161
+ =end
162
+
163
+ =begin
164
+ def link_to(*args, &block)
165
+ if block_given?
166
+ options = args.first || {}
167
+ html_options = args.second
168
+ link_to(capture(&block), options, html_options)
169
+ else
170
+ name = args[0]
171
+ options = args[1] || {}
172
+ html_options = args[2]
173
+ =end
174
+
175
+ end
176
+ end