Permalink
Browse files

Add syndicate form, re-organize adam section

  • Loading branch information...
adamdawkins committed Jan 22, 2019
1 parent 1aab696 commit c8fb81c838be2985e186bb54e2262d6a7c29a074
@@ -37,6 +37,13 @@ $article_color: #E96856;
&--note {
border-top: 1px solid $note_color;
}

&.is-draft {
background: #eee;
opacity: .8;
border: 1px dashed #ccc;
box-shadow: none;
}
}

@media screen and (min-width: 480px) {
@@ -68,6 +75,14 @@ $article_color: #E96856;
content: "📔";
box-shadow: 1px 1px 2px $note_color;
}

&.is-draft {
&::before {
background: #eee;
box-shadow: none;
border: 1px dashed #ccc;
}
}
}
}

@@ -0,0 +1,10 @@
class Adam::PostsController < AdamController
def index
@posts = Post.all.order(updated_at: :desc)
end

def show
@post = Post.find(params[:id])
redirect_to "/adam/#{@post.type.downcase.pluralize}/#{@post.id}"
end
end
@@ -0,0 +1,23 @@
class Adam::SyndicatesController < AdamController
def create
@post = Post.find(params[:post_id])
@post.syndicates.create(syndicate_params)
redirect_to_post
end

def destroy
@syndicate = Syndicate.find(params[:id])
@post = @syndicate.post
@syndicate.destroy
redirect_to_post
end

private
def syndicate_params
params.require(:syndicate).permit(:silo_id, :url)
end

def redirect_to_post
redirect_to(adam_post_path @post) and return
end
end
@@ -1,10 +1,13 @@
<article class="article">
<article class="post post--article <%= !article.published? ? 'is-draft' : '' %>">
<%= link_to article.title, adam_article_path(article) %>
(
<% if article.published? %>
<%= link_to "published", long_post_path(article.params) %>
<% else %>
Draft
<% end %>
)
<span>(
<% if article.published? %>
<%= link_to "published", long_post_path(article.params) %>
<% else %>
Draft
<% end %>
)
</span>
<%= blurb(article) %>

</article>
@@ -9,12 +9,6 @@
<% end %>
</div>

<div>
<%= label_tag :send_to_twitter do %>
<%= check_box_tag :send_to_twitter %>
Send to Twitter?
<% end %>
</div>
<div style="margin-top: 1em">
<%= f.submit %>
</div>
@@ -6,5 +6,22 @@
<% end %>
<% end %>
</div>
<div>
<h3>Syndicates</h3>
<ul>
<% @article.syndicates.each do |syn| %>
<li>
<%= link_to syn.silo.name, syn.url %>
<%= simple_form_for(syn, url: adam_syndicate_path(syn), method: :delete) do |f|%>
<%= f.submit "Delete" %>
<% end %>
</li>
<% end %>
</ul>
<%= simple_form_for(@article.syndicates.build, url: adam_post_syndicates_path(@article)) do |f| %>
<%= f.association :silo %>
<%= f.input :url %>
<% end %>
</div>
<h1 class="title"><%= @article.title %></h1>
<%= Kramdown::Document.new(@article.content).to_html.html_safe %>
@@ -1,4 +1,4 @@
<article class="note">
<article class="post post--note <%= !note.published? ? 'is-draft' : '' %>">
<div class=""><%= note.content %></div>
<%= link_to "preview", adam_note_path(note), class: "u-url" %>
</article>
@@ -0,0 +1,7 @@
<h2>Actions</h2>
<ul>
<li><%= link_to "New note", new_adam_note_path %></li>
<li><%= link_to "New article", new_adam_article_path %></li>
</ul>
<h1>Posts</h1>
<%= render @posts %>
@@ -8,9 +8,13 @@
root to: 'posts#index'

get 'login', to: 'sessions#new'
get 'adam', to: 'adam/notes#new'
get 'adam', to: 'adam/posts#index'

namespace :adam do
resources :syndicates, only: :destroy
resources :posts do
resources :syndicates, only: :create
end
resources :notes
resources :articles
put "notes/:id/publish", to: "notes#publish", as: "publish_note"

0 comments on commit c8fb81c

Please sign in to comment.