middleman-targets 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/CHANGELOG.md +6 -0
  4. data/Gemfile +18 -0
  5. data/LICENSE.md +22 -0
  6. data/README.md +110 -0
  7. data/Rakefile +10 -0
  8. data/bin/middleman-targets +80 -0
  9. data/documentation_project/.gitignore +25 -0
  10. data/documentation_project/Gemfile +14 -0
  11. data/documentation_project/README.md +13 -0
  12. data/documentation_project/config.rb +123 -0
  13. data/documentation_project/source/frontmatter.html.md.erb +70 -0
  14. data/documentation_project/source/helpers-resources.html.md.erb +98 -0
  15. data/documentation_project/source/images/free-logo-small.png +0 -0
  16. data/documentation_project/source/images/free-logo-small@2x.png +0 -0
  17. data/documentation_project/source/images/free-logo.png +0 -0
  18. data/documentation_project/source/images/free-logo@2x.png +0 -0
  19. data/documentation_project/source/images/pro-logo-small.png +0 -0
  20. data/documentation_project/source/images/pro-logo-small@2x.png +0 -0
  21. data/documentation_project/source/images/pro-logo.png +0 -0
  22. data/documentation_project/source/images/pro-logo@2x.png +0 -0
  23. data/documentation_project/source/index.html.md.erb +59 -0
  24. data/documentation_project/source/javascripts/all.js +1 -0
  25. data/documentation_project/source/layouts/layout.haml +9 -0
  26. data/documentation_project/source/layouts/template-logo-large.haml +17 -0
  27. data/documentation_project/source/layouts/template-logo-medium.haml +14 -0
  28. data/documentation_project/source/layouts/template-logo-small.haml +11 -0
  29. data/documentation_project/source/only-free.html.md.erb +38 -0
  30. data/documentation_project/source/only-pro.html.md.erb +39 -0
  31. data/documentation_project/source/simple-demo.html.md.erb +183 -0
  32. data/documentation_project/source/stylesheets/_github.scss +61 -0
  33. data/documentation_project/source/stylesheets/_middlemac_minimal.scss +516 -0
  34. data/documentation_project/source/stylesheets/_normalize.scss +374 -0
  35. data/documentation_project/source/stylesheets/style.css.scss +3 -0
  36. data/documentation_project/source/target-feature-config.html.md.erb +153 -0
  37. data/lib/middleman-targets.rb +13 -0
  38. data/lib/middleman-targets/commands.rb +6 -0
  39. data/lib/middleman-targets/extension.rb +281 -0
  40. data/lib/middleman-targets/version.rb +5 -0
  41. data/middleman-targets.gemspec +26 -0
  42. metadata +126 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5b0207312e941b65b1ee3842b775d77c868fccdc
4
+ data.tar.gz: 17aa00a667fcece866f54b5080ae53e9e8269b58
5
+ SHA512:
6
+ metadata.gz: 3eff02a74fc75761e2820e4aaad2c61a6edb7e78be4cff60f7081f0cce0e72ee89e951cbe72afedddbc7dc11875c514de9106505f9197bc16a2f2d5bd851f0b1
7
+ data.tar.gz: cd7d551e89f13468ac9e6b7f9dd6b84912cb3248e24f5e87b6b905807682a807aebf588e80dfba5c255f1ccf64645912fc19364e6fd6188a3ea10d85302f4a22
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ # Rubymine noise
2
+ .idea/
3
+
4
+ # BBedit noise
5
+ *.bbprojectd
6
+
7
+ # Mac OS X noise
8
+ .DS_Store
9
+
10
+ # Ignore bundler lock files
11
+ Gemfile.lock
12
+
13
+ # Ignore pkg folder
14
+ /pkg
15
+
16
+ # Ignore build folders
17
+ build*
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ middlemac-targets change log
2
+ ============================
3
+
4
+ - Version 1.0.0 / 2016-March
5
+
6
+ - Initial Release
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # If you do not have OpenSSL installed, update
2
+ # the following line to use "http://" instead
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in middlemac.gemspec
6
+ gemspec
7
+
8
+ group :development do
9
+ gem 'rake'
10
+ gem 'rdoc'
11
+ gem 'yard'
12
+ end
13
+
14
+ group :test do
15
+ gem 'cucumber'
16
+ gem 'aruba'
17
+ gem 'rspec'
18
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License
2
+ ===============
3
+
4
+ Copyright (c) 2016 Jim Derry
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,110 @@
1
+ middleman-targets readme
2
+ ========================
3
+
4
+ `middleman-targets`
5
+
6
+ : This gem provides the ability to generate multiple targets by outfitting
7
+ Middleman with additional command line options. The provided helpers make
8
+ it simple to control content that is specific to each target, based on the
9
+ target name or based on feature sets for each target.
10
+
11
+ It is standalone and can be used in any Middleman project.
12
+
13
+
14
+ Install the Gem
15
+ ---------------
16
+
17
+ Install the gem in your preferred way, typically:
18
+
19
+ ~~~ bash
20
+ gem install middleman-targets
21
+ ~~~
22
+
23
+ From git source:
24
+
25
+ ~~~ bash
26
+ rake install
27
+ ~~~
28
+
29
+
30
+ Documentation
31
+ -------------
32
+
33
+ The complete documentation leverages the features of this gem in order to better
34
+ document them. Having installed the gem, read the full documentation in your
35
+ web browser:
36
+
37
+ ~~~ bash
38
+ middleman-targets documentation
39
+ cd middleman-targets-docs/
40
+ bundle install
41
+ bundle exec middleman server
42
+ ~~~
43
+
44
+ And then open your web browser to the address specified (typically
45
+ `localhost:4567`).
46
+
47
+
48
+ Quick Documentation
49
+ -------------------
50
+
51
+ [Middleman](https://middlemanapp.com/) 4.1.6 or newer is required. Earlier
52
+ point versions of Middleman do not have the necessary support for this
53
+ extension.
54
+
55
+ Once setup and configured, you can build multiple targets like so:
56
+
57
+ ~~~ bash
58
+ bundle exec middleman build --target mytarget
59
+ ~~~
60
+
61
+ Or:
62
+
63
+ ~~~ bash
64
+ bundle exec middleman build_all
65
+ ~~~
66
+
67
+ Or:
68
+
69
+ ~~~ bash
70
+ bundle exec middleman serve --target mytarget
71
+ ~~~
72
+
73
+ Added Features
74
+ --------------
75
+
76
+ To support multiple targets and features, flexible configuration and helpers are
77
+ available, including
78
+
79
+ - Enhanced `image_tag` support chooses target-specific assets for you.
80
+ - Enhanced `image_tag` support conditionally includes assets specific to
81
+ targets or features that you designate.
82
+ - The `target_name?()` helper allows you to selectively include or exclude
83
+ content on a per-target basis.
84
+ - The `target_feature?()` helper allows fined-grained control over included
85
+ content by managing features of a target instead of a target per se.
86
+ - Front matter `target` and `exclude` arrays can ensure entire pages are
87
+ included or excluded on a target and/or feature specific basis.
88
+ - …and more.
89
+
90
+
91
+ Middlemac
92
+ ---------
93
+
94
+ This Middleman extension is a critical part of
95
+ [Middlemac](https://github.com/middlemac), the Mac OS X help building system
96
+ for Mac OS X applications. However this gem is not Mac OS X specific and can be
97
+ useful in any application for which you want to generate multiple targets.
98
+
99
+
100
+ License
101
+ -------
102
+
103
+ MIT. See `LICENSE.md`.
104
+
105
+
106
+ Changelog
107
+ ---------
108
+
109
+ See `CHANGELOG.md` for point changes, or simply have a look at the commit
110
+ history for non-version changes (such as readme updates).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :spec
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ################################################################################
4
+ # middleman-targets
5
+ # This file constitutes the command line interface for middleman-targets
6
+ ################################################################################
7
+
8
+ require 'thor'
9
+ require 'fileutils'
10
+ require 'middleman-targets/version'
11
+
12
+ module MiddlemacTargetsCli
13
+
14
+ class Cli < Thor
15
+
16
+ map %w[--version -v] => :__print_version
17
+
18
+ ############################################################
19
+ # help
20
+ # Override to add additional description.
21
+ ############################################################
22
+ def help(*args)
23
+ if args.count == 0
24
+ puts <<-HEREDOC
25
+
26
+ middleman-targets version #{Middleman::MiddlemanTargets::VERSION}
27
+
28
+ This gem adds functionality to Middleman and is not executable on its own
29
+ (other than for generating the documentation sample project). Instead, you
30
+ must add this gem to your Middleman project's `Gemfile` and then activate
31
+ it in your `config.rb` file. This will enable the new `--target` command
32
+ line option in Middleman, and the new `build_all` command.
33
+
34
+ HEREDOC
35
+ end
36
+ super
37
+ end
38
+
39
+
40
+ ############################################################
41
+ # documentation
42
+ ############################################################
43
+ desc 'documentation', 'Install the sample project into your current working directory.'
44
+ long_desc <<-HEREDOC
45
+ `documentation` will produce a sample project named `middleman-targets-docs/`
46
+ in your current working directory. This sample uses the features of this gem.
47
+ You can then serve this new project to read the documentation by:
48
+
49
+ cd middleman-targets-docs
50
+ bundle install
51
+ bundle exec middleman server
52
+
53
+ HEREDOC
54
+ def documentation
55
+ source = File.join('..', '..', 'documentation_project', '.')
56
+ source = File.expand_path(source, __FILE__)
57
+ dest = File.expand_path(File.join('.', 'middleman-targets-docs', '.'))
58
+ FileUtils.cp_r(source, dest)
59
+ puts "middleman-targets installed the project in\n#{dest}"
60
+ end
61
+
62
+
63
+ ############################################################
64
+ # __print_version
65
+ ############################################################
66
+ desc '--version, -v', 'print the version'
67
+ def __print_version
68
+ puts "middleman-targets version #{Middleman::MiddlemanTargets::VERSION}"
69
+ end
70
+
71
+ end # class Cli
72
+
73
+ end # module MiddlemacTargetsCli
74
+
75
+
76
+ ###########################################################
77
+ # Main
78
+ ###########################################################
79
+
80
+ MiddlemacTargetsCli::Cli.start(ARGV)
@@ -0,0 +1,25 @@
1
+ # Rubymine noise
2
+ .idea/
3
+
4
+ # BBedit noise
5
+ *.bbprojectd
6
+
7
+ # Mac OS X noise
8
+ .DS_Store
9
+
10
+ # Ignore bundler lock files
11
+ Gemfile.lock
12
+
13
+ # Ignore pkg folder
14
+ /pkg
15
+
16
+ # Ignore build folders
17
+ .rbenv-*
18
+ .ruby-gemset
19
+ .ruby-version
20
+ .sass-cache
21
+ .sassc
22
+ .tmp
23
+ build*
24
+ Makefile
25
+ tmp
@@ -0,0 +1,14 @@
1
+ # If you do not have OpenSSL installed, change
2
+ # the following line to use 'http://'
3
+ source 'https://rubygems.org'
4
+
5
+ # For faster file watcher updates on Windows:
6
+ gem 'wdm', '~> 0.1.0', platforms: [:mswin, :mingw]
7
+
8
+ # Windows does not come with time zone data
9
+ gem 'tzinfo-data', platforms: [:mswin, :mingw, :jruby]
10
+
11
+ # Middleman Gems
12
+ gem 'middleman-targets', '~>1.0.0'
13
+ gem 'middleman', '~> 4.1.6'
14
+ gem 'middleman-syntax'
@@ -0,0 +1,13 @@
1
+ documentation-project readme
2
+ ----------------------------
3
+
4
+ This gem's documentation is a Middleman project using the features of this gem.
5
+ To view the documentation project, `cd` into this directory and
6
+
7
+ ~~~ bash
8
+ gem install
9
+ bundle exec middleman serve
10
+ ~~~
11
+
12
+ When the server starts, it will provide instructions on how to view the project
13
+ in your web browser.
@@ -0,0 +1,123 @@
1
+ ################################################################################
2
+ # Sample Project for middleman-targets
3
+ ################################################################################
4
+
5
+ #==========================================================================
6
+ # Conflicting helpers
7
+ # middleman-targets extends the built-in `image_tag` helper, but so do
8
+ # some of Middleman's other extensions. To avoid issues, make sure you
9
+ # activate those other extensions, first, before :MiddlemanTargets.
10
+ #==========================================================================
11
+ activate :automatic_image_sizes
12
+ activate :automatic_alt_tags
13
+
14
+
15
+ #==========================================================================
16
+ # Extension Setup
17
+ # Note that middleman-targets adds configuration parameters to the base
18
+ # Middleman application (supported feature in 4.0+); there are *not*
19
+ # extension options. Additionally if middleman-targets is in your Gemfile
20
+ # then it is also activated automatically.
21
+ #==========================================================================
22
+ activate :MiddlemanTargets
23
+
24
+ # Set the default target. This is the target that is used automatically
25
+ # when you `middleman build` or `middleman server` without using the
26
+ # `targets` CLI option.
27
+ set :target, :pro
28
+
29
+ # Setup your targets and their features. You can use any target names and
30
+ # feature names that you like, but keep in mind that the key :features is
31
+ # required for each of your targets.
32
+ #
33
+ # The key :build_dir for any target, if used, will override the global
34
+ # :build_dir setting. You can use a specific string for this setting, and
35
+ # this string can optionally include a single %s sprintf placeholder which
36
+ # will be filled with the target name.
37
+ #
38
+ # You can add your own keys to each target for your own uses; the
39
+ # `sample_key` below is an example of such. The generic `target_value()`
40
+ # helper can retrieve these values, or you can write your own helpers.
41
+ set :targets, {
42
+ :free =>
43
+ {
44
+ :sample_key => 'People who use free versions don\'t drive profits.',
45
+ :build_dir => 'build (%s)',
46
+ :features =>
47
+ {
48
+ :feature_advertise_pro => true,
49
+ :insults_user => true,
50
+ :grants_wishes => false,
51
+ }
52
+ },
53
+
54
+ :pro =>
55
+ {
56
+ :sample_key => 'You are a valued contributor to our balance sheet!',
57
+ :features =>
58
+ {
59
+ :feature_advertise_pro => false,
60
+ :insults_user => false,
61
+ :grants_wishes => true,
62
+ }
63
+ },
64
+ }
65
+
66
+ # By enabling :target_magic_images and using middleman-targets' image helper,
67
+ # then target specific images will be used instead of the image you specify,
68
+ # *if* that image name is prefixed with :target_magic_word. For example, you
69
+ # might request "all-my_image.png", and "pro-my_image.png" (if it exists) will
70
+ # be used in your :pro target instead.
71
+ #
72
+ # Important: when this is enabled, images from *other* targets will *not* be
73
+ # included in the build! In the example above, *any* image prefixed with "free-"
74
+ # would not be included in the output directory.
75
+ set :target_magic_images, true
76
+ set :target_magic_word, 'all'
77
+
78
+ # Note that output will now use this directory as a *prefix*; if the target
79
+ # is :pro, then the actual build directory will be `build (pro)/`. If the
80
+ # build_dir key is present for any of the :targets, they will override this
81
+ # setting.
82
+ set :build_dir, 'build'
83
+
84
+
85
+ #==========================================================================
86
+ # Regular Middleman Setup
87
+ #==========================================================================
88
+
89
+ set :relative_links, true
90
+ activate :syntax
91
+
92
+
93
+ #==========================================================================
94
+ # Helpers
95
+ # These helpers are used by the sample project only; there's no need
96
+ # to keep them around in your own projects.
97
+ #==========================================================================
98
+
99
+ # Methods defined in the helpers block are available in templates
100
+ helpers do
101
+
102
+ def product_name
103
+ 'middleman-targets'
104
+ end
105
+
106
+ def product_version
107
+ '2.0.0-beta1'
108
+ end
109
+
110
+ def product_uri
111
+ 'https://github.com/middlemac'
112
+ end
113
+
114
+ end
115
+
116
+ # Build-specific configuration
117
+ configure :build do
118
+ # Minify CSS on build
119
+ # activate :minify_css
120
+
121
+ # Minify Javascript on build
122
+ # activate :minify_javascript
123
+ end