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' ruby '>=2.3'


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

+ 5
- 5
Gemfile.lock View File

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


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




+ 5
- 0
lib/site.rb View File

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


class Site class Site
def self.generate def self.generate
@@ -25,6 +26,10 @@ class Site
{ summary: summary, last_updated: last_updated }) { summary: summary, last_updated: last_updated })
Petrify.csv(path, 'inlink-summary', summary) 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 # New applications page
apps = ScraperWiki.select("* from `applications` apps = ScraperWiki.select("* from `applications`
order by date_received desc limit 60") order by date_received desc limit 60")


+ 1
- 1
views/layout.haml View File

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

Loading…
Cancel
Save