features, bug fixes
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -12,6 +12,7 @@ gem 'github-markdown'
|
||||
gem 'hirb' #pretty console output
|
||||
gem 'rb-readline', '~> 0.4.2'
|
||||
gem 'rest-client'
|
||||
gem 'epic-editor-rails'
|
||||
|
||||
# Gems used only for assets and not required
|
||||
# in production environments by default.
|
||||
|
||||
@@ -46,6 +46,8 @@ GEM
|
||||
execjs
|
||||
coffee-script-source (1.6.2)
|
||||
debug_inspector (0.0.2)
|
||||
epic-editor-rails (0.2.3)
|
||||
railties (>= 3.2, < 5.0)
|
||||
erubis (2.7.0)
|
||||
execjs (1.4.0)
|
||||
multi_json (~> 1.0)
|
||||
@@ -140,6 +142,7 @@ DEPENDENCIES
|
||||
better_errors
|
||||
binding_of_caller
|
||||
coffee-rails (~> 3.2.1)
|
||||
epic-editor-rails
|
||||
github-markdown
|
||||
hirb
|
||||
jquery-rails
|
||||
|
||||
@@ -1,24 +1,45 @@
|
||||
$(function(){
|
||||
$('.flash').click(function(){
|
||||
$('.flash').animate({
|
||||
opacity: 0
|
||||
}, 'fast', function(){
|
||||
$(this).animate({
|
||||
height: 0
|
||||
}, 'slow', function(){
|
||||
$(this).hide();
|
||||
})
|
||||
});
|
||||
$('.flash').click(function(){
|
||||
$('.flash').animate({
|
||||
opacity: 0
|
||||
}, 'fast', function(){
|
||||
$(this).animate({
|
||||
height: 0
|
||||
}, 'slow', function(){
|
||||
$(this).hide();
|
||||
})
|
||||
});
|
||||
setTimeout(function(){
|
||||
$('.flash').animate({
|
||||
opacity: 0
|
||||
}, 3000, function(){
|
||||
$(this).animate({
|
||||
height: 0
|
||||
}, 'slow', function(){
|
||||
$(this).hide();
|
||||
})
|
||||
});
|
||||
}, 4000);
|
||||
})
|
||||
});
|
||||
setTimeout(function(){
|
||||
$('.flash').animate({
|
||||
opacity: 0
|
||||
}, 3000, function(){
|
||||
$(this).animate({
|
||||
height: 0
|
||||
}, 'slow', function(){
|
||||
$(this).hide();
|
||||
})
|
||||
});
|
||||
}, 4000);
|
||||
|
||||
|
||||
var editor = new EpicEditor({
|
||||
container: 'epic',
|
||||
textarea: 'epic-textarea',
|
||||
basePath: '/assets',
|
||||
theme: {
|
||||
base: '/base/epiceditor.css',
|
||||
preview: '/preview/github.css',
|
||||
editor: '/editor/epic-light.css'
|
||||
},
|
||||
button: {
|
||||
bar: true
|
||||
},
|
||||
autogrow: {
|
||||
minHeight: 500
|
||||
}
|
||||
});
|
||||
try {
|
||||
editor.load();
|
||||
} catch (e) {}
|
||||
});
|
||||
@@ -11,4 +11,5 @@
|
||||
// GO AFTER THE REQUIRES BELOW.
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require epiceditor
|
||||
//= require app
|
||||
|
||||
@@ -3,4 +3,7 @@
|
||||
*= require style.css
|
||||
*= require screen.css
|
||||
*= require mobi.css
|
||||
*/
|
||||
*/
|
||||
@import 'base/epiceditor';
|
||||
@import 'preview/github';
|
||||
@import 'editor/epic-light';
|
||||
@@ -145,9 +145,9 @@ and (min-width: 0px) //TODO
|
||||
display: block;
|
||||
}
|
||||
|
||||
.post {
|
||||
.post, .thread {
|
||||
margin-bottom: 50px;
|
||||
.post-title {
|
||||
.post-title, .thread-title {
|
||||
margin-bottom: 10px;
|
||||
word-wrap: break-word;
|
||||
h1 {
|
||||
@@ -169,7 +169,7 @@ and (min-width: 0px) //TODO
|
||||
font-weight: bold !important;
|
||||
text-shadow: none !important;
|
||||
}
|
||||
.post-info {
|
||||
.post-info, .thread-info {
|
||||
border-bottom: 2px dashed #999;
|
||||
color: #888;
|
||||
width: 100%;
|
||||
@@ -179,11 +179,11 @@ and (min-width: 0px) //TODO
|
||||
color: #d55;
|
||||
}
|
||||
}
|
||||
.post-edit {
|
||||
.post-edit, .thread-edit {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
.post-content {
|
||||
.post-content, .thread-content {
|
||||
margin-top: 10px;
|
||||
clear: both;
|
||||
word-wrap: break-word;
|
||||
@@ -445,6 +445,9 @@ and (min-width: 0px) //TODO
|
||||
background: #EE8383;
|
||||
}
|
||||
}
|
||||
&.left {
|
||||
float: left;
|
||||
}
|
||||
&.right {
|
||||
float: right;
|
||||
}
|
||||
@@ -495,14 +498,6 @@ and (min-width: 0px) //TODO
|
||||
transition: opacity 0.3s, margin 0.3s;
|
||||
}
|
||||
|
||||
#edit_create_post, #edit_create_comment {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#delete_post, #delete_comment {
|
||||
float: right;
|
||||
}
|
||||
|
||||
#blogpost_text {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -514,7 +509,7 @@ and (min-width: 0px) //TODO
|
||||
}
|
||||
|
||||
#forum_groups {
|
||||
.group {
|
||||
.item_group {
|
||||
margin: 10px 0;
|
||||
&:hover .editlink {
|
||||
opacity: 1;
|
||||
@@ -526,15 +521,25 @@ and (min-width: 0px) //TODO
|
||||
padding: 0.5em;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
.forums {
|
||||
.items {
|
||||
border: 1px solid #ddd;
|
||||
border-top: none;
|
||||
border-bottom: none;
|
||||
.forum {
|
||||
.item {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
padding: 0.5em;
|
||||
border-bottom: 1px solid #ddd;
|
||||
&.locked:after {
|
||||
color: #000;
|
||||
font-weight: normal;
|
||||
content: " (L)";
|
||||
}
|
||||
&.sticky:before {
|
||||
color: #000;
|
||||
font-weight: normal;
|
||||
content: "(S) ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class BlogpostsController < ApplicationController
|
||||
|
||||
def update
|
||||
@post = Blogpost.find(params[:id])
|
||||
if mod?
|
||||
if mod? || @comment.author.is?(current_user)
|
||||
@post.user_editor = current_user
|
||||
if @post.update_attributes(params[:blogpost] ? params[:blogpost].slice(:title, :content, :user_editor) : {})
|
||||
redirect_to @post, notice: 'Post has been updated.'
|
||||
|
||||
@@ -14,7 +14,7 @@ class ForumsController < ApplicationController
|
||||
def show
|
||||
@forum = Forum.find(params[:id])
|
||||
if @forum.role_read.nil? || current_user && @forum.role_read <= current_user.role
|
||||
@threads = @forum.forumthreads.reverse
|
||||
@threads = @forum.forumthreads.order("sticky desc, updated_at desc")
|
||||
else
|
||||
redirect_to forums_path
|
||||
end
|
||||
|
||||
@@ -6,7 +6,26 @@ class ForumthreadsController < ApplicationController
|
||||
|
||||
def show
|
||||
@thread = Forumthread.find(params[:id])
|
||||
render text: @thread.content
|
||||
end
|
||||
|
||||
def update
|
||||
@thread = Forumthread.find(params[:id])
|
||||
if mod? || @thread.author.is?(current_user)
|
||||
@thread.user_editor = current_user
|
||||
if @thread.update_attributes(params[:forumthread] ? params[:forumthread].slice(:title, :content, :user_editor) : {})
|
||||
redirect_to [@thread.forum, @thread], notice: 'Post has been updated.'
|
||||
else
|
||||
flash[:alert] = "There was a problem while updating the post"
|
||||
render action: "edit"
|
||||
end
|
||||
else
|
||||
flash[:alert] = "You are not allowed to edit this thread!"
|
||||
redirect_to [@thread.forum, @thread]
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@thread = Forumthread.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
@@ -11,4 +11,16 @@ class Forumthread < ActiveRecord::Base
|
||||
def to_s
|
||||
title
|
||||
end
|
||||
|
||||
def author
|
||||
@author ||= if self.user_author.present?
|
||||
user_author
|
||||
else
|
||||
User.first
|
||||
end
|
||||
end
|
||||
|
||||
def editor
|
||||
@editor ||= user_editor
|
||||
end
|
||||
end
|
||||
@@ -2,9 +2,8 @@
|
||||
<p id="markdown-note">Note: You can use <%= link_to "Markdown", "https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet", target: "_blank" %>!</p>
|
||||
<%= simple_form_for @post do |f|%>
|
||||
<%= f.input :title, :label => false %>
|
||||
<%= f.input :content, :label => false, input_html: {class: "full-width vertical"} %>
|
||||
<%= f.submit "Update Post", :id => "edit_create_post", class: "btn blue" %>
|
||||
<%= f.hidden_field :content, id: "epic-textarea", :label => false, input_html: {class: "full-width vertical"} %>
|
||||
<div id="epic"></div>
|
||||
<%= f.submit "Update Post", class: "btn blue left" %>
|
||||
<% end %>
|
||||
<div id="delete_post">
|
||||
<%= button_to "Delete post", @post, :method => "delete", :confirm => "Delete post & comments forever?", class: "btn red right" %>
|
||||
</div>
|
||||
<%= button_to "Delete post", @post, :method => "delete", :confirm => "Delete post & comments forever?", class: "btn red right" %>
|
||||
@@ -2,6 +2,7 @@
|
||||
<p id="markdown-note">Note: You can use <%= link_to "Markdown", "https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet", target: "_blank" %>!</p>
|
||||
<%= simple_form_for @post do |f|%>
|
||||
<%= f.input :title, placeholder: "Title" %>
|
||||
<%= f.input :content, placeholder: "Text", input_html: {class: "full-width vertical"} %>
|
||||
<%= f.submit "Create Post", id: "edit_create_post", class: "btn blue" %>
|
||||
<%= f.hidden_field :content, id: "epic-textarea", placeholder: "Text", input_html: {class: "full-width vertical"} %>
|
||||
<div id="epic"></div>
|
||||
<%= f.submit "Create Post", class: "btn blue left" %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<h1>Edit comment</h1>
|
||||
|
||||
<%= simple_form_for [@comment.blogpost, @comment] do |f| %>
|
||||
<%= f.input :content, :label => false, :as => "text", :placeholder => "Comment" %>
|
||||
<%= f.submit "Update Comment", :id => "edit_create_comment", class: "btn blue" %>
|
||||
<%= f.input :content, label: false, as: "text", placeholder: "Comment" %>
|
||||
<%= f.submit "Update Comment", class: "btn blue left" %>
|
||||
<% end %>
|
||||
<div id="delete_comment">
|
||||
<%= button_to "Delete comment", [@comment.blogpost, @comment] , :method => "delete", :confirm => "Delete comment forever?", class: "btn red right" %>
|
||||
</div>
|
||||
<%= button_to "Delete comment", [@comment.blogpost, @comment] , method: "delete", confirm: "Delete comment forever?", class: "btn red right" %>
|
||||
@@ -1,14 +1,14 @@
|
||||
<div id="forum_groups">
|
||||
<% @groups.each do |group| %>
|
||||
<div class="group" id="forums-<%= group.id %>">
|
||||
<div class="item_group" id="forums-<%= group.id %>">
|
||||
<div class="header">
|
||||
<%= group.name %>
|
||||
<%= link_to "edit", edit_forumgroup_path(group), class: "editlink" if admin? %>
|
||||
</div>
|
||||
|
||||
<div class="forums">
|
||||
<div class="items">
|
||||
<% group.forums.each do |f| %>
|
||||
<%= link_to f.name, f, class: "forum" %>
|
||||
<%= link_to f.name, f, class: "item" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -3,15 +3,12 @@
|
||||
<p><%= link_to "New thread", new_forum_forumthread_path(@forum), class: "btn blue" %></p>
|
||||
|
||||
<div id="forum_groups">
|
||||
<div id="forum-<%= @forum.id %>" class="group">
|
||||
<div id="forum-<%= @forum.id %>" class="item_group">
|
||||
<div class="header">
|
||||
<%= @forum.name %> <%= link_to "edit", edit_forum_path(@forum), class: "editlink" %>
|
||||
</div>
|
||||
<div class="forums">
|
||||
<% @threads.select{ |t| t.sticky }.each do |thread| %>
|
||||
<%= link_to thread.title, forum_forumthread_path(@forum, thread), class: "forum sticky" %>
|
||||
<% end %>
|
||||
<% @threads.reject{ |t| t.sticky }.each do |thread| %>
|
||||
<%= link_to thread.title, forum_forumthread_path(@forum, thread), class: "forum" %>
|
||||
<div class="items">
|
||||
<% @threads.each do |thread| %>
|
||||
<%= link_to thread.title, forum_forumthread_path(@forum, thread), class: "item#{" locked" if thread.locked}#{" sticky" if thread.sticky}" %>
|
||||
<% end %>
|
||||
</div>
|
||||
9
app/views/forumthreads/edit.html.erb
Normal file
9
app/views/forumthreads/edit.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<h1>Edit thread</h1>
|
||||
<p id="markdown-note">Note: You can use <%= link_to "Markdown", "https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet", target: "_blank" %>!</p>
|
||||
<%= simple_form_for [@thread.forum, @thread] do |f|%>
|
||||
<%= f.input :title, label: false %>
|
||||
<%= f.hidden_field :content, id: "epic-textarea", label: false, input_html: {class: "full-width vertical"} %>
|
||||
<div id="epic"></div>
|
||||
<%= f.submit "Update thread", class: "btn blue left" %>
|
||||
<% end %>
|
||||
<%= button_to "Delete thread", [@thread.forum, @thread], :method => "delete", :confirm => "Delete thread & comments forever?", class: "btn red right" %>
|
||||
@@ -1,17 +1,17 @@
|
||||
<%= link_to @forum.group, forumgroup_path(@forum.group) %> → <%= link_to @forum, @forum %> → New thread
|
||||
<h1>New thread</h1>
|
||||
<%= simple_form_for [@forum, @thread] do |f|%>
|
||||
<% if mod? %>
|
||||
<%= f.label :sticky %> <%= f.input :sticky %>
|
||||
<%= f.label :locked %> <%= f.input :locked %>
|
||||
<% end %>
|
||||
<div id="form_labels">
|
||||
<%= f.label :title %>
|
||||
<%= f.label :content, "Text" %>
|
||||
</div>
|
||||
<div id="form_inputs">
|
||||
<%= f.input :title, placeholder: "Title" %>
|
||||
<%= f.input :content, placeholder: "Text" %>
|
||||
</div>
|
||||
<% if mod? %>
|
||||
<%= f.input :sticky %> <%= f.label :sticky %>
|
||||
<%= f.input :locked %> <%= f.label :locked %>
|
||||
<% end %>
|
||||
<%= f.submit "Create forum", class: "btn blue" %><br>
|
||||
<%= f.hidden_field :content, id: "epic-textarea", placeholder: "Text" %>
|
||||
<div id="epic"></div>
|
||||
<%= f.submit "Create thread", class: "btn blue" %><br>
|
||||
<% end %>
|
||||
16
app/views/forumthreads/show.html.erb
Normal file
16
app/views/forumthreads/show.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → <%= link_to @thread %>
|
||||
<div class="post">
|
||||
<div class="thread-title">
|
||||
<h1><%= @thread.title %></h1>
|
||||
</div>
|
||||
<div class="thread-info"><%= link_user @thread.author %> on <%= @thread.created_at.strftime("%e. %b %Y") %>
|
||||
<% if mod? %>
|
||||
<%= link_to "edit", edit_forum_forumthread_path(@thread.forum, @thread), class: "thread-edit" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="thread-content">
|
||||
<%= Sanitize.clean(GitHub::Markdown.render_gfm(@thread.content), Sanitize::Config::RELAXED).html_safe %>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
(replies go here)
|
||||
Reference in New Issue
Block a user