Skip to content

Commit

Permalink
added api landing page. #160
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Dec 15, 2018
1 parent dcad2f3 commit 9380d23
Show file tree
Hide file tree
Showing 23 changed files with 441 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ capybara-*.html
/tmp/*
/data/*
/db/*.sqlite3
/public/system/*
public/assets
/public/*
!/public/.keep
/coverage/
/spec/tmp/
/config/data_bags/*
Expand Down
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN bash -lc 'rvm --default use ruby-2.4.4'

# Update installed APT packages
RUN apt-get update && apt-get upgrade -y -o Dpkg::Options::="--force-confold" && \
apt-get install ntp wget tzdata -y && \
apt-get install ntp wget tzdata pandoc -y && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# install dockerize
Expand Down Expand Up @@ -53,12 +53,18 @@ RUN mkdir -p tmp/pids && \
chown -R app:app /home/app/webapp && \
chmod -R 755 /home/app/webapp

# Install Ruby gems for middleman
WORKDIR /home/app/webapp/vendor/middleman
RUN /sbin/setuser app bundle install

# Add Runit script for shoryuken workers
WORKDIR /home/app/webapp
RUN mkdir /etc/service/shoryuken
ADD vendor/docker/shoryuken.sh /etc/service/shoryuken/run

# Run additional scripts during container startup (i.e. not at build time)
RUN mkdir -p /etc/my_init.d
COPY vendor/docker/70_index_page.sh /etc/my_init.d/70_index_page.sh
COPY vendor/docker/80_flush_cache.sh /etc/my_init.d/80_flush_cache.sh
COPY vendor/docker/90_migrate.sh /etc/my_init.d/90_migrate.sh

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ gem 'rails', '~> 5.2.0'
gem 'bootsnap', '~> 1.2', '>= 1.2.1'
gem 'mysql2', '~> 0.4.4'
gem 'dotenv'
gem 'rake', '~> 12.0'
gem 'multi_json'
gem 'json', '~> 1.8', '>= 1.8.5'
gem 'oj', '>= 2.8.3'
Expand Down
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ DEPENDENCIES
rack-cors (~> 1.0, >= 1.0.2)
rack-utf8_sanitizer (~> 1.6)
rails (~> 5.2.0)
rake (~> 12.0)
rspec-rails (~> 3.5, >= 3.5.2)
shoryuken (~> 4.0)
shoulda-matchers (~> 3.1)
Expand Down
1 change: 0 additions & 1 deletion app/controllers/index_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class IndexController < ApplicationController
before_action :set_doi, only: [:show]

def index
authorize! :index, :Index
render plain: ENV['SITE_TITLE']
end

Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
ENV['APPLICATION'] ||= "client-api"
ENV['HOSTNAME'] ||= "lupo"
ENV['MEMCACHE_SERVERS'] ||= "memcached:11211"
ENV['SITE_TITLE'] ||= "REST API"
ENV['SITE_TITLE'] ||= "DataCite REST API"
ENV['LOG_LEVEL'] ||= "info"
ENV['CONCURRENCY'] ||= "25"
ENV['CDN_URL'] ||= "https://assets.datacite.org"
Expand Down
3 changes: 1 addition & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
post 'provider-prefixes/set-created', :to => 'provider_prefixes#set_created'

resources :heartbeat, only: [:index]
resources :index, only: [:index]

resources :clients, constraints: { :id => /.+/ } do
resources :prefixes, constraints: { :id => /.+/ }
Expand Down Expand Up @@ -79,8 +80,6 @@
resources :data_centers, only: [:show, :index], constraints: { :id => /.+/ }, path: "/data-centers"
resources :works, only: [:show, :index], constraints: { :id => /.+/ }

resources :index, path: '/', constraints: { :id => /.+/ }, only: [:index]

# rescue routing errors
#match "*path", to: "index#routing_error", via: :all
end
Empty file added public/.keep
Empty file.
1 change: 0 additions & 1 deletion public/robots.txt

This file was deleted.

3 changes: 3 additions & 0 deletions vendor/docker/70_index_page.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
cd vendor/middleman
/sbin/setuser app bundle exec middleman build -e ${RAILS_ENV}
12 changes: 12 additions & 0 deletions vendor/middleman/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# If you do not have OpenSSL installed, change
# the following line to use 'http://'
source 'https://rubygems.org'

# Middleman Gems
gem 'middleman', "~> 4.1"
gem 'tilt', '~> 2.0', git: "https://github.com/datacite/tilt.git", branch: "pandoc-options"
gem 'tilt-handlebars', '~> 1.4'
gem 'middleman-data_source', '~> 0.8.1'
gem 'middleman-livereload'
gem 'middleman-syntax', '~> 2.0'
gem 'pandoc-ruby', '~> 2.0'
149 changes: 149 additions & 0 deletions vendor/middleman/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
GIT
remote: https://github.com/datacite/tilt.git
revision: 612652f9d03ff3c129c415b1826fb84b0c7a0845
branch: pandoc-options
specs:
tilt (2.0.5)

GEM
remote: https://rubygems.org/
specs:
activesupport (5.0.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
backports (3.10.3)
borrower (0.10.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
compass-import-once (1.0.5)
sass (>= 3.2, < 3.5)
concurrent-ruby (1.0.5)
contracts (0.13.0)
dotenv (2.2.1)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
erubis (2.7.0)
eventmachine (1.2.5)
execjs (2.7.0)
fast_blank (1.0.0)
fastimage (2.1.1)
ffi (1.9.18)
haml (5.0.4)
temple (>= 0.8.0)
tilt
hamster (3.0.0)
concurrent-ruby (~> 1.0)
handlebars (0.8.0)
handlebars-source (~> 4.0.5)
therubyracer (~> 0.12.1)
handlebars-source (4.0.11)
hashie (3.5.7)
http_parser.rb (0.6.0)
i18n (0.7.0)
kramdown (1.16.2)
libv8 (3.16.14.19)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
memoist (0.16.0)
middleman (4.2.1)
coffee-script (~> 2.2)
compass-import-once (= 1.0.5)
haml (>= 4.0.5)
kramdown (~> 1.2)
middleman-cli (= 4.2.1)
middleman-core (= 4.2.1)
sass (>= 3.4.0, < 4.0)
middleman-cli (4.2.1)
thor (>= 0.17.0, < 2.0)
middleman-core (4.2.1)
activesupport (>= 4.2, < 5.1)
addressable (~> 2.3)
backports (~> 3.6)
bundler (~> 1.1)
contracts (~> 0.13.0)
dotenv
erubis
execjs (~> 2.0)
fast_blank
fastimage (~> 2.0)
hamster (~> 3.0)
hashie (~> 3.4)
i18n (~> 0.7.0)
listen (~> 3.0.0)
memoist (~> 0.14)
padrino-helpers (~> 0.13.0)
parallel
rack (>= 1.4.5, < 3)
sass (>= 3.4)
servolux
tilt (~> 2.0)
uglifier (~> 3.0)
middleman-data_source (0.8.1)
borrower (~> 0.9)
middleman (>= 3.1)
rack-test (~> 0.6.2)
middleman-livereload (3.4.6)
em-websocket (~> 0.5.1)
middleman-core (>= 3.3)
rack-livereload (~> 0.3.15)
middleman-syntax (2.1.0)
middleman-core (>= 3.2)
rouge (~> 1.0)
minitest (5.10.3)
padrino-helpers (0.13.3.4)
i18n (~> 0.6, >= 0.6.7)
padrino-support (= 0.13.3.4)
tilt (>= 1.4.1, < 3)
padrino-support (0.13.3.4)
activesupport (>= 3.1)
pandoc-ruby (2.0.2)
parallel (1.12.1)
public_suffix (3.0.1)
rack (2.0.3)
rack-livereload (0.3.16)
rack
rack-test (0.6.3)
rack (>= 1.0)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
ref (2.0.0)
rouge (1.11.1)
sass (3.4.25)
servolux (0.13.0)
temple (0.8.0)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (0.20.0)
thread_safe (0.3.6)
tilt-handlebars (1.4.0)
handlebars (~> 0.7)
tilt (>= 1.3, < 3)
tzinfo (1.2.4)
thread_safe (~> 0.1)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)

PLATFORMS
ruby

DEPENDENCIES
middleman (~> 4.1)
middleman-data_source (~> 0.8.1)
middleman-livereload
middleman-syntax (~> 2.0)
pandoc-ruby (~> 2.0)
tilt (~> 2.0)!
tilt-handlebars (~> 1.4)

BUNDLED WITH
1.16.0
52 changes: 52 additions & 0 deletions vendor/middleman/config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
###
# Page options, layouts, aliases and proxies
###

# Default ENV variables
ENV['CDN_URL'] ||= "https://assets.datacite.org"
ENV['RAILS_ENV'] ||= "development"
ENV['SITE_TITLE'] ||= "DataCite REST API"
ENV['SITE_DESCRIPTION'] ||= "The DataCite API."
ENV['TWITTER_HANDLE'] ||= "@datacite"

# Build into /public
set :build_dir, "../../public"

# Per-page layout changes:
#
# With no layout
page '/*.xml', layout: false
page '/*.json', layout: false
page '/*.txt', layout: false

# General configuration

# Reload the browser automatically whenever files change
configure :development do
activate :livereload
end

# Load data
activate :data_source do |c|
c.root = "#{ENV['CDN_URL']}/data"
c.files = [
"links.json"
]
end

# Set markdown template engine
set :markdown_engine, :pandoc
set :markdown, smartypants: true

# use asset host
activate :asset_host, host: ENV['CDN_URL']

###
# Helpers
###
# Methods defined in the helpers block are available in templates
helpers do
def stage?
ENV['RAILS_ENV'] == "stage"
end
end
11 changes: 11 additions & 0 deletions vendor/middleman/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'middleman-core/load_paths'
::Middleman.setup_load_paths

require 'middleman-core'
require 'middleman-core/rack'

require 'fileutils'

app = ::Middleman::Application.new

run ::Middleman::Rack.new(app).to_app
File renamed without changes.
61 changes: 61 additions & 0 deletions vendor/middleman/source/includes/_footer.html.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<footer class='row footer'>
<div class="container-fluid">
<div class='col-md-3 col-sm-4'>
<h4>About DataCite</h4>
<ul>
{{#each about_links}}
<li><a href="{{this.url}}">{{this.name}}</a></li>
{{/each}}
</ul>
</div>
<div class='col-md-3 col-sm-4'>
<h4>Services</h4>
<ul>
{{#each services_links}}
<li><a href="{{this.url}}">{{this.name}}</a></li>
{{/each}}
</ul>
</div>
<div class='col-md-3 col-sm-4'>
<h4>Resources</h4>
<ul>
{{#each resources_links}}
<li><a href="{{this.url}}">{{this.name}}</a></li>
{{/each}}
</ul>
<h4>Community</h4>
<ul>
{{#each community_links}}
<li><a href="{{this.url}}">{{this.name}}</a></li>
{{/each}}
</ul>
</div>
<div class='col-md-3'>
<h4 class="share">Contact us</h4>
<a href='mailto:[email protected]' class="share">
<i class='fa fa-at'></i>
</a>
<a href='https://blog.datacite.org' class="share">
<i class='fa fa-rss'></i>
</a>
<a href='https://twitter.com/datacite' class="share">
<i class='fa fa-twitter'></i>
</a>
<a href='https://github.com/datacite/datacite' class="share">
<i class='fa fa-github'></i>
</a>
<a href='https://www.linkedin.com/company/datacite' class="share">
<i class='fa fa-linkedin'></i>
</a>
<ul>
{{#each contact_links}}
<li><a href="{{this.url}}">{{this.name}}</a></li>
{{/each}}
</ul>
<a href="http://status.datacite.org" target="_blank">
<span class="color-dot"></span>
<span class="color-description"></span>
</a>
</div>
</div>
</footer>
9 changes: 9 additions & 0 deletions vendor/middleman/source/includes/_google_analytics.html.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{site_ga}}', 'auto');
ga('send', 'pageview');
</script>
Loading

0 comments on commit 9380d23

Please sign in to comment.