From 8d21b802c35d5b1f8e6e868aaa20c1c0066275c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Tue, 2 Mar 2021 00:41:56 +0100 Subject: Add new interfaces tree, remake database code as 'ruby' interface This follows the directory structure outlined in my previous commit message. --- interfaces/http/http.rb | 10 ++++++++++ interfaces/http/web/views/index.erb | 19 +++++++++++++++++++ interfaces/http/web/web.rb | 6 ++++++ 3 files changed, 35 insertions(+) create mode 100644 interfaces/http/http.rb create mode 100644 interfaces/http/web/views/index.erb create mode 100644 interfaces/http/web/web.rb (limited to 'interfaces/http') diff --git a/interfaces/http/http.rb b/interfaces/http/http.rb new file mode 100644 index 0000000..0a8457c --- /dev/null +++ b/interfaces/http/http.rb @@ -0,0 +1,10 @@ +require 'sinatra/base' +require_relative '../ruby/ruby' +require_relative 'web/web' + +$config = Config.first + +class HTTPInterface < Sinatra::Base + use WebInterface + run! if app_file == $0 +end diff --git a/interfaces/http/web/views/index.erb b/interfaces/http/web/views/index.erb new file mode 100644 index 0000000..80e64a5 --- /dev/null +++ b/interfaces/http/web/views/index.erb @@ -0,0 +1,19 @@ + + + + + <%= $config.title %> + + +

<%= $config.title %>

+ <% for post in @posts %> +

<%= post.title %>

+
+

<%= post.created_at %>

+
+
+ <%= post.body %> +
+ <% end %> + + diff --git a/interfaces/http/web/web.rb b/interfaces/http/web/web.rb new file mode 100644 index 0000000..8ae8afd --- /dev/null +++ b/interfaces/http/web/web.rb @@ -0,0 +1,6 @@ +class WebInterface < Sinatra::Base + get '/' do + @posts = Post.all + erb :index + end +end \ No newline at end of file -- cgit v1.2.3