diff --git a/public/assets/fonts/merriweather-sans-v13-latin-italic.eot b/public/assets/fonts/merriweather-sans-v13-latin-italic.eot new file mode 100755 index 0000000..c6d5de9 Binary files /dev/null and b/public/assets/fonts/merriweather-sans-v13-latin-italic.eot differ diff --git a/public/assets/fonts/merriweather-sans-v13-latin-italic.svg b/public/assets/fonts/merriweather-sans-v13-latin-italic.svg new file mode 100755 index 0000000..5d9276c --- /dev/null +++ b/public/assets/fonts/merriweather-sans-v13-latin-italic.svg @@ -0,0 +1,373 @@ + + + diff --git a/public/assets/fonts/merriweather-sans-v13-latin-italic.ttf b/public/assets/fonts/merriweather-sans-v13-latin-italic.ttf new file mode 100755 index 0000000..434322b Binary files /dev/null and b/public/assets/fonts/merriweather-sans-v13-latin-italic.ttf differ diff --git a/public/assets/fonts/merriweather-sans-v13-latin-italic.woff b/public/assets/fonts/merriweather-sans-v13-latin-italic.woff new file mode 100755 index 0000000..a125347 Binary files /dev/null and b/public/assets/fonts/merriweather-sans-v13-latin-italic.woff differ diff --git a/public/assets/fonts/merriweather-sans-v13-latin-italic.woff2 b/public/assets/fonts/merriweather-sans-v13-latin-italic.woff2 new file mode 100755 index 0000000..53c512a Binary files /dev/null and b/public/assets/fonts/merriweather-sans-v13-latin-italic.woff2 differ diff --git a/public/assets/fonts/merriweather-sans-v13-latin-regular.eot b/public/assets/fonts/merriweather-sans-v13-latin-regular.eot new file mode 100755 index 0000000..4757299 Binary files /dev/null and b/public/assets/fonts/merriweather-sans-v13-latin-regular.eot differ diff --git a/public/assets/fonts/merriweather-sans-v13-latin-regular.svg b/public/assets/fonts/merriweather-sans-v13-latin-regular.svg new file mode 100755 index 0000000..b94fce4 --- /dev/null +++ b/public/assets/fonts/merriweather-sans-v13-latin-regular.svg @@ -0,0 +1,376 @@ + + + diff --git a/public/assets/fonts/merriweather-sans-v13-latin-regular.ttf b/public/assets/fonts/merriweather-sans-v13-latin-regular.ttf new file mode 100755 index 0000000..6036a59 Binary files /dev/null and b/public/assets/fonts/merriweather-sans-v13-latin-regular.ttf differ diff --git a/public/assets/fonts/merriweather-sans-v13-latin-regular.woff b/public/assets/fonts/merriweather-sans-v13-latin-regular.woff new file mode 100755 index 0000000..e41a2b7 Binary files /dev/null and b/public/assets/fonts/merriweather-sans-v13-latin-regular.woff differ diff --git a/public/assets/fonts/merriweather-sans-v13-latin-regular.woff2 b/public/assets/fonts/merriweather-sans-v13-latin-regular.woff2 new file mode 100755 index 0000000..c53b99f Binary files /dev/null and b/public/assets/fonts/merriweather-sans-v13-latin-regular.woff2 differ diff --git a/public/assets/fonts/merriweather-v21-latin-italic.eot b/public/assets/fonts/merriweather-v21-latin-italic.eot new file mode 100755 index 0000000..833d75d Binary files /dev/null and b/public/assets/fonts/merriweather-v21-latin-italic.eot differ diff --git a/public/assets/fonts/merriweather-v21-latin-italic.svg b/public/assets/fonts/merriweather-v21-latin-italic.svg new file mode 100755 index 0000000..dfb5af8 --- /dev/null +++ b/public/assets/fonts/merriweather-v21-latin-italic.svg @@ -0,0 +1,390 @@ + + + diff --git a/public/assets/fonts/merriweather-v21-latin-italic.ttf b/public/assets/fonts/merriweather-v21-latin-italic.ttf new file mode 100755 index 0000000..c809b10 Binary files /dev/null and b/public/assets/fonts/merriweather-v21-latin-italic.ttf differ diff --git a/public/assets/fonts/merriweather-v21-latin-italic.woff b/public/assets/fonts/merriweather-v21-latin-italic.woff new file mode 100755 index 0000000..fe2e3dc Binary files /dev/null and b/public/assets/fonts/merriweather-v21-latin-italic.woff differ diff --git a/public/assets/fonts/merriweather-v21-latin-italic.woff2 b/public/assets/fonts/merriweather-v21-latin-italic.woff2 new file mode 100755 index 0000000..3c26191 Binary files /dev/null and b/public/assets/fonts/merriweather-v21-latin-italic.woff2 differ diff --git a/public/assets/fonts/merriweather-v21-latin-regular.eot b/public/assets/fonts/merriweather-v21-latin-regular.eot new file mode 100755 index 0000000..7f65333 Binary files /dev/null and b/public/assets/fonts/merriweather-v21-latin-regular.eot differ diff --git a/public/assets/fonts/merriweather-v21-latin-regular.svg b/public/assets/fonts/merriweather-v21-latin-regular.svg new file mode 100755 index 0000000..555dea6 --- /dev/null +++ b/public/assets/fonts/merriweather-v21-latin-regular.svg @@ -0,0 +1,374 @@ + + + diff --git a/public/assets/fonts/merriweather-v21-latin-regular.ttf b/public/assets/fonts/merriweather-v21-latin-regular.ttf new file mode 100755 index 0000000..4e8f415 Binary files /dev/null and b/public/assets/fonts/merriweather-v21-latin-regular.ttf differ diff --git a/public/assets/fonts/merriweather-v21-latin-regular.woff b/public/assets/fonts/merriweather-v21-latin-regular.woff new file mode 100755 index 0000000..2f2ab42 Binary files /dev/null and b/public/assets/fonts/merriweather-v21-latin-regular.woff differ diff --git a/public/assets/fonts/merriweather-v21-latin-regular.woff2 b/public/assets/fonts/merriweather-v21-latin-regular.woff2 new file mode 100755 index 0000000..0998409 Binary files /dev/null and b/public/assets/fonts/merriweather-v21-latin-regular.woff2 differ diff --git a/server.rb b/server.rb index 0a515ed..62cda88 100644 --- a/server.rb +++ b/server.rb @@ -1,29 +1,51 @@ require 'json' require 'faraday' require 'sinatra' +require 'sinatra/namespace' require_relative 'get_images_by_category.rb' require_relative 'get_random_image.rb' +set :environment, :production +set :server, %w[thin mongrel webrick] + categories = File.readlines("categories.txt") +# Index get '/' do image = get_random_image(get_images_by_category(categories)) erb :index, locals: { image: image } end +# About page get '/about' do erb :about end -get '/api/random' do - content_type :json - image = get_random_image(get_images_by_category(categories)) - image.to_json +get '/about-api' do + erb :api end -get '/api/categories' do - content_type :json - categories.to_json -end \ No newline at end of file +# API +namespace "/api" do + before do + content_type 'application/json' + end + + get '/random' do + image = get_random_image(get_images_by_category(categories)) + image.to_json + end + + get '/categories' do + content_type :json + categories_trimmed = [] + + categories.each do |category| + categories_trimmed << category.delete("\n") + end + + categories_trimmed.to_json + end +end diff --git a/views/api.erb b/views/api.erb new file mode 100644 index 0000000..4ed26c2 --- /dev/null +++ b/views/api.erb @@ -0,0 +1,12 @@ +
There is, at the moment, a very rudimentary API available.
+Description: <%= image[:desc] %>
Photo by: <%= image[:user_url] %>
Licensed under: <%= image[:license] %>
-URL: <%= image[:url] %>
\ No newline at end of file +URL:
\ No newline at end of file diff --git a/views/layout.erb b/views/layout.erb index 9d6ed4f..c72cfa2 100644 --- a/views/layout.erb +++ b/views/layout.erb @@ -13,6 +13,7 @@