Browse Source

Generate local JSON file for all applications

main
Adrian Short 5 years ago
parent
commit
cca68e95c3
4 changed files with 12 additions and 7 deletions
  1. +1
    -1
      Gemfile
  2. +5
    -5
      Gemfile.lock
  3. +5
    -0
      lib/site.rb
  4. +1
    -1
      views/layout.haml

+ 1
- 1
Gemfile View File

@@ -3,6 +3,6 @@ source 'https://rubygems.org'
ruby '>=2.3'

gem 'scraperwiki', :git => 'https://github.com/openaustralia/scraperwiki-ruby/', :branch => 'morph_defaults'
gem 'petrify'
gem 'petrify', '>= 0.4.0'
gem 'rest-client'
gem 'json'

+ 5
- 5
Gemfile.lock View File

@@ -12,7 +12,7 @@ GEM
specs:
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
haml (5.0.4)
haml (5.1.2)
temple (>= 0.8.0)
tilt
http-cookie (1.0.3)
@@ -23,7 +23,7 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
netrc (0.11.0)
petrify (0.3.1)
petrify (0.4.0)
haml (~> 5.0)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
@@ -32,8 +32,8 @@ GEM
sqlite3 (1.3.13)
sqlite_magic (0.0.6)
sqlite3
temple (0.8.0)
tilt (2.0.8)
temple (0.8.2)
tilt (2.0.10)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
@@ -43,7 +43,7 @@ PLATFORMS

DEPENDENCIES
json
petrify
petrify (>= 0.4.0)
rest-client
scraperwiki!



+ 5
- 0
lib/site.rb View File

@@ -1,6 +1,7 @@
require 'scraperwiki'
require 'petrify'
require 'csv'
require 'json'

class Site
def self.generate
@@ -25,6 +26,10 @@ class Site
{ summary: summary, last_updated: last_updated })
Petrify.csv(path, 'inlink-summary', summary)

# Generate a JSON file with all the data
apps = ScraperWiki.select("* from applications")
Petrify.file(path, 'data.json', apps.to_json)

# New applications page
apps = ScraperWiki.select("* from `applications`
order by date_received desc limit 60")


+ 1
- 1
views/layout.haml View File

@@ -42,7 +42,7 @@
Source code
%a{ :href => 'https://www.adrianshort.org/tags/inlinkuk/'}<
InLink blog posts
%a{ :href => 'https://git.adrianshort.org/data.json'}<
%a{ :href => '/data.json'}<
JSON bulk download
%a{ :href => 'https://twitter.com/search?f=tweets&vertical=default&q=%23inlink'}<
\#InLink on Twitter

Loading…
Cancel
Save