table_setter 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 1
2
+ :patch: 2
3
3
  :build:
4
4
  :major: 0
5
5
  :minor: 2
@@ -225,10 +225,12 @@ script/generate table-setter</pre>
225
225
  <h2><a id="credits" href="#toc">Credits</a></h2>
226
226
  <p><a href="http://github.com/thejefflarson">Jeff Larson</a> (Maintainer), <a href="http://github.com/brianboyer/">Brian Boyer</a>, <a href="http://github.com/kleinmatic">Scott Klein</a>, <a href="http://github.com/markpercival">Mark Percival</a>, <a href="http://github.com/seebq">Charles Brian Quinn</a>, <a href="http://github.com/bouvard">Christopher Groskopf</a>, and <a href="http://github.com/ryanmark">Ryan Mark</a>.</p>
227
227
  <h2><a id="changes" href="#toc">Change Log</a></h2>
228
+ <strong>0.2.2</strong>
229
+ <p>Fixing long standing bug with empty prefixes in the <strong>build</strong> command.</p>
228
230
  <strong>0.2.1</strong>
229
231
  <p>Table Urls have an optional trailing slash. Fixes a bug in <strong>0.2.0</strong></p>
230
232
  <strong>0.2.0</strong>
231
- <p><del><b>Backwards incompatible change:</b> Table urls no longer end in a trailing slash. Please the <strong>url_for</strong> calls in your templates to reflect the change.</del></p>
233
+ <p>It's recommended not to use this version. <del><b>Backwards incompatible change:</b> Table urls no longer end in a trailing slash. Please modify the <strong>url_for</strong> calls in your templates to reflect the change.</del></p>
232
234
  <strong>0.1.11</strong>
233
235
  <p>Javascript Fixes. <b>Note:</b> You'll need to delete the javascript's folder in the config directory and run <strong>table-setter install</strong> to grab the changes.</p>
234
236
  <strong>0.1.10</strong>
data/index.html CHANGED
@@ -8,7 +8,7 @@
8
8
  </head>
9
9
  <body>
10
10
  <a href="http://www.propublica.org" class="propublica">&nbsp;</a>
11
- <h1>TableSetter <small>&ndash; Version: 0.2.0</small></h1>
11
+ <h1>TableSetter <small>&ndash; Version: 0.2.2</small></h1>
12
12
  <p><a href="https://github.com/propublica/table-setter">TableSetter</a> is a Ruby app that provides an easy way to present CSVs hosted locally or remotely (e.g. on google, etc) in custom HTML. TableSetter in the wild: <a href="http://projects.propublica.org/tables/failed-banks">a list of all stimulus projects from last year</a>, <a href="http://projects.propublica.org/tables/stimulus-spending-progress">the stimulus spending progress</a>, or <a href="http://projects.propublica.org/tables/failed-banks">a list of failed banks due to the last recession</a>.</p>
13
13
  <p>Each table is filterable and sortable on multiple columns. Also each column can be formatted in one of many different styles. In production mode, <strong>TableSetter</strong> provides valid expires headers and can be coupled with an upstream cache like <a href="http://rtomayko.github.com/rack-cache/">Rack::Cache</a> or varnish for speedy presentation.</p>
14
14
  <h2><a id="toc">Table of Contents</a></h2>
@@ -222,10 +222,12 @@ script/generate table-setter</pre>
222
222
  <h2><a id="credits" href="#toc">Credits</a></h2>
223
223
  <p><a href="http://github.com/thejefflarson">Jeff Larson</a> (Maintainer), <a href="http://github.com/brianboyer/">Brian Boyer</a>, <a href="http://github.com/kleinmatic">Scott Klein</a>, <a href="http://github.com/markpercival">Mark Percival</a>, <a href="http://github.com/seebq">Charles Brian Quinn</a>, <a href="http://github.com/bouvard">Christopher Groskopf</a>, and <a href="http://github.com/ryanmark">Ryan Mark</a>.</p>
224
224
  <h2><a id="changes" href="#toc">Change Log</a></h2>
225
+ <strong>0.2.2</strong>
226
+ <p>Fixing long standing bug with empty prefixes in the <strong>build</strong> command.</p>
225
227
  <strong>0.2.1</strong>
226
228
  <p>Table Urls have an optional trailing slash. Fixes a bug in <strong>0.2.0</strong></p>
227
229
  <strong>0.2.0</strong>
228
- <p><del><b>Backwards incompatible change:</b> Table urls no longer end in a trailing slash. Please the <strong>url_for</strong> calls in your templates to reflect the change.</del></p>
230
+ <p>It's recommended not to use this version. <del><b>Backwards incompatible change:</b> Table urls no longer end in a trailing slash. Please modify the <strong>url_for</strong> calls in your templates to reflect the change.</del></p>
229
231
  <strong>0.1.11</strong>
230
232
  <p>Javascript Fixes. <b>Note:</b> You'll need to delete the javascript's folder in the config directory and run <strong>table-setter install</strong> to grab the changes.</p>
231
233
  <strong>0.1.10</strong>
@@ -11,19 +11,20 @@ table-setter is a Sinatra application for rendering and processing CSVs from goo
11
11
 
12
12
  Usage:
13
13
  table-setter COMMAND path/to/table-setter/assets OPTIONS
14
-
14
+
15
15
  commands:
16
16
  start run the development server, for deployment use config.ru
17
17
  install copy the table-setter assets into the the directory
18
18
  build statically build tables in the ./out/ directory
19
-
19
+
20
20
  options:
21
21
  EOB
22
-
23
-
22
+
23
+
24
24
  def initialize
25
25
  @prefix = ""
26
26
  parse_options
27
+ @prefix = "/#{@prefix}/".gsub(/^\/\//, "/")
27
28
  command = ARGV.shift
28
29
  @directory = ARGV.shift || '.'
29
30
  TableSetter.configure @directory
@@ -34,12 +35,12 @@ options:
34
35
  else puts BANNER
35
36
  end
36
37
  end
37
-
38
+
38
39
  def start_server
39
40
  app = build_rack
40
41
  Rack::Handler::Thin.run app, :Port => "3000"
41
42
  end
42
-
43
+
43
44
  def install_assets
44
45
  FileUtils.mkdir_p @directory unless File.exists? @directory
45
46
  puts "\nInstalling TableSetter files...\n\n"
@@ -47,19 +48,17 @@ options:
47
48
  copy_file path, File.join(TableSetter.config_path, path.gsub(ROOT + "/template/", "/"))
48
49
  end
49
50
  end
50
-
51
51
 
52
-
53
52
  def build_out
54
53
  @out_dir = File.join(TableSetter.config_path, 'out', @prefix)
55
54
  puts "\nBuilding your TableSetter files...\n\n"
56
55
  app = build_rack
57
- request = Rack::MockRequest.new(app)
58
- build_index request
56
+ @request = Rack::MockRequest.new(app)
57
+ build_index
59
58
  build_assets
60
- build_tables request
59
+ build_tables
61
60
  end
62
-
61
+
63
62
  private
64
63
  # Option parsing
65
64
  def parse_options
@@ -72,11 +71,11 @@ options:
72
71
  @option_parser.banner = BANNER
73
72
  @option_parser.parse! ARGV
74
73
  end
75
-
74
+
76
75
  def build_rack
77
76
  prefix = @prefix
78
77
  Rack::Builder.app do
79
- map "/#{prefix}" do
78
+ map prefix do
80
79
  use Rack::CommonLogger, STDERR
81
80
  use Rack::ShowExceptions
82
81
  use Rack::Lint
@@ -84,57 +83,57 @@ options:
84
83
  end
85
84
  end
86
85
  end
87
-
88
- def build_index(request)
89
- install_file(request.request("GET", "/#{@prefix}/").body,
86
+
87
+ def build_index
88
+ install_file(@request.request("GET", "#{@prefix}").body,
90
89
  File.join(@out_dir, "index.html"))
91
90
  end
92
-
91
+
93
92
  def build_assets
94
93
  Dir[TableSetter.config_path + "/public/**/*"].each do |path|
95
94
  copy_file path, File.join(path.gsub(TableSetter.config_path + "/public/", "#{@out_dir}/"))
96
95
  end
97
96
  end
98
-
99
- def build_tables(request)
97
+
98
+ def build_tables
100
99
  TableSetter::Table.all.each do |table|
101
100
  return if !table.live
102
101
  puts "Building #{table.slug}"
103
- install_file(request.request("GET", "/#{@prefix}/#{table.slug}/").body,
102
+ install_file(@request.request("GET", "#{@prefix}#{table.slug}/").body,
104
103
  File.join(@out_dir, table.slug, "index.html"))
105
104
  if table.hard_paginate?
106
105
  table.load
107
106
  (1..table.total_pages).each do |page|
108
107
  puts "Building #{table.slug} #{page} of #{table.total_pages}"
109
- install_file(request.request("GET", "/#{@prefix}/#{table.slug}/#{page}/").body,
108
+ install_file(@request.request("GET", "#{@prefix}#{table.slug}/#{page}/").body,
110
109
  File.join(@out_dir, table.slug, page.to_s, "index.html"))
111
110
  end
112
111
  end
113
112
  end
114
113
  end
115
-
114
+
116
115
  def base_files
117
116
  Dir[ROOT + "/template/**/*"]
118
117
  end
119
-
118
+
120
119
  def copy_file(source, dest)
121
120
  ensure_directory dest
122
121
  exists = File.exists? dest
123
122
  FileUtils.cp_r(source, dest) unless exists
124
123
  puts "#{exists ? "exists" : "created"}\t#{dest}"
125
124
  end
126
-
125
+
127
126
  def ensure_directory(dest)
128
127
  expanded_path = File.dirname dest
129
128
  FileUtils.mkdir_p(expanded_path) unless File.exists?(expanded_path)
130
129
  end
131
-
130
+
132
131
  def install_file(body, dest)
133
132
  ensure_directory dest
134
133
  File.open(dest, "w") do |file|
135
134
  file.write(body)
136
135
  end
137
136
  end
138
-
137
+
139
138
  end
140
- end
139
+ end
data/table_setter.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{table_setter}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Larson"]
@@ -1,7 +1,7 @@
1
1
  <ul>
2
2
  <% for table in tables %>
3
3
  <li>
4
- <a href="<%= url_for "/#{table.slug/}" %>"><%= table.title %></a>
4
+ <a href="<%= url_for "/#{table.slug}/" %>"><%= table.title %></a>
5
5
  </li>
6
6
  <% end %>
7
7
  </ul>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_setter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeff Larson