diff --git a/CHANGELOG b/CHANGELOG index c83caeb..7791b8c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ += Version 0.4 + * Added project generator (ace-gen). + = Version 0.3 * Added LazyRendering mixin. * Added SassFilter. diff --git a/bin/ace-gen b/bin/ace-gen index 9a5aa08..b613821 100755 --- a/bin/ace-gen +++ b/bin/ace-gen @@ -20,6 +20,8 @@ rescue LoadError end templater = SimpleTemplater.new(:ace) +templater.discover! + generator = templater.find(:project) if generator.nil? diff --git a/lib/ace/version.rb b/lib/ace/version.rb index 654189d..0e6d40c 100644 --- a/lib/ace/version.rb +++ b/lib/ace/version.rb @@ -1,5 +1,5 @@ # encoding: utf-8 module Ace - VERSION = "0.3.3" + VERSION = "0.4" end diff --git a/project_generator/content/.gitignore b/project_generator/content/.gitignore new file mode 100644 index 0000000..53752db --- /dev/null +++ b/project_generator/content/.gitignore @@ -0,0 +1 @@ +output diff --git a/project_generator/content/Gemfile b/project_generator/content/Gemfile new file mode 100644 index 0000000..aeed120 --- /dev/null +++ b/project_generator/content/Gemfile @@ -0,0 +1,24 @@ +# encoding: utf-8 + +# Use local clones if possible. +# If you want to use your local copy, just symlink it to vendor. +extend Module.new { + def gem(name, options = Hash.new) + local_path = File.expand_path("../vendor/#{name}", __FILE__) + if File.exist?(local_path) + super name, options.merge(path: local_path).delete_if { |key, _| [:git, :branch].include?(key) } + else + super name, options + end + end +} + +source "http://gemcutter.org" + +gem "ace" +gem "nake" +gem "template-inheritance" + +group(:development) + gem "rack" +end diff --git a/project_generator/content/LICENSE.rbt b/project_generator/content/LICENSE.rbt new file mode 100644 index 0000000..92290b7 --- /dev/null +++ b/project_generator/content/LICENSE.rbt @@ -0,0 +1,26 @@ +Copyright (c) <%= Time.now.year %> <%= @user %> + +All the logic can be used under the MIT license (see bellow). +The actual articles though shall not be used by other people +in any circumstances unless the author gives permission to do +otherwise. In such case the copyright information shall not +be omitted as well as a link to its original source. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/project_generator/content/README.textile.rbt b/project_generator/content/README.textile.rbt new file mode 100644 index 0000000..9b3c14e --- /dev/null +++ b/project_generator/content/README.textile.rbt @@ -0,0 +1,11 @@ +h1. About + +This is "<%= @name %>":<%= @url %>. It is written in "Ace":https://github.com/botanicus/ace, a powerful generator of static sites. + +h1. Usage + +_*NOTE:* You need Ruby 1.9.2 or later._ + +# Install all the dependencies via bundler: @bundle install@. +# Generate the output by running @./tasks.rb generate@. +# Run @./config.ru@ and view the content at "localhost:9292":http://localhost:9292/. diff --git a/project_generator/content/app/.gitignore b/project_generator/content/app/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/project_generator/content/boot.rb b/project_generator/content/boot.rb new file mode 100755 index 0000000..4794fbb --- /dev/null +++ b/project_generator/content/boot.rb @@ -0,0 +1,20 @@ +#!/usr/bin/env bundle exec ace +# encoding: utf-8 + +Encoding.default_internal = "utf-8" +Encoding.default_external = "utf-8" + +# Setup $LOAD_PATH. +require "bundler/setup" + +# Custom setup. +require "pupu/adapters/ace" +Pupu.media_prefix = "/assets" + +require "helpers" + +# Load the app. +Dir["app/**/*.rb"].each do |file| + puts "~ Loading #{file}" + load file +end diff --git a/project_generator/content/config.ru b/project_generator/content/config.ru new file mode 100755 index 0000000..f4ba0ec --- /dev/null +++ b/project_generator/content/config.ru @@ -0,0 +1,32 @@ +#!/usr/bin/env rackup + +# This is just for development. The only thing it does +# is serving of static files from the output/ directory. + +use Rack::Head + +class Server + def initialize(root) + @file_server = Rack::File.new(root) + end + + def call(env) + path = env["PATH_INFO"] + returned = @file_server.call(env) + if returned[0] == 404 && env["PATH_INFO"].end_with?("/") + env["PATH_INFO"] = File.join(env["PATH_INFO"], "index.html") + returned = @file_server.call(env) + log "[404]", env["PATH_INFO"] if returned[0] == 404 + returned + else + returned + end + end + + private + def log(bold, message) + warn "~ \033[1;31m#{bold}\033[0m #{message}" + end +end + +run Server.new("output") diff --git a/project_generator/content/config.yml.rbt b/project_generator/content/config.yml.rbt new file mode 100644 index 0000000..6a551bb --- /dev/null +++ b/project_generator/content/config.yml.rbt @@ -0,0 +1,2 @@ +title: "" +base_url: "<% @url %>" diff --git a/project_generator/content/content/assets/css/.gitignore b/project_generator/content/content/assets/css/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/project_generator/content/content/assets/img/.gitignore b/project_generator/content/content/assets/img/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/project_generator/content/content/assets/js/.gitignore b/project_generator/content/content/assets/js/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/project_generator/content/content/index.html.haml b/project_generator/content/content/index.html.haml new file mode 100644 index 0000000..719e1f7 --- /dev/null +++ b/project_generator/content/content/index.html.haml @@ -0,0 +1,7 @@ +- extends "base.html" + +- block(:description, "Hello world page, nothing fancy.") +- block(:keywords, "hello world, ace, whatever else") + += block(:body) do + %h1 Hello World! diff --git a/project_generator/content/content/robots.txt b/project_generator/content/content/robots.txt new file mode 100644 index 0000000..d3ac87d --- /dev/null +++ b/project_generator/content/content/robots.txt @@ -0,0 +1,3 @@ +User-agent: * +Disallow: /assets +Allow: / diff --git a/project_generator/content/layouts/base.html.haml.rbt b/project_generator/content/layouts/base.html.haml.rbt new file mode 100644 index 0000000..b39baf3 --- /dev/null +++ b/project_generator/content/layouts/base.html.haml.rbt @@ -0,0 +1,13 @@ +!!! 5 +%html + %head + %title= block(:title, "<%= @name %>") + %meta{"http-equiv" => "content-type", content: "text/html; charset=utf-8"} + %meta{"http-equiv" => "content-language", content: "en"} + %meta{name: "description", content: block(:description, "")} + %meta{name: "keywords", content: block(:keywords, "")} + = block(:head) + %body + = block(:body) + #footer + © <%= Time.now.year %> – #{Time.now.year} <%= @user %> | Powered by Ace. diff --git a/project_generator/content/rules.rb b/project_generator/content/rules.rb new file mode 100644 index 0000000..da3605e --- /dev/null +++ b/project_generator/content/rules.rb @@ -0,0 +1,5 @@ +# encoding: utf-8 + +require "ace/static" + +rule Ace::Static, "index.html.haml" diff --git a/project_generator/content/tasks.rb b/project_generator/content/tasks.rb new file mode 100755 index 0000000..765595d --- /dev/null +++ b/project_generator/content/tasks.rb @@ -0,0 +1,28 @@ +#!/usr/bin/env bundle exec nake +# encoding: utf-8 + +Encoding.default_internal = "utf-8" +Encoding.default_external = "utf-8" + +# Task.tasks.default_proc = lambda { |*| Task[:generate] } + +Task.new(:generate) do |task| + task.description = "Generate static HTML." + + task.define do + sh "./boot.rb" + end +end + +Task.new(:rsync) do |task| + task.description = "Rsync the output to server." + + # config + task.config[:user] = "TODO" + task.config[:server] = "TODO" + task.config[:path] = "TODO" + + task.define do |options| + sh "rsync -av --delete output/ #{config[:user]}@#{config[:server]}:#{config[:path]}" + end +end diff --git a/project_generator/setup.rb b/project_generator/setup.rb index 09b0b41..c5afc35 100644 --- a/project_generator/setup.rb +++ b/project_generator/setup.rb @@ -4,6 +4,10 @@ # You can update context hash and register hooks. Don't forget to use merge! instead of merge, because you are # manipulating with one object, rather than returning new one. +# ace-gen project --user="Jakub Stastny" --name=101Ideas.cz --url=http://101ideas.cz + hook do |generator, context| - # TODO + context[:user] ||= ENV["USER"] + context[:name] || raise("You have to specify at least --title=WebTitle") + context[:url] ||= "http://#{context[:name]}" end