great_pretender 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d7bef2a3f4eedc66d221d827f8a6f747cb54b4c
4
- data.tar.gz: 4e36bcc3085b77217e178240f1e6aa22098dfc52
3
+ metadata.gz: b0a84b26997b6eb8cf255e8f687a1b1b6238ce70
4
+ data.tar.gz: 5f7d90db4cf3dabd4c410d413237da15360d5e28
5
5
  SHA512:
6
- metadata.gz: a2a4192ad7d8997fb34aad458289b6a189ca99b3d31b8f1f21bf8e6fd2fab7bf027b965192a275b335adf6faa179ded3016de479e53bd1447314e62332b88444
7
- data.tar.gz: f9f15adcb02f5466ee6447267e2c00374bf2a839943a90726e6677ea4cfd17f8ffe2ab630e742f1a2bc2e9ae020c19071d234732981a6acbcf2374c7c8eb278d
6
+ metadata.gz: 2c6e1dcc3080c725c1e1405346aad7f1b130b6b9dbc2504804ade1c5a535545379d3e4876ad6fc4ee8f00967619ee7bcf3d724b66d1b40f3fbf61a62a9ef350e
7
+ data.tar.gz: 3071b731a1bca2a49b3d97d7544221cf56bd5cd6bfc2908c4144ad4a358aef585422e811af35855ed3055389b84e7b9d7421316b727c5a7d804c336320142599
data/README.md CHANGED
@@ -1,31 +1,163 @@
1
- # GreatPretender
1
+ # Great Pretender
2
2
 
3
- TODO: Write a gem description
3
+ **Ridiculously easy-to-use Rails mockups for those enlightened individuals who design in-browser.**
4
4
 
5
- ## Installation
5
+ ## Features
6
6
 
7
- Add this line to your application's Gemfile:
7
+ **Great Pretender** was designed to be easy and awesome. Here are a few of its neat features:
8
+
9
+ - Supports multiple layouts
10
+ - Supports nested mockup directories (e.g. `app/views/mockups/users/sessions/whatever.html.slim`)
11
+ - Supports partials
12
+ - Installs in 2 minutes as a Rails engine
13
+ - Can be mixed in to other controllers for access control or whatever else you want to add
14
+ - Configurable mockups folder name and default layout
15
+ - Dances with wolves
16
+
17
+ ## Install
18
+
19
+ Just add it to your Gemfile and go!
20
+
21
+ 1. Add it to your `Gemfile`
22
+
23
+ ```ruby
24
+ group :development do
25
+ gem 'great_pretender'
26
+ end
27
+ ```
28
+
29
+ 2. Bundle
30
+
31
+ bundle install
32
+
33
+ ## Configuration
34
+
35
+ You can override two things in Great Pretender:
36
+
37
+ 1. The mockups folder name (default is `mockups`, as in `app/views/mockups`)
38
+ 2. The default layout to render mockups within (default is `application`, as in the one you normally use)
39
+
40
+ You can add `config/initializers/great_pretender.rb` and configure it to your liking:
41
+
42
+ ```ruby
43
+ if defined? GreatPretender
44
+ GreatPretender.config do |c|
45
+ c.default_layout = "public_facing"
46
+ c.view_path = "wireframes"
47
+ end
48
+ end
49
+ ```
50
+
51
+ ## Getting Started
52
+
53
+ ### With the Rails engine
54
+
55
+ If you're just using Great Pretender to pass mockups from designer to developer, you can get started really easily by adding it to `config/routes.rb`:
8
56
 
9
57
  ```ruby
10
- gem 'great_pretender'
58
+ Rails.application.routes.draw do
59
+ mount GreatPretender::Engine, at: 'mockups' if defined?(GreatPretender)
60
+ end
11
61
  ```
12
62
 
13
- And then execute:
63
+ Take care to load it only in the environments you want. Typically I've seen just the development environment, but I also know people who use mockups on staging to show remote clients.
64
+
65
+ ### With your own controller
66
+
67
+ Some people want to have a little bit more control over their mockups (in order to, for example, require an admin account to view them on a staging server).
68
+
69
+ If that's the case, you can create your own controller that uses Great Pretender:
70
+
71
+ 1. Create a controller that uses whatever inheritance you're interested in, and mix `GreatPretender::Controller` into it:
72
+
73
+ ```ruby
74
+ class Admin::MockupsController < Admin::ApplicationController
75
+
76
+ include GreatPretender::Controller
77
+
78
+ before_action :require_admin_user! # or whatever
14
79
 
15
- $ bundle
80
+ layout 'admin' # or whatever
16
81
 
17
- Or install it yourself as:
82
+ end
83
+ ```
18
84
 
19
- $ gem install great_pretender
85
+ 2. Manually add routes to the Great Pretender actions (`index` and `show`). **Please note** that the `show` action requires a `*splat`-style id:
86
+
87
+ ```ruby
88
+ Rails.application.routes.draw do
89
+ namespace :admin do
90
+ # ... your other stuff ...
91
+ get 'mockups', to: 'mockups#index', as: :mockups
92
+ get 'mockups/*id', to: 'mockups#show', as: :mockup
93
+ end
94
+ end
95
+ ```
96
+
97
+ 3. **(OPTIONAL)** Override the `great_pretender/index.html` template to render it in your custom interface.
98
+
99
+ Available helper methods are `mockups` (an array of `GreatPretender::Mockup` objects) and `mockup_root` (the path where you should add mockups).
100
+
101
+ Here's an example:
102
+
103
+ ```
104
+ %ul
105
+ - mockups.each do |mockup|
106
+ %li= link_to mockup.name, admin_mockup_path(mockup)
107
+ ```
20
108
 
21
109
  ## Usage
22
110
 
23
- TODO: Write usage instructions here
111
+ ### Creating mockups
112
+
113
+ Once you've got Great Pretender up and running, you should add some mockups. By default, you would put these in `app/views/mockups`, but if you overrode `view_path` in `GreatPretender.config.view_path`, you would use `app/views/whatever_you_overrode_it_to`.
114
+
115
+ 1. Add a mockup file
116
+
117
+ For example, in `app/views/mockups/users/show.html.slim`:
118
+
119
+ ```
120
+ header= image_tag "logo.png"
121
+ p
122
+ | I can use regular Rails helpers because this is just a template file!
123
+ ' Hooray!
124
+ ```
125
+
126
+ 2. Open your browser and navigate to whatever path you installed Great Pretender on (90% of cases I'm guessing will be in `http://localhost:3000/mockups`). Then click on your mockup.
127
+
128
+ 3. Profit
129
+
130
+ ### Creating partials
131
+
132
+ You can add partials like you would anywhere else. Just prefix them with a skid (`_`) and go from there.
133
+
134
+ By default, partials render **without a layout**, so you can request them using AJAX and receive the HTML free of all that layout cruft.
135
+
136
+ If you *want* to receive a layout as part of it, use a custom layout (see next section) and just request that mockups' path.
137
+
138
+ ### Using alternative layouts
139
+
140
+ If you're designing for a site with multiple layouts, you can simply nest mockup files in a folder with the name of a layout, and they'll be rendered with that layout. For example, with the following structure...
141
+
142
+ ```
143
+ app/
144
+ |- views/
145
+ |--- layouts/
146
+ |----- application.html.slim
147
+ |----- admin.html.slim
148
+ |--- mockups/
149
+ |----- admin/
150
+ |------- index.html.slim
151
+ |------- users/
152
+ |--------- index.html.slim
153
+ ```
154
+
155
+ ...all of the mockups in `app/views/mockups/admin` would render using the `admin` layout.
156
+
157
+ Using this strategy, you can name your mockups clearly after their conceptual section in your app.
158
+
159
+ ## The end!
24
160
 
25
- ## Contributing
161
+ Thanks for using Great Pretender! I hope it helps you like it's helped us!
26
162
 
27
- 1. Fork it ( https://github.com/[my-github-username]/great_pretender/fork )
28
- 2. Create your feature branch (`git checkout -b my-new-feature`)
29
- 3. Commit your changes (`git commit -am 'Add some feature'`)
30
- 4. Push to the branch (`git push origin my-new-feature`)
31
- 5. Create a new Pull Request
163
+ Copyright &copy; 2014 [Back Forty LLC](http://www.inthebackforty.com/)
@@ -62,7 +62,6 @@ module GreatPretender
62
62
  @view_paths.each do |view_path|
63
63
  layout_path = view_path.join('layouts')
64
64
  layout_path = layout_path.join("#{layout}.*#{extensions}")
65
- puts "\n\n\n" + layout_path.inspect + "\n\n\n"
66
65
  return layout if Dir[layout_path].any?
67
66
  end
68
67
  end
@@ -1,3 +1,3 @@
1
1
  module GreatPretender
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: great_pretender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flip Sasser