Permalink
Browse files

Create a shared Posts homepage for notes and articles

  • Loading branch information...
adamdawkins committed Jan 21, 2019
1 parent 8713479 commit a3bf9d27f6fb31cfc547f27f60d56fd80feb0642
@@ -1,10 +1,14 @@
.note {
$note_color: #65A2A8;
$article_color: #E96856;

.post {
display: flex;
flex-direction: column;
background: white;
position:relative;
padding: 0 1rem;
margin-bottom: 1.5rem;
box-shadow: 1px 1px 2px rgba(0,0,0, .1);
border-top: 1px solid #65A2A8;
border-radius: .1em;

footer {
@@ -15,14 +19,31 @@
p {
line-height: 2rem;
}

&__cta {
float: right;
margin-bottom: 1.5rem;
}

&__title {
color: black;
}

&--article {
border-top: 1px solid $article_color;

}

&--note {
border-top: 1px solid $note_color;
}
}

@media screen and (min-width: 480px) {
.note {
.post {
margin-left: 5rem;

&::before {
content: "📔";
position: absolute;
left: -5rem;
border-radius: 50%;
@@ -31,13 +52,22 @@
font-size: 2rem;
padding: 1rem;
top: 0;
box-shadow: 1px 1px 2px #65A2A8;
display: flex;
justify-content: center;
align-items: center;
height: 2rem;
width: 2rem;
}

&--article::before {
content: "📄";
box-shadow: 1px 1px 2px $article_color;
}

&--note::before {
content: "📔";
box-shadow: 1px 1px 2px $note_color;
}
}
}

@@ -77,6 +77,7 @@ section {

a {
color: #E96856;
text-decoration-color: #E96856;

&.silent {
color: inherit;
@@ -93,6 +94,13 @@ a {
}
}

&.underline {
color: inherit;
&:hover {
color: #E96856;
}
}

}

a[href^="http"] {
@@ -103,5 +111,5 @@ blockquote p {
font-style: italic;
}

@import "notes";
@import "posts";
@import "indiemark";
@@ -1,8 +1,4 @@
class Adam::NotesController < AdamController
def index
@notes = Note.all
end

def new
@note = Note.new
end
@@ -1,4 +1,5 @@
class ArticlesController < ApplicationController
def index
@articles = Article.all.published
end
end
@@ -1,19 +1,5 @@
class NotesController < ApplicationController
before_action :set_published_date, only: :show
def index
@notes = Note.published
end

def show
@note = Note.where(published_at: @published_date.all_day, slug: params[:slug])
end

private

def set_published_date
@published_date = Date.new(params[:year].to_i,
params[:month].to_i,
params[:day].to_i
)
end
end
@@ -6,6 +6,10 @@ def show
render "#{@post.type.downcase.pluralize}/show"
end

def index
@posts = Post.published
end

private

def set_published_date
@@ -1,2 +1,7 @@
module ArticlesHelper
def blurb(article, length: 280)
html = Kramdown::Document.new(article.content).to_html.html_safe
first_paragraph = Nokogiri::HTML(html).css('p').first.text()
simple_format first_paragraph
end
end
@@ -0,0 +1,27 @@
<article class="h-entry post post--article">
<%= link_to long_post_path(article.params), class: "u-url quiet" do %>
<time class="block-time dt-published" datetime="<%= article.published_at.strftime('%Y-%m-%dT%H:%M:%S.%L%z') %>">
<% if article.published_at.today? %>
<%= time_ago_in_words(article.published_at) %> ago
<span style="font-weight: normal; margin-left: 1em;"><%= article.published_at.strftime("%R") %></span>
<% else %>
<%= article.published_at.strftime("%a %-d %b %Y %R %Z") %>
<% end %>
</time>
<% end %>
<div class="p-name e-content">
<h3 class="post__title"><%= link_to article.title, long_post_path(article.params), class: "underline" %></h3>
<%= blurb(article) %>
<%= link_to "Read on", long_post_path(article.params), class: 'post__cta' %>
</div>
<% if article.syndicates.any? %>
<footer>
<div class="syndication">
<% article.syndicates.each do |syndicate| %>
<p>Also articleed to <%= link_to syndicate.silo.name, syndicate.url, rel: "external syndication", class: "u-syndication" %>
<% end %>
</div>
</footer>
<% end %>
<a class="u-author" href="/"></a>
</article>
@@ -1 +1,2 @@
<h1>Articles</h1>
<%= render @articles %>
@@ -14,7 +14,7 @@

<body>
<header>
<h1>Adam Dawkins</h1>
<h1><%= link_to "Adam Dawkins", root_path, class: "quiet" %></h1>
</header>
<main>
<%= yield %>
@@ -1,4 +1,4 @@
<article class="h-entry note">
<article class="h-entry post post--note">
<% if note.published? %>
<%= link_to long_post_path(note.params), class: "u-url quiet" do %>
<time class="block-time dt-published" datetime="<%= note.published_at.strftime('%Y-%m-%dT%H:%M:%S.%L%z') %>">
@@ -12,14 +12,14 @@
<% end %>
<% end %>
<p class="p-name e-content"><%= note.content %></p>
<% if note.syndicates.any? %>
<footer>
<div class="syndication">
<% note.syndicates.each do |syndicate| %>
<p>Also posted to <%= link_to syndicate.silo.name, syndicate.url, rel: "external syndication", class: "u-syndication" %>
<% end %>
</div>
</footer>
<% end %>
<a class="u-author" href="/"></a>
<% if note.syndicates.any? %>
<footer>
<div class="syndication">
<% note.syndicates.each do |syndicate| %>
<p>Also posted to <%= link_to syndicate.silo.name, syndicate.url, rel: "external syndication", class: "u-syndication" %>
<% end %>
</div>
</footer>
<% end %>
<a class="u-author" href="/"></a>
</article>
@@ -1,5 +1,2 @@
<div class="h-feed">
<%= render "shared/text_bio" %>
<h1>Latest</h1>
<%= render @notes %>
</div>
<h1>Notes</h1>
<%= render @notes %>
@@ -0,0 +1,6 @@
<div class="h-feed">
<%= render "shared/text_bio" %>
<h1>Latest</h1>
<p>You're seeing everything. You can view just my <%= link_to "articles", articles_path %> or <%= link_to "notes", notes_path %>.</p>
<%= render @posts %>
</div>
@@ -5,7 +5,7 @@
end

constraints host: ENV['FULL_URL'] do
root to: 'notes#index'
root to: 'posts#index'

get 'login', to: 'sessions#new'
get 'adam', to: 'adam/notes#new'
@@ -23,7 +23,7 @@
get 'indiemark', to: 'indiemarks#index'

resources :articles, only: :index
resources :notes
resources :notes, only: :index

get '*page', to: 'pages#show'
end

0 comments on commit a3bf9d2

Please sign in to comment.