diff --git a/.gitignore b/.gitignore
index 9fcfc5cca..ac2cc5770 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,8 +35,8 @@ capybara-*.html
/tmp/*
/data/*
/db/*.sqlite3
-/public/system/*
-public/assets
+/public/*
+!/public/.keep
/coverage/
/spec/tmp/
/config/data_bags/*
diff --git a/Dockerfile b/Dockerfile
index 698ce7ac8..dc48bb109 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -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
@@ -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
diff --git a/Gemfile b/Gemfile
index 47c2cd56a..43b13cef7 100644
--- a/Gemfile
+++ b/Gemfile
@@ -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'
diff --git a/Gemfile.lock b/Gemfile.lock
index 1273d6601..994781cf0 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -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)
diff --git a/app/controllers/index_controller.rb b/app/controllers/index_controller.rb
index d22a535fa..1417139d6 100644
--- a/app/controllers/index_controller.rb
+++ b/app/controllers/index_controller.rb
@@ -5,7 +5,6 @@ class IndexController < ApplicationController
before_action :set_doi, only: [:show]
def index
- authorize! :index, :Index
render plain: ENV['SITE_TITLE']
end
diff --git a/config/application.rb b/config/application.rb
index ac49256a4..7e7eb0102 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -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"
diff --git a/config/routes.rb b/config/routes.rb
index 9646beaa7..0c3a6251a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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 => /.+/ }
@@ -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
diff --git a/public/.keep b/public/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/public/robots.txt b/public/robots.txt
deleted file mode 100644
index 37b576a4a..000000000
--- a/public/robots.txt
+++ /dev/null
@@ -1 +0,0 @@
-# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
diff --git a/vendor/docker/70_index_page.sh b/vendor/docker/70_index_page.sh
new file mode 100755
index 000000000..fad7b5b99
--- /dev/null
+++ b/vendor/docker/70_index_page.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+cd vendor/middleman
+/sbin/setuser app bundle exec middleman build -e ${RAILS_ENV}
diff --git a/vendor/middleman/Gemfile b/vendor/middleman/Gemfile
new file mode 100644
index 000000000..3410f7d6b
--- /dev/null
+++ b/vendor/middleman/Gemfile
@@ -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'
diff --git a/vendor/middleman/Gemfile.lock b/vendor/middleman/Gemfile.lock
new file mode 100644
index 000000000..fd3ba85c7
--- /dev/null
+++ b/vendor/middleman/Gemfile.lock
@@ -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
diff --git a/vendor/middleman/config.rb b/vendor/middleman/config.rb
new file mode 100644
index 000000000..b03ba4ad8
--- /dev/null
+++ b/vendor/middleman/config.rb
@@ -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
diff --git a/vendor/middleman/config.ru b/vendor/middleman/config.ru
new file mode 100644
index 000000000..ece6fda7e
--- /dev/null
+++ b/vendor/middleman/config.ru
@@ -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
diff --git a/public/favicon.ico b/vendor/middleman/source/favicon.ico
old mode 100644
new mode 100755
similarity index 100%
rename from public/favicon.ico
rename to vendor/middleman/source/favicon.ico
diff --git a/vendor/middleman/source/includes/_footer.html.hbs b/vendor/middleman/source/includes/_footer.html.hbs
new file mode 100644
index 000000000..a10f67d10
--- /dev/null
+++ b/vendor/middleman/source/includes/_footer.html.hbs
@@ -0,0 +1,61 @@
+
diff --git a/vendor/middleman/source/includes/_google_analytics.html.hbs b/vendor/middleman/source/includes/_google_analytics.html.hbs
new file mode 100644
index 000000000..8b18f56af
--- /dev/null
+++ b/vendor/middleman/source/includes/_google_analytics.html.hbs
@@ -0,0 +1,9 @@
+
diff --git a/vendor/middleman/source/includes/_header.html.hbs b/vendor/middleman/source/includes/_header.html.hbs
new file mode 100644
index 000000000..797adbfda
--- /dev/null
+++ b/vendor/middleman/source/includes/_header.html.hbs
@@ -0,0 +1,20 @@
+
<%= current_page.data.description %>
+