pwnstyles_rails 0.0.2 → 0.0.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -6,8 +6,18 @@ module PwnstylesRails
6
6
 
7
7
  # rails g pwnstyles_rails:install
8
8
  class InstallGenerator < UpdateGenerator
9
- def stylesheets
10
- copy_stylesheets []
9
+ def staic_assets
10
+ copy_static_assets []
11
+ end
12
+
13
+ def layout
14
+ dir = File.expand_path 'layouts', File.dirname(__FILE__)
15
+ Dir.glob(File.join(dir, '*'), File::FNM_DOTMATCH).each do |source|
16
+ next if File.directory?(source)
17
+ source_file = source[(dir.length + 1)..-1]
18
+ dest = Rails.root.join 'app', 'views', 'layouts', source_file
19
+ copy_file source, dest
20
+ end
11
21
  end
12
22
  end # class PwnstylesRails::AllGenerator
13
23
 
@@ -0,0 +1,18 @@
1
+ <nav>
2
+ <ul>
3
+ <li>
4
+ <a href="#">Footer Link</a>
5
+ <a href="#">Footer Link</a>
6
+ <a href="#">Footer Link</a>
7
+ </li>
8
+ </ul>
9
+ <p class="copyright">
10
+ <%= link_to image_tag('cc_by_nd.png', :alt => 'Creative Commons License'),
11
+ 'http://creativecommons.org/licenses/by-nd/3.0/us/' %>
12
+ &copy; Copyright 2011
13
+ <a href="#">someone</a>
14
+ </p>
15
+ <p class="design">
16
+ Designed by <a href="http://www.costan.us">Victor Costan</a>
17
+ </p>
18
+ </nav>
@@ -0,0 +1,12 @@
1
+ <hgroup>
2
+ <h1>
3
+ <%= image_tag 'logo.png', :alt => '' %>
4
+ <span class="app-name">
5
+ App Name
6
+ </span>
7
+ </h1>
8
+
9
+ <% if current_user %>
10
+ <%= render 'layouts/menu' %>
11
+ <% end %>
12
+ </hgroup>
@@ -0,0 +1,22 @@
1
+ <nav>
2
+ <ol>
3
+ <li>
4
+ <%= link_to 'Submenu', '#' %>
5
+ <ol>
6
+ <li><%= link_to 'Item 1', '#' %></li>
7
+ <li><%= link_to 'Item 2', '#' %></li>
8
+ <li><%= link_to 'Item 3', '#' %></li>
9
+ </ol>
10
+ </li>
11
+ <li>
12
+ <%= link_to 'Action', '#' %>
13
+ </li>
14
+ <li>
15
+ <%= link_to 'username', '#' %>
16
+ <ol>
17
+ <li><%= link_to 'Sign out', '#' %></li>
18
+ <li><%= link_to 'Settings', '#' %></li>
19
+ </ol>
20
+ </li>
21
+ </ol>
22
+ </nav>
@@ -0,0 +1,19 @@
1
+ <% if flash[:error] %>
2
+ <p class="status-bar error" data-pwnfx-reveal-target="status-bar">
3
+ <%= flash[:error] %>
4
+
5
+ <span class="actions">
6
+ <%= link_to 'Hide', '#', 'data-pwnfx-reveal' => 'status-bar',
7
+ 'data-pwnfx-reveal-trigger' => 'click-hide' %>
8
+ </span>
9
+ </p>
10
+ <% elsif flash[:notice] %>
11
+ <p class="status-bar notice" data-pwnfx-reveal-target="status-bar">
12
+ <%= flash[:notice] %>
13
+
14
+ <span class="actions">
15
+ <%= link_to 'Hide', '#', 'data-pwnfx-reveal' => 'status-bar',
16
+ 'data-pwnfx-reveal-trigger' => 'click-hide' %>
17
+ </span>
18
+ </p>
19
+ <% end %>
@@ -0,0 +1,28 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>App Name</title>
5
+ <%= csrf_meta_tag %>
6
+ <%= favicon_link_tag %>
7
+ <%= stylesheet_link_tag :pwnstyles, :cache => true %>
8
+ <%= javascript_include_tag :all, :cache => true %>
9
+ </head>
10
+ <body>
11
+ <header>
12
+ <%= render 'layouts/header' %>
13
+ </header>
14
+
15
+ <div id="real-body">
16
+ <%= render 'layouts/status_bar' %>
17
+ <div id="content-wrapper">
18
+ <article id="main">
19
+ <%= yield %>
20
+ </article>
21
+ </div>
22
+ </div>
23
+
24
+ <footer>
25
+ <%= render 'layouts/footer' %>
26
+ </footer>
27
+ </body>
28
+ </html>
@@ -6,21 +6,27 @@ module PwnstylesRails
6
6
 
7
7
  # rails g pwnstyles_rails:update
8
8
  class UpdateGenerator < Rails::Generators::Base
9
- def stylesheets
10
- copy_stylesheets ['scss/vars/_app.scss']
9
+ def static_assets
10
+ copy_static_assets ['scss/vars/_app.scss']
11
11
  end
12
12
 
13
13
 
14
14
  private
15
15
 
16
- def copy_stylesheets(exclude_list = [])
17
- dir = File.expand_path '../../../public/stylesheets', File.dirname(__FILE__)
16
+ def copy_static_assets(exclude_list = [])
17
+ copy_dir 'public/stylesheets', 'public/pwnstyles/stylesheets'
18
+ copy_dir 'public/javascripts', 'public/javascripts'
19
+ end
20
+
21
+ def copy_dir(source_dir, destination_dir, exclude_list = [])
22
+ dir = File.expand_path File.join('../../..', source_dir),
23
+ File.dirname(__FILE__)
18
24
  Dir.glob(File.join(dir, '**', '*'), File::FNM_DOTMATCH).each do |source|
19
25
  next if File.directory?(source)
20
26
  source_file = source[(dir.length + 1)..-1]
21
27
  next if exclude_list.include?(source_file)
22
28
 
23
- dest = Rails.root.join 'public', 'pwnstyles', 'stylesheets', source_file
29
+ dest = Rails.root.join destination_dir, source_file
24
30
  copy_file source, dest
25
31
  end
26
32
  end
@@ -0,0 +1,160 @@
1
+ /**
2
+ * PwnFx: AJAX sprinkles via unobtrusive JavaScript.
3
+ * @author Victor Costan
4
+ *
5
+ * The author sorely misses Rails' AJAX helpers such as observe_field. This
6
+ * library provides a replacement that adheres to the new philosophy of
7
+ * unobtrusive JavaScript triggered by HTML5 data- attributes.
8
+ */
9
+
10
+
11
+ /** Namespace. */
12
+ var PwnFx = {};
13
+
14
+ /** Wires JS to elements with data-pwnfx attributes. */
15
+ PwnFx.wireAll = function () {
16
+ $('[data-pwnfx-move]').each(function (_, element) {
17
+ PwnFx.wireMove(element);
18
+ });
19
+
20
+ $('[data-pwnfx-refresh-url]').each(function (_, element) {
21
+ PwnFx.wireRefresh(element);
22
+ });
23
+ $('[data-pwnfx-confirm]').each(function (_, element) {
24
+ PwnFx.wireConfirm(element);
25
+ });
26
+ $('[data-pwnfx-reveal]').each(function (_, element) {
27
+ PwnFx.wireReveal(element);
28
+ });
29
+ };
30
+
31
+ /** Wires JS to an AJAX refresh element that uses data-pwnfx-refresh-url. */
32
+ PwnFx.wireRefresh = function (element) {
33
+ var jElement = $(element);
34
+ var xhrUrl = jElement.attr('data-pwnfx-refresh-url');
35
+ jElement.attr('data-pwnfx-refresh-url-done', xhrUrl);
36
+ jElement.removeAttr('data-pwnfx-refresh-url');
37
+
38
+ var targetSelector = '#' + jElement.attr('data-pwnfx-refresh-target');
39
+ var refreshInterval =
40
+ parseInt(jElement.attr('data-pwnfx-refresh-ms') || '200');
41
+ var xhrMethod = jElement.attr('data-pwnfx-refresh-method') || 'POST';
42
+ var form = $(jElement.parents('form')[0]);
43
+ var onXhrSuccessFn = function (data) {
44
+ $(targetSelector).html(data);
45
+ };
46
+ var refreshPending = false;
47
+ var refreshOldValue = null;
48
+ var ajaxRefreshFn = function () {
49
+ refreshPending = false;
50
+ $.ajax({
51
+ data: form.serialize(), success: onXhrSuccessFn,
52
+ dataType: 'html', type: xhrMethod, url: xhrUrl
53
+ });
54
+ };
55
+ var onChangeFn = function () {
56
+ var value = jElement.val();
57
+ if (value == refreshOldValue) {
58
+ return;
59
+ } else {
60
+ refreshOldValue = value;
61
+ }
62
+ if (refreshPending) {
63
+ return;
64
+ } else {
65
+ refreshPending = true;
66
+ setTimeout(ajaxRefreshFn, refreshInterval);
67
+ }
68
+ };
69
+
70
+ jElement.bind('change', onChangeFn);
71
+ jElement.bind('keydown', onChangeFn);
72
+ jElement.bind('keyup', onChangeFn);
73
+ onChangeFn();
74
+ };
75
+
76
+ /**
77
+ * Wires JS to an AJAX confirmation check element using data-pwnfx-confirm.
78
+ */
79
+ PwnFx.wireConfirm = function (element) {
80
+ var jElement = $(element);
81
+ var identifier = jElement.attr('data-pwnfx-confirm');
82
+ var sourceSelector = '[data-pwnfx-confirm="' + identifier + '"]'
83
+ var winSelector = '[data-pwnfx-confirm-win="' + identifier + '"]';
84
+ var failSelector = '[data-pwnfx-confirm-fail="' + identifier + '"]';
85
+
86
+ var onChangeFn = function () {
87
+ var value = null;
88
+ var matching = true;
89
+ $(sourceSelector).each(function (index, element) {
90
+ var val = $(element).val();
91
+ value = value || val;
92
+ if (value != val) {
93
+ matching = false;
94
+ }
95
+ if (matching) {
96
+ $(winSelector).removeClass('hidden');
97
+ $(failSelector).addClass('hidden');
98
+ } else {
99
+ $(winSelector).addClass('hidden');
100
+ $(failSelector).removeClass('hidden');
101
+ }
102
+ });
103
+ };
104
+ jElement.bind('change', onChangeFn);
105
+ jElement.bind('keydown', onChangeFn);
106
+ jElement.bind('keyup', onChangeFn);
107
+ onChangeFn();
108
+ };
109
+
110
+ /** Moves an element using data-pwnfx-move. */
111
+ PwnFx.wireMove = function (element) {
112
+ var jElement = $(element);
113
+ var identifier = jElement.attr('data-pwnfx-move');
114
+ jElement.attr('data-pwnfx-move-done', identifier);
115
+ jElement.removeAttr('data-pwnfx-move');
116
+
117
+ var targetSelector = '[data-pwnfx-move-target="' + identifier + '"]';
118
+ var jTarget = $(targetSelector).first();
119
+ jElement.detach();
120
+ jTarget.append(jElement);
121
+ };
122
+
123
+ /** Wires JS to an AJAX show/hide trigger using data-pwnfx-reveal. */
124
+ PwnFx.wireReveal = function (element) {
125
+ var jElement = $(element);
126
+ var identifier = jElement.attr('data-pwnfx-reveal');
127
+ jElement.attr('data-pwnfx-reveal-done', identifier);
128
+ jElement.removeAttr('data-pwnfx-reveal');
129
+
130
+ var trigger = jElement.attr('data-pwnfx-reveal-trigger') || 'click';
131
+ var showOnCheck = true;
132
+ if (trigger == 'uncheck') {
133
+ trigger = 'check';
134
+ showOnCheck = false;
135
+ } else if (trigger == 'click-hide') {
136
+ trigger = 'click';
137
+ showOnCheck = false;
138
+ }
139
+ var targetSelector = '[data-pwnfx-reveal-target="' + identifier + '"]';
140
+
141
+ var onChangeFn = function () {
142
+ var checked = (trigger == 'click') || jElement.is(':checked');
143
+ var willShow = (checked == showOnCheck);
144
+ if (willShow) {
145
+ $(targetSelector).removeClass('hidden');
146
+ } else {
147
+ $(targetSelector).addClass('hidden');
148
+ }
149
+ };
150
+
151
+ if (trigger == 'click') {
152
+ jElement.bind('click', onChangeFn);
153
+ } else if (trigger = 'check') {
154
+ jElement.bind('change', onChangeFn);
155
+ onChangeFn();
156
+ }
157
+ };
158
+
159
+ // Wire JS to elements when the document is loaded.
160
+ $(PwnFx.wireAll);
@@ -4,11 +4,13 @@ body {
4
4
  background: $footer-background-color2;
5
5
  }
6
6
 
7
+ #real-body {
8
+ background-color: #ffffff;
9
+ }
10
+
7
11
  #content-wrapper {
8
12
  margin: 0 auto;
9
13
  padding: 0 0 24px 0;
10
14
  width: $page-width;
11
15
  overflow: hidden;
12
- background: #ffffff;
13
16
  }
14
-
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pwnstyles_rails}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Victor Costan"]
12
- s.date = %q{2011-04-25}
12
+ s.date = %q{2011-04-26}
13
13
  s.description = %q{Included CSS was designed for reuse across pwnb.us apps.}
14
14
  s.email = %q{victor@costan.us}
15
15
  s.extra_rdoc_files = [
@@ -29,7 +29,13 @@ Gem::Specification.new do |s|
29
29
  "lib/pwnstyles_rails.rb",
30
30
  "lib/pwnstyles_rails/engine.rb",
31
31
  "lib/pwnstyles_rails/generators/install_generator.rb",
32
+ "lib/pwnstyles_rails/generators/layouts/_footer.html.erb",
33
+ "lib/pwnstyles_rails/generators/layouts/_header.html.erb",
34
+ "lib/pwnstyles_rails/generators/layouts/_menu.html.erb",
35
+ "lib/pwnstyles_rails/generators/layouts/_status_bar.html.erb",
36
+ "lib/pwnstyles_rails/generators/layouts/application.html.erb",
32
37
  "lib/pwnstyles_rails/generators/update_generator.rb",
38
+ "public/javascripts/pwn-fx.js",
33
39
  "public/stylesheets/.gitignore",
34
40
  "public/stylesheets/scss/generic/_controls.scss",
35
41
  "public/stylesheets/scss/generic/_links.scss",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwnstyles_rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Victor Costan
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-25 00:00:00 Z
18
+ date: 2011-04-26 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -131,7 +131,13 @@ files:
131
131
  - lib/pwnstyles_rails.rb
132
132
  - lib/pwnstyles_rails/engine.rb
133
133
  - lib/pwnstyles_rails/generators/install_generator.rb
134
+ - lib/pwnstyles_rails/generators/layouts/_footer.html.erb
135
+ - lib/pwnstyles_rails/generators/layouts/_header.html.erb
136
+ - lib/pwnstyles_rails/generators/layouts/_menu.html.erb
137
+ - lib/pwnstyles_rails/generators/layouts/_status_bar.html.erb
138
+ - lib/pwnstyles_rails/generators/layouts/application.html.erb
134
139
  - lib/pwnstyles_rails/generators/update_generator.rb
140
+ - public/javascripts/pwn-fx.js
135
141
  - public/stylesheets/.gitignore
136
142
  - public/stylesheets/scss/generic/_controls.scss
137
143
  - public/stylesheets/scss/generic/_links.scss