remove the HAML option for the generators + add a generator for sections + integrate Webpack (WIP)
Didier Lafforgue
committed Jun 07, 2018
commit 4263352494cf45f910ee69083cb0a4b023198d3a
Showing 30
changed files with
360 additions
and 327 deletions
generators/blank/app/assets/.babelrc
+3
-0
| @@ | @@ -0,0 +1,3 @@ |
| + | { |
| + | "presets": ["env"] |
| + | } |
generators/blank/app/assets/fonts/.empty_directory
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | .empty_directory |
generators/blank/app/assets/javascripts/app.js
+2
-0
| @@ | @@ -0,0 +1,2 @@ |
| + | // Wagon main javascript file |
| + | import '../stylesheets/app.scss'; |
generators/blank/app/assets/package.json.tt
+35
-0
| @@ | @@ -0,0 +1,35 @@ |
| + | { |
| + | "name": "<%= config[:name] %>", |
| + | "version": "1.0.0", |
| + | "description": "Assets source for the <%= config[:name] %> website", |
| + | "main": "index.js", |
| + | "scripts": { |
| + | "start": "webpack --config webpack.dev.js --progress --colors --watch", |
| + | "build:dev": "webpack --config webpack.dev.js --progress", |
| + | "build:prod": "NODE_ENV=production webpack --config webpack.prod.js --progress", |
| + | "test": "echo \"Error: no test specified\" && exit 1" |
| + | }, |
| + | "author": "Wagon", |
| + | "license": "ISC", |
| + | "dependencies": { |
| + | }, |
| + | "devDependencies": { |
| + | "babel-core": "^6.26.3", |
| + | "babel-loader": "^7.1.4", |
| + | "babel-preset-env": "^1.7.0", |
| + | "babel-preset-es2015": "^6.24.1", |
| + | "css-loader": "^0.28.11", |
| + | "mini-css-extract-plugin": "^0.4.0", |
| + | "node-sass": "^4.9.0", |
| + | "optimize-css-assets-webpack-plugin": "^4.0.2", |
| + | "postcss-flexbugs-fixes": "^3.3.1", |
| + | "postcss-loader": "^2.1.5", |
| + | "sass-loader": "^7.0.1", |
| + | "style-loader": "^0.21.0", |
| + | "webpack": "^4.8.3", |
| + | "webpack-cli": "^2.1.3", |
| + | "webpack-merge": "^4.1.2", |
| + | "file-loader": "^1.1.11", |
| + | "image-webpack-loader": "^4.3.0" |
| + | } |
| + | } |
generators/blank/app/assets/postcss.config.js
+6
-0
| @@ | @@ -0,0 +1,6 @@ |
| + | module.exports = { |
| + | plugins: [ |
| + | require('postcss-flexbugs-fixes'), |
| + | require('autoprefixer') |
| + | ] |
| + | } |
generators/blank/app/assets/stylesheets/app.scss
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | // Wagon main stylesheet file |
generators/blank/app/assets/webpack.common.js
+47
-0
| @@ | @@ -0,0 +1,47 @@ |
| + | const path = require('path'); |
| + | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); |
| + | |
| + | module.exports = { |
| + | entry: './javascripts/app.js', |
| + | output: { |
| + | path: path.resolve(__dirname, '../../public'), |
| + | filename: 'javascripts/bundle.js' |
| + | }, |
| + | module: { |
| + | rules: [ |
| + | { |
| + | test: /\.(js|jsx|es6)$/, |
| + | exclude: /(node_modules|bower_components)/, |
| + | loader: 'babel-loader', |
| + | query: { presets: ['env'] } |
| + | }, |
| + | { |
| + | test: /\.scss$/, |
| + | use: ['style-loader', MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader'] |
| + | }, |
| + | { |
| + | test: /\.(woff2?|svg)$/, |
| + | loader: 'file-loader?name=fonts/[name].[ext]&useRelativePath=false&publicPath=../' |
| + | }, |
| + | { |
| + | test: /\.(ttf|eot|otf)$/, |
| + | loader: 'file-loader?name=fonts/[name].[ext]&useRelativePath=false&publicPath=../' |
| + | }, |
| + | { |
| + | test: /\.(gif|png|jpe?g|svg)$/i, |
| + | use: [ |
| + | { |
| + | loader: 'file-loader', options: { |
| + | outputPath: 'images/', |
| + | name: '[path][name].[ext]' |
| + | } |
| + | }, |
| + | { loader: 'image-webpack-loader', options: { bypassOnDebug: true } } |
| + | ] |
| + | } |
| + | ] |
| + | }, |
| + | plugins: [ |
| + | new MiniCssExtractPlugin({ filename: 'stylesheets/bundle.css', allChunks: true }) |
| + | ] |
| + | }; |
generators/blank/app/assets/webpack.dev.js
+7
-0
| @@ | @@ -0,0 +1,7 @@ |
| + | const merge = require('webpack-merge'); |
| + | const common = require('./webpack.common.js'); |
| + | |
| + | module.exports = merge(common, { |
| + | mode: 'development', |
| + | devtool: 'inline-source-map' |
| + | }); |
generators/blank/app/assets/webpack.prod.js
+12
-0
| @@ | @@ -0,0 +1,12 @@ |
| + | const merge = require('webpack-merge'); |
| + | const common = require('./webpack.config.js'); |
| + | const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); |
| + | |
| + | module.exports = merge(common, { |
| + | plugins: [ |
| + | new OptimizeCssAssetsPlugin({ |
| + | assetNameRegExp: /\.css$/, |
| + | cssProcessorOptions: { discardComments: { removeAll: true } } |
| + | }) |
| + | ] |
| + | }); |
generators/blank/app/views/pages/404.liquid
+1
-1
| @@ | @@ -2,7 +2,7 @@ |
| title: Page not found | |
| published: true | |
| --- | |
| - | {% extends index %} |
| + | {% extends layouts/default %} |
| {% block 'main' %} | |
generators/blank/app/views/pages/404.liquid.haml
+0
-11
| @@ | @@ -1,11 +0,0 @@ |
| - | --- |
| - | title: Page not found |
| - | published: true |
| - | --- |
| - | {% extends index %} |
| - | |
| - | {% block 'main' %} |
| - | |
| - | %p Page not found |
| - | |
| - | {% endblock %} |
generators/blank/app/views/pages/index.liquid
+7
-15
| @@ | @@ -2,18 +2,10 @@ |
| title: Home page | |
| published: true | |
| --- | |
| - | <!DOCTYPE html> |
| - | <html lang="en"> |
| - | <head> |
| - | <meta charset="utf-8"> |
| - | <title>{{ site.name }}</title> |
| - | <meta name="keywords" value="{{ site.meta_keywords }}" /> |
| - | <meta name="description" value="{{ site.meta_description }}" /> |
| - | </head> |
| - | <body> |
| - | <h1>{{ page.title }}</h1> |
| - | {% block 'main' %} |
| - | <p>Lorem ipsum....</p> |
| - | {% endblock %} |
| - | </body> |
| - | </html> |
| \ No newline at end of file | |
| + | {% extends layouts/default %} |
| + | |
| + | {% block 'main' %} |
| + | |
| + | <p>Go to app/views/pages/index.liquid to modify the home page</p> |
| + | |
| + | {% endblock %} |
generators/blank/app/views/pages/index.liquid.haml
+0
-16
| @@ | @@ -1,16 +0,0 @@ |
| - | --- |
| - | title: Home page |
| - | published: true |
| - | --- |
| - | !!! |
| - | %html{lang: "en"} |
| - | %head |
| - | %meta{charset: "utf-8"} |
| - | %title {{ site.name }} |
| - | %meta{name: "keywords", value: "{{ site.meta_keywords }}"} |
| - | %meta{name: "description", value: "{{ site.meta_description }}"} |
| - | %body |
| - | %h1 {{ page.title }} |
| - | {% block 'main' %} |
| - | %p Lorem ipsum.... |
| - | {% endblock %} |
| \ No newline at end of file | |
generators/blank/app/views/pages/layouts/default.liquid
+21
-0
| @@ | @@ -0,0 +1,21 @@ |
| + | --- |
| + | title: Default layout |
| + | is_layout: false |
| + | --- |
| + | <!DOCTYPE html> |
| + | <html lang="en"> |
| + | <head> |
| + | <meta charset="utf-8"> |
| + | <title>{{ site.name }}</title> |
| + | <meta name="keywords" value="{{ site.meta_keywords }}" /> |
| + | <meta name="description" value="{{ site.meta_description }}" /> |
| + | {{ 'bundle.css' | stylesheet_tag }} |
| + | {{ 'bundle.js' | javascript_tag }} |
| + | </head> |
| + | <body> |
| + | <h1>{{ page.title }}</h1> |
| + | |
| + | {% block 'main' %} |
| + | {% endblock %} |
| + | </body> |
| + | </html> |
generators/blank/app/views/sections/.empty_directory
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | .empty_directory |
generators/foundation/app/views/pages/404.liquid.haml
+0
-11
| @@ | @@ -1,11 +0,0 @@ |
| - | --- |
| - | title: Page not found |
| - | published: true |
| - | --- |
| - | {% extends index %} |
| - | |
| - | {% block 'main' %} |
| - | |
| - | %p Page not found |
| - | |
| - | {% endblock %} |
generators/foundation/app/views/pages/index.liquid.haml
+0
-144
| @@ | @@ -1,144 +0,0 @@ |
| - | --- |
| - | title: Home page |
| - | published: true |
| - | --- |
| - | !!! |
| - | %html.no-js{:lang => "en"} |
| - | %head |
| - | %meta{:charset => "utf-8"} |
| - | %meta{:content => "ie=edge", "http-equiv" => "x-ua-compatible"} |
| - | %meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"} |
| - | %title Foundation for Sites |
| - | {{ 'app.css' | stylesheet_tag }} |
| - | %body |
| - | .row |
| - | .large-12.columns |
| - | %h1 Welcome to Foundation |
| - | .row |
| - | .large-12.columns |
| - | .callout |
| - | %h3 We’re stoked you want to try Foundation! |
| - | %p To get going, this file (index.html) includes some basic styles you can modify, play around with, or totally destroy to get going. |
| - | %p Once you've exhausted the fun in this document, you should check out: |
| - | .row |
| - | .large-4.medium-4.columns |
| - | %p |
| - | %a{:href => "http://foundation.zurb.com/docs"} Foundation Documentation |
| - | = succeed "Everything" do |
| - | %br/ |
| - | you need to know about using the framework. |
| - | .large-4.medium-4.columns |
| - | %p |
| - | %a{:href => "http://zurb.com/university/code-skills"} Foundation Code Skills |
| - | = succeed "These" do |
| - | %br/ |
| - | online courses offer you a chance to better understand how Foundation works and how you can master it to create awesome projects. |
| - | .large-4.medium-4.columns |
| - | %p |
| - | %a{:href => "http://foundation.zurb.com/forum"} Foundation Forum |
| - | = succeed "Join" do |
| - | %br/ |
| - | the Foundation community to ask a question or show off your knowlege. |
| - | .row |
| - | .large-4.medium-4.medium-push-2.columns |
| - | %p |
| - | %a{:href => "http://github.com/zurb/foundation"} Foundation on Github |
| - | = succeed "Latest" do |
| - | %br/ |
| - | code, issue reports, feature requests and more. |
| - | .large-4.medium-4.medium-pull-2.columns |
| - | %p |
| - | %a{:href => "https://twitter.com/ZURBfoundation"} @zurbfoundation |
| - | = succeed "Ping" do |
| - | %br/ |
| - | us on Twitter if you have questions. When you build something with this we'd love to see it (and send you a totally boss sticker). |
| - | .row |
| - | .large-8.medium-8.columns |
| - | %h5 Here’s your basic grid: |
| - | / Grid Example |
| - | .row |
| - | .large-12.columns |
| - | .primary.callout |
| - | %p |
| - | %strong This is a twelve column section in a row. |
| - | Each of these includes a div.callout element so you can see where the columns are - it's not required at all for the grid. |
| - | .row |
| - | .large-6.medium-6.columns |
| - | .primary.callout |
| - | %p Six columns |
| - | .large-6.medium-6.columns |
| - | .primary.callout |
| - | %p Six columns |
| - | .row |
| - | .large-4.medium-4.small-4.columns |
| - | .primary.callout |
| - | %p Four columns |
| - | .large-4.medium-4.small-4.columns |
| - | .primary.callout |
| - | %p Four columns |
| - | .large-4.medium-4.small-4.columns |
| - | .primary.callout |
| - | %p Four columns |
| - | %hr/ |
| - | %h5 We bet you’ll need a form somewhere: |
| - | %form |
| - | .row |
| - | .large-12.columns |
| - | %label Input Label |
| - | %input{:placeholder => "large-12.columns", :type => "text"}/ |
| - | .row |
| - | .large-4.medium-4.columns |
| - | %label Input Label |
| - | %input{:placeholder => "large-4.columns", :type => "text"}/ |
| - | .large-4.medium-4.columns |
| - | %label Input Label |
| - | %input{:placeholder => "large-4.columns", :type => "text"}/ |
| - | .large-4.medium-4.columns |
| - | .row.collapse |
| - | %label Input Label |
| - | .input-group |
| - | %input.input-group-field{:placeholder => "small-9.columns", :type => "text"}/ |
| - | %span.input-group-label .com |
| - | .row |
| - | .large-12.columns |
| - | %label Select Box |
| - | %select |
| - | %option{:value => "husker"} Husker |
| - | %option{:value => "starbuck"} Starbuck |
| - | %option{:value => "hotdog"} Hot Dog |
| - | %option{:value => "apollo"} Apollo |
| - | .row |
| - | .large-6.medium-6.columns |
| - | %label Choose Your Favorite |
| - | %input#pokemonRed{:name => "pokemon", :type => "radio", :value => "Red"} |
| - | %label{:for => "pokemonRed"} Radio 1 |
| - | %input#pokemonBlue{:name => "pokemon", :type => "radio", :value => "Blue"} |
| - | %label{:for => "pokemonBlue"} Radio 2 |
| - | .large-6.medium-6.columns |
| - | %label Check these out |
| - | %input#checkbox1{:type => "checkbox"} |
| - | %label{:for => "checkbox1"} Checkbox 1 |
| - | %input#checkbox2{:type => "checkbox"} |
| - | %label{:for => "checkbox2"} Checkbox 2 |
| - | .row |
| - | .large-12.columns |
| - | %label Textarea Label |
| - | %textarea{:placeholder => "small-12.columns"} |
| - | .large-4.medium-4.columns |
| - | %h5 Try one of these buttons: |
| - | %p |
| - | %a.button{:href => "#"} Simple Button |
| - | %br/ |
| - | %a.success.button{:href => "#"} Success Btn |
| - | %br/ |
| - | %a.alert.button{:href => "#"} Alert Btn |
| - | %br/ |
| - | %a.secondary.button{:href => "#"} Secondary Btn |
| - | .callout |
| - | %h5 So many components, girl! |
| - | %p A whole kitchen sink of goodies comes with Foundation. Check out the docs to see them all, along with details on making them your own. |
| - | %a.small.button{:href => "http://foundation.zurb.com/sites/docs/"} Go to Foundation Docs |
| - | %script{:crossorigin => "anonymous", :integrity => "sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=", :src => "https://code.jquery.com/jquery-2.2.3.min.js"} |
| - | {{'vendor/what-input.min.js' | javascript_tag }} |
| - | {{ 'vendor/foundation.min.js' | javascript_tag }} |
| - | {{'app.js' | javascript_tag }} |
generators/page/template.liquid.haml.tt
+0
-47
| @@ | @@ -1,47 +0,0 @@ |
| - | --- |
| - | title: <%= config[:title] -%> |
| - | |
| - | <% if config[:translated] -%># unique identifier for urls, the same as a permalink |
| - | slug: <%= config[:slug] -%> |
| - | <% end -%> |
| - | |
| - | # true if the page is included in the menu |
| - | listed: <% if config[:listed] -%><%= config[:listed] %><% else -%>true<% end %> |
| - | |
| - | # true if the page is published |
| - | published: true |
| - | |
| - | # true if the page can be used as a layout for new pages created by the editors |
| - | # is_layout: true |
| - | |
| - | # position among sibling pages |
| - | # position: 1 |
| - | |
| - | # sets a redirection to the given url (301) |
| - | # redirect_url: "<url to a page or to a remote url>" |
| - | |
| - | # other unique identifier of this page. To be used with the path_to liquid tag. |
| - | # handle: my-page-handle |
| - | |
| - | # content type that this page is templatizing |
| - | <% if config[:content_type] -%> |
| - | content_type: <%= config[:content_type] -%> |
| - | <% else -%> |
| - | # content_type: "<slug of one of the content types>" |
| - | <% end -%> |
| - | |
| - | # editable_elements: |
| - | # 'some_block/some_slug': "<text>" |
| - | # 'some_block/some_slug': "<relative path to the file under the public/samples folder>" |
| - | |
| - | # Control the display of the page in the back-office. |
| - | # display_settings: |
| - | # hidden: true # hidden for authors? |
| - | --- |
| - | {% extends parent %} |
| - | |
| - | {% block main %} |
| - | |
| - | %p Hello world |
| - | |
| - | {% endblock %} |
generators/page/template.liquid.tt
+6
-0
| @@ | @@ -41,6 +41,12 @@ content_type: <%= config[:content_type] -%> |
| # Control the display of the page in the back-office. | |
| # display_settings: | |
| # hidden: true # hidden for authors? | |
| + | |
| + | # Display a list of sections if there is the {% dropzone_sections %} liquid tag |
| + | # is present in the page. |
| + | # sections_content: > |
| + | # [] |
| + | # |
| --- | |
| {% extends parent %} | |
generators/section/template.liquid.tt
+139
-0
| @@ | @@ -0,0 +1,139 @@ |
| + | --- |
| + | { |
| + | "name": "<%= config[:name] %>", |
| + | "type": "<%= config[:type] %>", |
| + | "class": "my-css-classname", |
| + | "settings": [ |
| + | { |
| + | "name": "My awesome title", |
| + | "id": "title", |
| + | "type": "text" |
| + | } |
| + | ], |
| + | "blocks": [ |
| + | { |
| + | "name": "List item", |
| + | "type": "list_item", |
| + | "settings": [ |
| + | { |
| + | "name": "Item title", |
| + | "id": "title", |
| + | "type": "text" |
| + | } |
| + | ] |
| + | } |
| + | ]<% if config[:static] -%>, |
| + | "default": { |
| + | "settings": { |
| + | "title": "Hello world" |
| + | }, |
| + | "blocks": [ |
| + | { |
| + | "type": "list_item", |
| + | "settings": { |
| + | "title": "Item #1" |
| + | } |
| + | }, |
| + | { |
| + | "type": "list_item", |
| + | "settings": { |
| + | "title": "Item #2" |
| + | } |
| + | }, |
| + | { |
| + | "type": "list_item", |
| + | "settings": { |
| + | "title": "Item #3" |
| + | } |
| + | } |
| + | ] |
| + | }<% else -%>, |
| + | "presets": [ |
| + | { |
| + | "name": "<%= config[:name] %>", |
| + | "category": "Category 1", |
| + | "settings": { |
| + | "title": "Hello world" |
| + | }, |
| + | "blocks": [ |
| + | { |
| + | "type": "list_item", |
| + | "settings": { |
| + | "title": "Item #1" |
| + | } |
| + | }, |
| + | { |
| + | "type": "list_item", |
| + | "settings": { |
| + | "title": "Item #2" |
| + | } |
| + | }, |
| + | { |
| + | "type": "list_item", |
| + | "settings": { |
| + | "title": "Item #3" |
| + | } |
| + | } |
| + | ] |
| + | } |
| + | ]<% end -%> |
| + | } |
| + | --- |
| + | {% comment %} |
| + | Above is the JSON definition of your section filled with random settings and blocks. |
| + | Modify it to match your needs. |
| + | |
| + | <% if config[:static] -%> |
| + | To use your static section, just add the following code in your layout template: |
| + | |
| + | {% section <%= config[:type] %> %} |
| + | <% else -%> |
| + | To use your section, make sure that your layouts includes the following liquid tag: |
| + | |
| + | {% sections_dropzone %} |
| + | |
| + | If you want to test this section in your Wagon site, add the following |
| + | lines in the YAML section of any page including the {% sections_dropzone %} |
| + | (or inheriting from a layout including it): |
| + | |
| + | sections_content: > |
| + | [ |
| + | { |
| + | "type": "<%= config[:type] %>", |
| + | "settings": { |
| + | "title": "My awesome section", |
| + | }, |
| + | "blocks": [ |
| + | { |
| + | "type": "list_item", |
| + | "settings": { |
| + | "title": "Item #1" |
| + | } |
| + | }, |
| + | { |
| + | "type": "list_item", |
| + | "settings": { |
| + | "title": "Item #2" |
| + | } |
| + | }, |
| + | { |
| + | "type": "list_item", |
| + | "settings": { |
| + | "title": "Item #3" |
| + | } |
| + | } |
| + | ] |
| + | } |
| + | ] |
| + | <% end -%> |
| + | {% endcomment %} |
| + | <div> |
| + | <h2>{{ section.settings.title }}</h2> |
| + | <ul> |
| + | {% for block in section.blocks %} |
| + | <li {{ block.locomotive_attributes }}> |
| + | {{ block.settings.title }} |
| + | </li> |
| + | {% endfor %} |
| + | </ul> |
| + | </div> |
generators/snippet/template.liquid.haml.tt
+0
-4
| @@ | @@ -1,4 +0,0 @@ |
| - | {% raw %} |
| - | / To use your snippet, just add the following code in your page template |
| - | / {% include <%= config[:slug] -%> %} |
| - | {% endraw %} |
| \ No newline at end of file | |
locomotive/wagon.rb b/lib/locomotive/wagon.rb
+1
-1
| @@ | @@ -21,7 +21,7 @@ module Locomotive |
| # Create a site from a site generator. | |
| # | |
| # @param [ Object ] generator The wrapping class of the generator itself | |
| - | # @param [ Array ] args [name of the site, destination path of the site, skip bundle flag, force_haml] |
| + | # @param [ Array ] args [name of the site, destination path of the site, skip bundle flag] |
| # @param [ Hash ] options General options (ex: --force-color) | |
| # | |
| def self.init(generator_klass, args, options = {}) | |
locomotive/wagon/cli.rb b/lib/locomotive/wagon/cli.rb
+19
-6
| @@ | @@ -110,13 +110,11 @@ module Locomotive |
| desc 'page FULLPATH', 'Create a page. No need to pass an extension to the FULLPATH arg' | |
| method_option :title, aliases: '-t', type: 'string', default: nil, desc: 'Title of the page' | |
| - | method_option :haml, aliases: '-h', type: 'boolean', default: nil, desc: 'add a HAML extension to the file' |
| method_option :listed, aliases: '-l', type: 'boolean', default: false, desc: 'tell if the page is listed in the menu' | |
| method_option :content_type, aliases: '-c', type: 'string', default: nil, desc: 'tell if the page is a template for a content type' | |
| method_option :locales, aliases: '-lo', type: 'string', default: nil, desc: 'locales for the various translations' | |
| long_desc <<-LONGDESC | |
| - | Create a page. The generator will ask for the extension (liquid or haml) and also |
| - | if the page is localized or not. |
| + | Create a page. The generator will ask if the page is localized or not. |
| Examples: | |
| @@ | @@ -135,8 +133,7 @@ module Locomotive |
| desc 'snippet SLUG', 'Create a snippet' | |
| long_desc <<-LONGDESC | |
| - | Create a snippet. The generator will ask for the extension (liquid or haml) and also |
| - | if the snippet is localized or not. |
| + | Create a snippet. The generator will ask if the snippet is localized or not. |
| Example: | |
| @@ | @@ -151,6 +148,22 @@ module Locomotive |
| end | |
| end | |
| + | desc 'section SLUG', 'Create a section' |
| + | long_desc <<-LONGDESC |
| + | Create a section. The generator will ask if the section is static or not. |
| + | |
| + | Example: |
| + | |
| + | * wagon generate section hero |
| + | LONGDESC |
| + | def section(slug) |
| + | force_color_if_asked(options) |
| + | |
| + | if path = check_path! |
| + | Locomotive::Wagon.generate :section, [slug, '', path], self.options |
| + | end |
| + | end |
| + | |
| desc 'site_metafields', 'Generate the missing file to describe the site metafields' | |
| def site_metafields | |
| force_color_if_asked(options) | |
| @@ | @@ -353,7 +366,7 @@ module Locomotive |
| desc 'delete ENV RESOURCE [SLUG] [PATH]', 'Delete a resource from a remote Locomotive Engine.' | |
| long_desc <<-LONGDESC | |
| - | Deletes a site, page, content_type, snippet, theme_asset or translation from the remote Locomotive Engine. |
| + | Deletes a site, page, content_type, snippet, section, theme_asset or translation from the remote Locomotive Engine. |
| It can also delete all the items of a resource if you pass: content_types, snippets, theme_assets or translations as the RESOURCE. | |
locomotive/wagon/generators/section.rb b/lib/locomotive/wagon/generators/section.rb
+46
-0
| @@ | @@ -0,0 +1,46 @@ |
| + | require 'thor/group' |
| + | require 'active_support' |
| + | require 'active_support/core_ext' |
| + | |
| + | module Locomotive |
| + | module Wagon |
| + | module Generators |
| + | class Section < Thor::Group |
| + | |
| + | include Thor::Actions |
| + | include Locomotive::Wagon::CLI::ForceColor |
| + | |
| + | argument :slug |
| + | argument :static |
| + | argument :target_path # path to the site |
| + | |
| + | def is_static? |
| + | if self.static.blank? |
| + | self.static = yes?('Is this section aimed to be used as static?') |
| + | end |
| + | end |
| + | |
| + | def create_section |
| + | _slug = slug.clone.downcase.gsub(/[-]/, '_') |
| + | |
| + | options = { name: _slug.humanize, type: _slug, static: self.static } |
| + | file_path = File.join(sections_path, _slug) |
| + | |
| + | template "template.liquid.tt", "#{file_path}.liquid", options |
| + | end |
| + | |
| + | def self.source_root |
| + | File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'generators', 'section') |
| + | end |
| + | |
| + | protected |
| + | |
| + | def sections_path |
| + | File.join(target_path, 'app', 'views', 'sections') |
| + | end |
| + | |
| + | end |
| + | |
| + | end |
| + | end |
| + | end |
locomotive/wagon/generators/site/base.rb b/lib/locomotive/wagon/generators/site/base.rb
+0
-12
| @@ | @@ -37,10 +37,6 @@ module Locomotive |
| File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..', 'generators', self.name.demodulize.underscore) | |
| end | |
| - | def self.may_use_haml |
| - | class_option :haml, type: :boolean, default: nil, required: false, desc: 'Use HAML templates?' |
| - | end |
| - | |
| def self.may_use_scss | |
| class_option :scss, type: :boolean, default: nil, required: false, desc: 'Use SCSS stylesheets?' | |
| end | |
| @@ | @@ -51,14 +47,6 @@ module Locomotive |
| File.join(target_path, name) | |
| end | |
| - | def haml? |
| - | if options[:haml].nil? |
| - | yes?('Do you prefer HAML templates?') |
| - | else |
| - | options[:haml] |
| - | end |
| - | end |
| - | |
| def scss? | |
| if options[:scss].nil? | |
| yes?('Do you prefer SCSS stylesheets?') | |
locomotive/wagon/generators/site/blank.rb b/lib/locomotive/wagon/generators/site/blank.rb
+1
-17
| @@ | @@ -5,22 +5,6 @@ module Locomotive |
| class Blank < Base | |
| - | may_use_haml |
| - | |
| - | def choose_haml_over_html |
| - | if haml? |
| - | remove_file File.join(self.destination, 'app/views/pages/index.liquid') |
| - | remove_file File.join(self.destination, 'app/views/pages/404.liquid') |
| - | else |
| - | remove_file File.join(self.destination, 'app/views/pages/index.liquid.haml') |
| - | remove_file File.join(self.destination, 'app/views/pages/404.liquid.haml') |
| - | end |
| - | end |
| - | |
| - | def bundle_install |
| - | super |
| - | end |
| - | |
| end | |
| Locomotive::Wagon::Generators::Site.register(:blank, Blank, %{ | |
| @@ | @@ -29,4 +13,4 @@ module Locomotive |
| end | |
| end | |
| end | |
| - | end |
| \ No newline at end of file | |
| + | end |
locomotive/wagon/generators/site/bootstrap.rb b/lib/locomotive/wagon/generators/site/bootstrap.rb
+0
-19
| @@ | @@ -5,27 +5,8 @@ module Locomotive |
| class Bootstrap < Base | |
| - | may_use_haml |
| may_use_scss | |
| - | def choose_haml_over_html |
| - | if haml? |
| - | remove_file File.join(self.destination, 'app/views/pages/layouts/default.liquid') |
| - | remove_file File.join(self.destination, 'app/views/pages/layouts/simple.liquid') |
| - | remove_file File.join(self.destination, 'app/views/pages/index.liquid') |
| - | remove_file File.join(self.destination, 'app/views/pages/404.liquid') |
| - | remove_file File.join(self.destination, 'app/views/snippets/nav.liquid') |
| - | remove_file File.join(self.destination, 'app/views/snippets/footer.liquid') |
| - | else |
| - | remove_file File.join(self.destination, 'app/views/pages/layouts/default.liquid.haml') |
| - | remove_file File.join(self.destination, 'app/views/pages/layouts/simple.liquid.haml') |
| - | remove_file File.join(self.destination, 'app/views/pages/index.liquid.haml') |
| - | remove_file File.join(self.destination, 'app/views/pages/404.liquid.haml') |
| - | remove_file File.join(self.destination, 'app/views/snippets/nav.liquid.haml') |
| - | remove_file File.join(self.destination, 'app/views/snippets/footer.liquid.haml') |
| - | end |
| - | end |
| - | |
| def choose_scss_over_css | |
| if scss? | |
| remove_file File.join(self.destination, 'public/stylesheets/application.css') | |
locomotive/wagon/generators/site/foundation.rb b/lib/locomotive/wagon/generators/site/foundation.rb
+0
-11
| @@ | @@ -5,19 +5,8 @@ module Locomotive |
| class Foundation < Base | |
| - | may_use_haml |
| may_use_scss | |
| - | def choose_haml_over_html |
| - | if haml? |
| - | remove_file File.join(self.destination, 'app/views/pages/index.liquid') |
| - | remove_file File.join(self.destination, 'app/views/pages/404.liquid') |
| - | else |
| - | remove_file File.join(self.destination, 'app/views/pages/index.liquid.haml') |
| - | remove_file File.join(self.destination, 'app/views/pages/404.liquid.haml') |
| - | end |
| - | end |
| - | |
| def choose_scss_over_css | |
| if scss? | |
| remove_file File.join(self.destination, 'public/stylesheets/app.css') | |
locomotive/wagon/generators/snippet.rb b/lib/locomotive/wagon/generators/snippet.rb
+3
-11
| @@ | @@ -14,35 +14,27 @@ module Locomotive |
| argument :locales | |
| argument :target_path # path to the site | |
| - | attr_accessor :haml |
| - | |
| - | def ask_for_haml |
| - | self.haml = yes?('Do you prefer a HAML template ?') |
| - | end |
| - | |
| def apply_locales? | |
| self.locales.shift # remove the default locale | |
| unless self.locales.empty? | |
| - | unless yes?('Do you want to generate files for each locale ?') |
| + | unless yes?('Do you want to generate files for each locale?') |
| self.locales = [] | |
| end | |
| end | |
| end | |
| def create_snippet | |
| - | extension = self.haml ? 'liquid.haml' : 'liquid' |
| - | |
| _slug = slug.clone.downcase.gsub(/[-]/, '_') | |
| options = { slug: _slug, translated: false } | |
| file_path = File.join(snippets_path, _slug) | |
| - | template "template.#{extension}.tt", "#{file_path}.#{extension}", options |
| + | template "template.liquid.tt", "#{file_path}.liquid", options |
| self.locales.each do |locale| | |
| options[:translated] = true | |
| - | template "template.#{extension}.tt", "#{file_path}.#{locale}.#{extension}", options |
| + | template "template.liquid.tt", "#{file_path}.#{locale}.liquid", options |
| end | |
| end | |
spec/integration/generators/page_spec.rb
+1
-1
| @@ | @@ -14,7 +14,7 @@ describe 'Locomotive::Wagon::Generators::Page' do |
| let(:fullpath) { 'new-page' } | |
| let(:default_locales) { ['en', 'fr'] } | |
| let(:locales) { nil } | |
| - | let(:page_options) { { haml: false, locales: locales, default_locales: default_locales } } |
| + | let(:page_options) { { locales: locales, default_locales: default_locales } } |
| let(:options) { { 'force_color' => true, 'path' => path, 'quiet' => true }.merge(page_options) } | |
| subject { Locomotive::Wagon.generate(:page, [fullpath, options.delete('path')], options) } | |