Skip to content

Commit

Permalink
Add actual article to detail view
Browse files Browse the repository at this point in the history
Using the `article_json` gem, add the parsed Google Doc article as HTML
to the detail page.
  • Loading branch information
nicolas-fricke committed Nov 24, 2017
1 parent 7d038a9 commit 2cbc315
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source 'https://rubygems.org'

gem 'article_json'
gem 'google_drive'
gem 'sinatra'

Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ GEM
specs:
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
article_json (0.3.0)
css_parser (~> 1.5)
nokogiri (~> 1.8)
css_parser (1.6.0)
addressable
declarative (0.0.10)
declarative-option (0.1.0)
diff-lcs (1.3)
Expand Down Expand Up @@ -85,6 +90,7 @@ PLATFORMS
ruby

DEPENDENCIES
article_json
google_drive
rack-test
rspec
Expand Down
1 change: 1 addition & 0 deletions app/server.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'sinatra'
require 'yaml'
require 'article_json'
require_relative 'config'
require_relative 'google_drive_connector'

Expand Down
2 changes: 1 addition & 1 deletion app/views/show.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<time><%= doc.modified_time.strftime('%d %b %Y') %></time>
</div>
<article>
Lorem ipsum, sit dolor amet.
<%= ArticleJSON::Article.from_google_doc_html(doc.export_as_string('html')).to_html %>
</article>
30 changes: 30 additions & 0 deletions spec/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,41 @@ def app
title: 'My first document',
last_modifying_user: user_double
end
let(:html) do
<<~HTML
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<style type="text/css"></style>
</head>
<body style="background-color:#ffffff;padding:72pt 72pt 72pt 72pt;max-width:468pt">
<h1 id="h.rdp4m3ei7nk6" style="padding-top:20pt;margin:0;color:#000000;padding-left:0;font-size:20pt;padding-bottom:6pt;line-height:1.15;page-break-after:avoid;font-family:&quot;Arial&quot;;orphans:2;widows:2;text-align:left;padding-right:0">
<span style="color:#000000;font-weight:400;text-decoration:none;vertical-align:baseline;font-size:20pt;font-family:&quot;Arial&quot;;font-style:normal">Simple article</span>
</h1>
<p style="padding:0;margin:0;color:#000000;font-size:11pt;font-family:&quot;Arial&quot;;line-height:1.15;orphans:2;widows:2;height:11pt;text-align:left">
<span style="color:#000000;font-weight:400;text-decoration:none;vertical-align:baseline;font-size:11pt;font-family:&quot;Arial&quot;;font-style:normal"></span>
</p>
<p style="padding:0;margin:0;color:#000000;font-size:11pt;font-family:&quot;Arial&quot;;line-height:1.15;orphans:2;widows:2;text-align:left">
<span style="color:#000000;font-weight:400;text-decoration:none;vertical-align:baseline;font-size:11pt;font-family:&quot;Arial&quot;;font-style:normal">It's nice when it works!</span>
</p>
<p style="padding:0;margin:0;color:#000000;font-size:11pt;font-family:&quot;Arial&quot;;line-height:1.15;orphans:2;widows:2;height:11pt;text-align:left">
<span style="color:#000000;font-weight:400;text-decoration:none;vertical-align:baseline;font-size:11pt;font-family:&quot;Arial&quot;;font-style:normal"></span>
</p>
</body>
</html>
HTML
end

before do
allow(document_double)
.to receive(:export_as_string).with('html').and_return(html)
end

it 'should return the article page for the given document' do
get "/#{doc_id}"
expect(last_response).to be_successful
expect(last_response.body).to include document_double.title
expect(last_response.body).to include "It's nice when it works!"
end
end

Expand Down

0 comments on commit 2cbc315

Please sign in to comment.