Forum ajouté

This commit is contained in:
Nico 2013-01-31 19:41:11 +01:00
parent 33629bffc4
commit 83d893330a
84 changed files with 3934 additions and 16 deletions

View File

@ -20,6 +20,7 @@ group :assets do
gem 'uglifier', '>= 1.0.3' gem 'uglifier', '>= 1.0.3'
gem 'compass-rails' gem 'compass-rails'
gem 'zurb-foundation', ">= 3.2"
end end
gem 'jquery-rails' gem 'jquery-rails'

View File

@ -87,6 +87,9 @@ GEM
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
mime-types (1.19) mime-types (1.19)
modular-scale (1.0.2)
compass (>= 0.11.5)
sassy-math (>= 1.2)
multi_json (1.5.0) multi_json (1.5.0)
mysql2 (0.3.11) mysql2 (0.3.11)
net-scp (1.0.4) net-scp (1.0.4)
@ -138,6 +141,8 @@ GEM
railties (~> 3.2.0) railties (~> 3.2.0)
sass (>= 3.1.10) sass (>= 3.1.10)
tilt (~> 1.3) tilt (~> 1.3)
sassy-math (1.2)
compass (~> 0.11)
sprockets (2.2.2) sprockets (2.2.2)
hike (~> 1.2) hike (~> 1.2)
multi_json (~> 1.0) multi_json (~> 1.0)
@ -155,6 +160,11 @@ GEM
warden (1.2.1) warden (1.2.1)
rack (>= 1.0) rack (>= 1.0)
yajl-ruby (1.1.0) yajl-ruby (1.1.0)
zurb-foundation (3.2.3)
compass (>= 0.12.2)
modular-scale (>= 1.0.2)
rake
sass (>= 3.2.0)
PLATFORMS PLATFORMS
ruby ruby
@ -183,3 +193,4 @@ DEPENDENCIES
rvm-capistrano rvm-capistrano
sass-rails (~> 3.2.3) sass-rails (~> 3.2.3)
uglifier (>= 1.0.3) uglifier (>= 1.0.3)
zurb-foundation (>= 3.2)

View File

@ -0,0 +1,137 @@
/*
*= require ./shared/jquery.js
*= require jquery_ujs
*= require ./note_files/ajquery.ui.widget
*= require ./note_files/jquery.fileupload
*= require ./shared/ace.js
*= require ./shared/mode-markdown.js
*= require ./shared/theme-textmate.js
*/
var editor = new Array();
function init_user_images(){
$(".message_form").find(".images .user_image").click(function(){
var src;
src = $(this).data("src");
r= $(this).closest(".message_form").find("textarea.markdown").data("id");
editor[r].focus();
editor[r].insert("\n\n![](<usrimg:"+src+">)\n\n");
editor[r].focus();
return false;
});
}
$(document).ready(function(){
$("textarea.markdown").each(function(){
var r;
var ed;
r = Math.floor((Math.random()*1000)+1);
$(this).data("id", r);
$(this).attr("id", r+"-textarea");
$(this).after('<div id="'+r+'-editor" class="ace_editor">bla</div>');
editor[r] = ace.edit(r+"-editor");
editor[r].setTheme("ace/theme/textmate");
editor[r].getSession().setMode("ace/mode/markdown");
editor[r].setPrintMarginColumn(0);
editor[r].session.setUseWrapMode(true);
editor[r].setHighlightActiveLine(false);
editor[r].renderer.setShowGutter(false);
editor[r].renderer.setShowPrintMargin(false);
editor[r].setFontSize("14px");
var textarea = $('#'+r+'-textarea').hide();
editor[r].getSession().setValue(textarea.val());
editor[r].getSession().on('change', function(){
textarea.val(editor[r].getSession().getValue());
});
});
//upload
drop = $('.user_images');
$('.user_images .fileupload').fileupload({
url: $(this).attr("action"),
dropZone: drop,
autoUpload: true,
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
if(progress == 100){
$(this).find('.progress').html('traitement en cours.');
}
else{
$(this).find('.progress').html(progress + '% téléchargé.');}
},
always: function (e, data) {
$(this).find('.progress').html("");
},
drop: function (e, data) {
drop.css("background", "transparent");
}
});
drop.bind('dragover', function (e) {
$(this).css("background", "#B7DF63");
});
drop.bind('dragleave', function (e) {
$(this).css("background", "transparent");
});
$(".user_images .add_files").live("click",function(){
$(this).next('input').click();
return false;
});
});

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
ace.define("ace/ext/static_highlight",["require","exports","module","ace/edit_session","ace/layer/text"],function(e,t,n){var r=e("../edit_session").EditSession,i=e("../layer/text").Text,s=".ace_editor {font-family: 'Monaco', 'Menlo', 'Droid Sans Mono', 'Courier New', monospace;font-size: 12px;}.ace_editor .ace_gutter { width: 25px !important;display: block;float: left;text-align: right; padding: 0 3px 0 0; margin-right: 3px;}.ace_line { clear: both; }*.ace_gutter-cell {-moz-user-select: -moz-none;-khtml-user-select: none;-webkit-user-select: none;user-select: none;}";t.render=function(e,t,n,o,u){o=parseInt(o||1,10);var a=new r("");a.setMode(t),a.setUseWorker(!1);var f=new i(document.createElement("div"));f.setSession(a),f.config={characterWidth:10,lineHeight:20},a.setValue(e);var l=[],c=a.getLength();for(var h=0;h<c;h++)l.push("<div class='ace_line'>"),u||l.push("<span class='ace_gutter ace_gutter-cell' unselectable='on'>"+(h+o)+"</span>"),f.$renderLine(l,h,!0,!1),l.push("</div>");var p="<div class=':cssClass'> <div class='ace_editor ace_scroller ace_text-layer'> :code </div> </div>".replace(/:cssClass/,n.cssClass).replace(/:code/,l.join(""));return f.destroy(),{css:s+n.cssText,html:p}}})

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"],function(e,t,n){t.isDark=!1,t.cssClass="ace-tm",t.cssText='.ace-tm .ace_gutter {background: #f0f0f0;color: #333;}.ace-tm .ace_print-margin {width: 1px;background: #e8e8e8;}.ace-tm .ace_fold {background-color: #6B72E6;}.ace-tm .ace_scroller {background-color: #FFFFFF;}.ace-tm .ace_cursor {border-left: 2px solid black;}.ace-tm .ace_overwrite-cursors .ace_cursor {border-left: 0px;border-bottom: 1px solid black;}.ace-tm .ace_invisible {color: rgb(191, 191, 191);}.ace-tm .ace_storage,.ace-tm .ace_keyword {color: blue;}.ace-tm .ace_constant {color: rgb(197, 6, 11);}.ace-tm .ace_constant.ace_buildin {color: rgb(88, 72, 246);}.ace-tm .ace_constant.ace_language {color: rgb(88, 92, 246);}.ace-tm .ace_constant.ace_library {color: rgb(6, 150, 14);}.ace-tm .ace_invalid {background-color: rgba(255, 0, 0, 0.1);color: red;}.ace-tm .ace_support.ace_function {color: rgb(60, 76, 114);}.ace-tm .ace_support.ace_constant {color: rgb(6, 150, 14);}.ace-tm .ace_support.ace_type,.ace-tm .ace_support.ace_class {color: rgb(109, 121, 222);}.ace-tm .ace_keyword.ace_operator {color: rgb(104, 118, 135);}.ace-tm .ace_string {color: rgb(3, 106, 7);}.ace-tm .ace_comment {color: rgb(76, 136, 107);}.ace-tm .ace_comment.ace_doc {color: rgb(0, 102, 255);}.ace-tm .ace_comment.ace_doc.ace_tag {color: rgb(128, 159, 191);}.ace-tm .ace_constant.ace_numeric {color: rgb(0, 0, 205);}.ace-tm .ace_variable {color: rgb(49, 132, 149);}.ace-tm .ace_xml-pe {color: rgb(104, 104, 91);}.ace-tm .ace_entity.ace_name.ace_function {color: #0000A2;}.ace-tm .ace_markup.ace_heading {color: rgb(12, 7, 255);}.ace-tm .ace_markup.ace_list {color:rgb(185, 6, 144);}.ace-tm .ace_meta.ace_tag {color:rgb(0, 22, 142);}.ace-tm .ace_string.ace_regex {color: rgb(255, 0, 0)}.ace-tm .ace_marker-layer .ace_selection {background: rgb(181, 213, 255);}.ace-tm.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px white;border-radius: 2px;}.ace-tm .ace_marker-layer .ace_step {background: rgb(252, 255, 0);}.ace-tm .ace_marker-layer .ace_stack {background: rgb(164, 229, 101);}.ace-tm .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgb(192, 192, 192);}.ace-tm .ace_marker-layer .ace_active-line {background: rgba(0, 0, 0, 0.07);}.ace-tm .ace_gutter-active-line {background-color : #dcdcdc;}.ace-tm .ace_marker-layer .ace_selected-word {background: rgb(250, 250, 255);border: 1px solid rgb(200, 200, 250);}.ace-tm .ace_indent-guide {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;}';var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)})

View File

@ -37,7 +37,7 @@
@import "admin/sheets"; @import "admin/sheets";
@import "topics"; @import "admin/topics";

View File

@ -1,13 +1,5 @@
/* /*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self *= require_self
*/ */

View File

@ -0,0 +1,271 @@
@import "compass";
@import "compass/reset";
@import "shared/formtastic";
//$baseFontSize : 16px;
@import "compass";
@import "admin/general";
@import "admin/forms";
body{
.button{
background:#2e2e2e;
color:#fbfbfb;
padding:10px 15px;
display:inline-block;
border-radius:20px;
}
#main{
padding:0 1em;
}
table{
@include border-radius(5px);
border:1px solid #9d9d9f;
.vertical_center{
td{
vertical-align:middle;}
}
width:100%;
th{
background:#2e2e2e;
color:#fbfbfb;
padding:5px;
border:0px;
}
td{
border-bottom:1px solid #9d9d9f;
padding:5px;
}
}
h1{
margin-top:10px;
}
nav#top{
padding:0px;
height:42px;
position:relative;
color:#FFFFFF;
background: #2E2E2E;
*{
color:#FFFFFF;
}
a{
display:inline-block;
padding:13px;
}
.personnal{
width:160px;
float:right;
position:relative;
span{
display:inline-block;
top:-15px;
position:relative;
}
.avatar{
width:36px;
border-radius:50%;
margin:2px;
}
.menu{
display:none;
}
&:hover{
.menu{
display:block;
position:absolute;
z-index:1000;
top:40px;
background:#2E2E2E;
a{
display:block;
width:160px;
padding:10px 15px;
}
}
}
}
}
.message{
min-height:150px;
border:1px solid black;
margin:1em 1em 0 1em;
}
.right{float:right;}
}
.forum_message{
@include border-radius(5px);
@include box-shadow(0px 0px 5px rgba(0,0,0,0.5) inset);
position:relative;
margin-bottom:1em;
min-height:120px;
.left{
@include box-shadow(0px 0px 5px rgba(0,0,0,0.5));
@include border-radius(3px 0px 0px 3px);
position:absolute;
top:0px;
left:0px;
bottom:0px;
width:100px;
background:rgba(0,0,0,0.8);
text-align:center;
padding:10px;
color:rgba(255,255,255,0.9);
*{
text-align:center;
}
.avatar{
width:70px;
height:70px;
@include border-radius(50%);
margin:auto;
}
}
.right{
min-height:150px;
margin-left:120px;
padding:10px 2%;
line-height:1.1em;
float:none;
img{
max-width:100%;
max-height:90%;
}
.large{
max-width:100%;
margin-left:0px;
}
.links{
float:right;
}
}
}
.message_form{
.form{
width:60%;
float:left;
.ace_editor{
height:400px;
width:57%;
border:solid 1px #C9C9C9;
.ace_scroller{
background:transparent !important;
}
}
}
.user_images{
width:40%;
float:left;
.progress{
float:right;
width:250px;
.bar{
text-align:right;
}
}
input[type=file]{
display:none;
}
.images{
height:400px;
overflow:auto;
border:1px solid black;
.user_image_block{
padding:5px;
float:left;
width:120px;
border:1px solid black;
min-height:140px;
text-align:center;
margin:5px;
.user_image{
cursor:pointer;
display:block;
margin:auto;
max-width:120px;
max-height:120px;
}
}
}
}
}

View File

@ -0,0 +1,3 @@
// Place all the styles related to the Forum::ForumUser controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -4,7 +4,39 @@ class ApplicationController < ActionController::Base
protect_from_forgery protect_from_forgery
helper_method :has_permission? helper_method :has_permission?
def has_permission?(text) def has_permission?(text)
true true
end end
def auth_fuser
if !current_fuser
redirect_to new_forum_auth_path
end
end
private
def current_fuser
if session[:forum_user_id] and ForumUser.exists?(session[:forum_user_id])
@current_fuser = ForumUser.find(session[:forum_user_id])
else
nil
end
end
def moderator?
true if current_admin
end
helper_method :current_fuser, :moderator?
end end

View File

@ -0,0 +1,23 @@
# -*- encoding : utf-8 -*-
class Forum::AuthsController < ApplicationController
layout "forum"
def new
end
def create
user = ForumUser.find_by_email(params[:email])
if user && user.authenticate(params[:password])
session[:forum_user_id] = user.id
redirect_to forum_forum_users_path, notice: "Connecté !"
else
flash.now.alert = "Email ou mot de passe incorect"
render "new"
end
end
def logout
session[:forum_user_id] = nil
redirect_to forum_forum_users_path, notice: "Logged out!"
end
end

View File

@ -0,0 +1,58 @@
class Forum::ForumCategoriesController < ApplicationController
layout "forum"
before_filter :auth_fuser
def show
@category = ForumCategory.find(params[:id])
end
def new
@category = ForumCategory.new(:forum_id => params[:forum_id])
end
def edit
@category = ForumCategory.find(params[:id])
end
def create
@category = ForumCategory.new(params[:forum_category])
if @category.save
redirect_to forum_forum_path(@category.forum)
else
render :action => "new"
end
end
def update
@category = ForumCategory.find(params[:id])
if @category.update_attributes(params[:forum_category])
redirect_to forum_forum_path(@category.forum)
else
render :action => "edit"
end
end
def destroy
@category = ForumCategory.find(params[:id])
@category.destroy
redirect_to forum_forum_path(@category.forum)
end
end

View File

@ -0,0 +1,60 @@
class Forum::ForumMessagesController < ApplicationController
layout "forum"
before_filter :auth_fuser
def show
@message = ForumMessage.find(params[:id])
end
def new
@message = ForumMessage.new(:forum_topic_id => params[:topic_id])
end
def edit
@message = ForumMessage.find(params[:id])
end
def create
@message = ForumMessage.new(params[:forum_message])
@message.forum_user = current_fuser
if @message.save
redirect_to forum_forum_topic_path(@message.forum_topic_id)
else
render :action => "new"
end
end
def update
@message = ForumMessage.find(params[:id])
if @message.update_attributes(params[:forum_message])
redirect_to forum_forum_topic_path(@message.forum_topic_id)
else
render :action => "edit"
end
end
def destroy
@message = ForumMessage.find(params[:id])
@message.destroy
redirect_to forum_forum_topic_path(@message.forum_topic_id)
end
end

View File

@ -0,0 +1,59 @@
class Forum::ForumTopicsController < ApplicationController
layout "forum"
before_filter :auth_fuser
def show
@topic = ForumTopic.find(params[:id])
end
def new
@topic = ForumTopic.new(:category_id => params[:category_id])
@topic.forum_messages.new(:forum_user => current_fuser)
end
def edit
@topic = ForumTopic.find(params[:id])
end
def create
@topic = ForumTopic.new(params[:forum_topic])
@topic.forum_user = current_fuser
if @topic.save
redirect_to [:forum, @topic]
else
render :action => "new"
end
end
def update
@topic = ForumTopic.find(params[:id])
if @topic.update_attributes(params[:forum_topic])
redirect_to forum_forum_category_path(@topic.category)
else
render :action => "edit"
end
end
def destroy
@topic = ForumTopic.find(params[:id])
@topic.destroy
redirect_to forum_forum_category_path(@topic.category)
end
end

View File

@ -0,0 +1,37 @@
class Forum::ForumUserImagesController < ApplicationController
before_filter :auth_fuser
def create
@forum_user_image = ForumUserImage.new(:image =>params[:files][0])
@forum_user_image.forum_user = current_fuser
@forum_user_image.save
end
def destroy
@user = ForumUser.find(params[:id])
@user.destroy
redirect_to forum_forum_users_path
end
def rotate
deg = params[:direction] == "right" ? -90 : 90
@forum_user_image = ForumUserImage.find(params[:id])
@forum_user_image.rotate(deg)
end
end

View File

@ -0,0 +1,62 @@
class Forum::ForumUsersController < ApplicationController
layout "forum"
before_filter :auth_fuser
def index
@users = ForumUser.all
end
def show
@user = ForumUser.find(params[:id])
end
def new
@user = ForumUser.new
end
def edit
@user = ForumUser.find(params[:id])
end
def create
@user = ForumUser.new(params[:forum_user])
if @user.save
redirect_to forum_forum_users_path
else
render :action => "new"
end
end
def update
@user = ForumUser.find(params[:id])
if @user.update_attributes(params[:forum_user])
redirect_to forum_forum_user_path(@user)
else
render :action => "edit"
end
end
def destroy
@user = ForumUser.find(params[:id])
@user.destroy
redirect_to forum_forum_users_path
end
end

View File

@ -0,0 +1,19 @@
class Forum::ForumsController < ApplicationController
layout "forum"
before_filter :auth_fuser
def index
@forums = Forum.all
end
def show
@forum = Forum.find(params[:id])
end
end

View File

@ -0,0 +1,2 @@
module Forum::ForumUserHelper
end

View File

@ -1,8 +1,19 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
module MarkdownHelper module MarkdownHelper
def m_img(s)
id = s.gsub(/<usrimg:(\w+)>/, '\1').to_i
ForumUserImage.find(id).image.large.url if ForumUserImage.exists?(id)
end
def markdown(text) def markdown(text)
text = text.gsub(/<usrimg:(\w+)>/){|s| m_img s}
renderer = Redcarpet::Render::HTML.new({ renderer = Redcarpet::Render::HTML.new({
:hard_wrap => true :hard_wrap => true
@ -24,6 +35,8 @@ module MarkdownHelper
pre.replace Pygments.highlight(pre.content.rstrip, :lexer => pre.attr("class")) pre.replace Pygments.highlight(pre.content.rstrip, :lexer => pre.attr("class"))
end end
doc.to_s doc.to_s

5
app/models/forum.rb Normal file
View File

@ -0,0 +1,5 @@
class Forum < ActiveRecord::Base
attr_accessible :description, :title
has_many :forum_categories
end

View File

@ -0,0 +1,8 @@
class ForumCategory < ActiveRecord::Base
attr_accessible :description, :parent_id, :title, :forum_id
belongs_to :forum
has_many :forum_topics, :foreign_key => :category_id
validates :title, :presence => true
end

View File

@ -0,0 +1,19 @@
# -*- encoding : utf-8 -*-
class ForumMessage < ActiveRecord::Base
belongs_to :forum_user
attr_accessible :description, :title, :forum_topic_id, :forum_user, :forum_user_id
validates :description, :presence => true
belongs_to :topic, :class_name => "ForumTopic"
belongs_to :forum_user
def username
if self.forum_user
self.forum_user.firstname.to_s+" "+
self.forum_user.name.to_s
else
"utilisateur supprimé"
end
end
end

32
app/models/forum_topic.rb Normal file
View File

@ -0,0 +1,32 @@
# -*- encoding : utf-8 -*-
class ForumTopic < ActiveRecord::Base
belongs_to :forum_user
attr_accessible :description, :title, :forum_messages_attributes, :category_id
has_many :forum_messages
accepts_nested_attributes_for :forum_messages
validates :title, :presence => true
belongs_to :category, :class_name => "ForumCategory"
def username
if self.forum_user
self.forum_user.firstname.to_s+" "+
self.forum_user.name.to_s
else
"utilisateur supprimé"
end
end
def principal
self.forum_messages.order("created_at").first
end
end

14
app/models/forum_user.rb Normal file
View File

@ -0,0 +1,14 @@
class ForumUser < ActiveRecord::Base
attr_accessible :bio, :email, :firstname, :name, :password, :password_confirmation, :avatar, :moderator
has_secure_password
validates_presence_of :password, :on => :create
validates_presence_of :email, :presence => true, :uniqueness => true
mount_uploader :avatar, AvatarUploader
has_many :messages, :class_name => "ForumMessage"
has_many :topics, :class_name => "ForumTopic"
has_many :images, :class_name => "ForumUserImage", :order => "created_at DESC"
end

View File

@ -0,0 +1,25 @@
class ForumUserImage < ActiveRecord::Base
belongs_to :album_id
belongs_to :forum_user
attr_accessor :original_imagename
attr_accessible :description, :image, :title, :views, :original_imagename
mount_uploader :image, UserImageUploader
def rotate(degrees=90)
versions = [self.image.path, self.image.large.path, self.image.thumb.path]
versions.each do |v|
image = Magick::ImageList.new(v)
image = image.rotate(degrees)
image.write(v)
end
self.updated_at = Time.now
self.save
end
end

View File

@ -1,7 +1,7 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class NoteFile < ActiveRecord::Base class NoteFile < ActiveRecord::Base
attr_accessor :file_cache, :original_filename
attr_accessible :description, :file, :name, :slug, :note, :note_id, :file_cache, :original_filename attr_accessible :description, :file, :name, :slug, :note, :note_id, :file_cache, :original_filename
belongs_to :note belongs_to :note
mount_uploader :file, FileUploader mount_uploader :file, FileUploader

View File

@ -0,0 +1,61 @@
# -*- encoding : utf-8 -*-
class UserImageUploader < CarrierWave::Uploader::Base
# Include RMagick or ImageScience support:
include CarrierWave::RMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
storage :file
# storage :s3
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"public_medias/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
process :resize_to_limit => [1024, 1024]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
version :large do
process :resize_to_limit => [800, 800]
end
version :thumb do
process :resize_to_limit => [400, 400]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(jpg jpeg gif png)
end
# Override the filename of the uploaded files:
def filename
File.basename(original_filename, File.extname(original_filename)).to_s.to_slug + File.extname(original_filename).to_s if original_filename
end
end

View File

@ -0,0 +1,12 @@
%h1 Login
= form_tag forum_auths_path do
%p
= label_tag :email
= text_field_tag :email, params[:email]
%p
= label_tag :password
= password_field_tag :password
%p= submit_tag "Log In"

View File

@ -0,0 +1,11 @@
= semantic_form_for [:forum, @category] do |f|
=f.inputs :name => "Basic" do
= f.input :title, :label => "Titre"
= f.input :description, :label => "Description"
= f.hidden_field :forum_id
=f.submit "Sauvegarder"

View File

@ -0,0 +1,15 @@
%tr.category
%td
%h2=link_to forum_category.title, [:forum, forum_category]
=markdown forum_category.description
%td
=forum_category.forum_topics.count
-if moderator?
%td
=link_to "modifier", edit_forum_forum_category_path(forum_category)
=link_to "supprimer", [:forum, forum_category], :confirm => "Supprimer cette catégorie ?", :method => :delete

View File

@ -0,0 +1 @@
=render :partial => "form"

View File

@ -0,0 +1 @@
=render :partial => "form"

View File

@ -0,0 +1,17 @@
=link_to "forum "+@category.forum.title, forum_forum_path(@category.forum)
>
= @category.title
=link_to "Nouveau topic", new_forum_forum_topic_path(:category_id => @category.id), :class => "button", :style => "margin:1em 0em;float:right"
%h1= @category.title
%table
%tr
%th Titre
%th Réponses
%th Démaré par
%th le
%th dernier message
-if moderator?
%th Actions
=render @category.forum_topics

View File

@ -0,0 +1,16 @@
.message_form
.form
= form_for [:forum, @message] do |f|
%h3 Contenu du message
=f.submit "Sauvegarder"
=f.hidden_field :forum_topic_id
=f.hidden_field :forum_user_id
=f.text_area :description, :class => "markdown"
%p{:style => "height:400px;"}
=f.submit "Sauvegarder"
=render :partial => "forum/forum_user_images/images_form"

View File

@ -0,0 +1,31 @@
.forum_message#forum_message{:id => forum_message.id}
.left
.user
-if forum_message.forum_user
=image_tag (forum_message.forum_user.avatar? ? forum_message.forum_user.avatar.square.url : ""), :class => "avatar"
=forum_message.forum_user.firstname
=forum_message.forum_user.name
-else
utilisateur supprimé
.date=l forum_message.created_at, :format => :short
.right
.links
=link_to "modifier", edit_forum_forum_message_path(forum_message)
=link_to "supprimer", [:forum, forum_message], :confirm => "Supprimer ce message ?", :method => :delete
=markdown forum_message.description
:javascript
$('.forum_message .right img').each(function(){
$(this).closest("p").css("width", "100%");
$(this).closest("p").css("max-width", "100%");
});

View File

@ -0,0 +1 @@
=render :partial => "form"

View File

@ -0,0 +1 @@
=render :partial => "form"

View File

@ -0,0 +1,34 @@
.message_form
= form_for [:forum, @topic] do |f|
%p
= f.label :title, "Titre : ", :style => "width:8%;display:inline-block;"
= f.text_field :title, :style => "width:90%;"
.form
%h3 Contenu du message
= f.hidden_field :category_id
=f.fields_for :forum_messages do |f|
=f.hidden_field :forum_user_id
=f.text_area :description, :class => "markdown"
%div{:style => "height:402px;"}
=f.submit "Sauvegarder"
=render :partial => "forum/forum_user_images/images_form"

View File

@ -0,0 +1,15 @@
%tr.topic
%td=link_to forum_topic.title, [:forum, forum_topic]
%td=forum_topic.forum_messages.count - 1
%td= forum_topic.username
%td=l forum_topic.created_at
%td
=l forum_topic.forum_messages.last.created_at
par
=forum_topic.forum_messages.last.username
-if moderator?
%td
=link_to "supprimer", [:forum, forum_topic], :confirm => "Supprimer ce topic ?", :method => :delete
=link_to forum_topic.title, [:forum, forum_topic]

View File

@ -0,0 +1 @@
=render :partial => "form"

View File

@ -0,0 +1 @@
=render :partial => "form"

View File

@ -0,0 +1,10 @@
=link_to "forum "+@topic.category.forum.title, forum_forum_path(@topic.category.forum)
>
=link_to @topic.category.title, [:forum, @topic.category]
>
=link_to "ajouter un message", new_forum_forum_message_path(:topic_id => @topic.id), :class => "button", :style => "margin:1em 0em;float:right"
%h1= @topic.title
%br
%br
=render @topic.forum_messages

View File

@ -0,0 +1,6 @@
#user_image.user_image_block{:id => forum_user_image.id}
=image_tag forum_user_image.image.thumb.url+"?"+forum_user_image.updated_at.to_s, :"data-src" => forum_user_image.id, :class => "user_image"
= link_to i(:rotate, :gray_light, "12x14"), rotate_forum_forum_user_image_path(:id => forum_user_image.id, :manager => params[:manager], :multiple => params[:multiple]), :remote => true
= link_to i(:rotate_right, :gray_light, "12x14"), rotate_forum_forum_user_image_path(:id => forum_user_image.id, :manager => params[:manager], :multiple => params[:multiple], :direction => :right), :remote => true

View File

@ -0,0 +1,29 @@
.user_images
%h3 Mon album photo
.images=render current_fuser.images
%form.fileupload{:action => forum_forum_user_images_path(), :enctype => "multipart/form-data", :method => "POST"}
.upload
.progress
.bar{:style => "height:1em;"}
%button.add_files ajouter des photos
%input{:multiple => "", :name => "files[]", :type => "file", :style => "float:right;"}
:javascript
init_user_images();
%p{:style => "clear:both;"} Vous pouvez télécharger de nouvelles images pour les ajouter dans votre message en cliquant sur "ajouter des photos" où en les glissant sur cette zone.
%p Vous pouvez ensuite ajouter une image dans votre message en cliquant sur celle que vous souhaitez ajouter.

View File

@ -0,0 +1,2 @@
$('.user_images .images').html('<%= escape_javascript(render(current_fuser.images))%>');
init_user_images();

View File

@ -0,0 +1,2 @@
$('#user_image_<%= @forum_user_image.id %>').replaceWith("<%= escape_javascript(render(@forum_user_image))%>");

View File

@ -0,0 +1,15 @@
= semantic_form_for [:forum, @user] do |f|
=f.inputs :name => "Basic" do
= f.input :firstname, :label => "Prénom"
= f.input :name, :label => "Nom"
= f.input :email, :label => "Email"
= f.input :password, :label => "Mot de passe"
= f.input :password_confirmation, :label => "Confirmation"
= f.input :avatar, :label => "Image de profil"
=image_tag(f.object.avatar.square.url) if f.object.avatar
=f.submit "Sauvegarder"

View File

@ -0,0 +1,12 @@
%tr.vertical_center.forum_user#forum_user{:id => forum_user.id}
%td=image_tag (forum_user.avatar? ? forum_user.avatar.square.url : ""), :class => "avatar", :style => "width:50px; border-radius:50%;"
%td=link_to forum_user.firstname.to_s+" "+forum_user.name.to_s, forum_forum_user_path(forum_user)
%td=forum_user.topics.count
%td=forum_user.messages.count
-if moderator?
%td
=link_to "voir", edit_forum_forum_user_path(forum_user)
=link_to "supprimer", [:forum, forum_user], :method => :delete, :confirm => "Voulez-vous vraiment supprimer cet utilisateur ?"

View File

@ -0,0 +1 @@
=render :partial => "form"

View File

@ -0,0 +1,13 @@
=link_to "nouvel utilisateur", new_forum_forum_user_path, :class => "button", :style => "margin:1em 0em;float:right"
%h1 Liste des utilisateurs
%table
%tr
%th{:style => "width:50px;"}
%th Nom
%th Messages
%th Topics
-if moderator?
%th Actions
=render @users

View File

@ -0,0 +1 @@
=render :partial => "form"

View File

@ -0,0 +1,7 @@
=image_tag (@user.avatar? ? @user.avatar.square.url : ""), :class => "avatar", :style => "width:100px; border-radius:1em;"
%p
=@user.firstname
=@user.name
%p
=link_to "modifier", edit_forum_forum_user_path(@user)

View File

@ -0,0 +1 @@
=debug @forums

View File

@ -0,0 +1,15 @@
=link_to "ajouter une catégorie", new_forum_forum_category_path(:forum_id => @forum.id), :class => "button", :style => "margin:1em 0em;float:right" if moderator?
%h1=@forum.title
.description
=markdown @forum.description
%table
%tr
%th Titre
%th Topics
-if moderator?
%th Actions
=render @forum.forum_categories

View File

@ -0,0 +1,61 @@
!!!
%html{:lang => "fr"}
%head
%meta{:"http-equiv" => "content-type" ,:content =>"text/html;charset=UTF-8" }
%title
Forum
=javascript_include_tag "forum"
=stylesheet_link_tag "forum"
= csrf_meta_tag
%style=Pygments.css('.highlight')
=javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false&region=FR"
%body
-if current_fuser
%nav#top
=link_to "utilisateurs", forum_forum_users_path
=link_to "forum", forum_forum_path(:id => 1)
.personnal
=image_tag (current_fuser.avatar? ? current_fuser.avatar.square.url : ""), :class => "avatar"
%span
=current_fuser.firstname
=current_fuser.name
.menu
=link_to "se déconnecter", logout_forum_auths_path, :method => :delete
#main= yield
#flash
-if flash[:alert] or (@flash_i and @flash_i[:alert])
.message.closeable.alert
= flash[:alert]
= @flash_i[:alert] if @flash_i and @flash_i[:alert]
-if flash[:notice]
.message.closeable.notice
= flash[:notice]

View File

@ -21,8 +21,8 @@
%td{:style => "width:16%;text-align:right;"} %td{:style => "width:16%;text-align:right;"}
-if has_permission?('adherent.edit') -if has_permission?('adherent.edit')
= link_to image_tag("/images/style/quartz-admin/delete.png"), :url => person, :method => :delete, :confirm => "Voulez-vous vraiment supprimer "+person.name.to_s+" de cette fiche ?", :remote => true = link_to image_tag("/images/style/quartz-admin/delete.png"), :url => person, :method => :delete, :confirm => "Voulez-vous vraiment supprimer "+person.name.to_s+" de cette fiche ?", :remote => true
= link_to image_tag("/images/style/quartz-admin/edit.png"), :url => edit_person_path(person), :method => :get, :remote => true = link_to image_tag("/images/style/quartz-admin/edit.png"), edit_person_path(person), :remote => true
-if person == person.sheet.person -if person == person.sheet.person
-img = image_tag("/images/style/quartz-admin/principal_active.png") -img = image_tag("/images/style/quartz-admin/principal_active.png")
-else -else

View File

@ -37,7 +37,7 @@
= link_to 'Ajouter', :url => new_donate_path(:sheet_id => @sheet), :update => "new_donate", :method => :get, :remote => true #if has_permission?('adherent.edit') = link_to 'Ajouter', :url => new_donate_path(:sheet_id => @sheet), :update => "new_donate", :method => :get, :remote => true #if has_permission?('adherent.edit')
#new_donate #new_donate
#donates #donates
=render @sheet.donates =#render @sheet.donates

View File

@ -2,12 +2,34 @@
Survey::Application.routes.draw do Survey::Application.routes.draw do
get "forum_user/index"
namespace :admin do namespace :admin do
root :to => "dashboard#index" root :to => "dashboard#index"
resources :admins resources :admins
end end
namespace :forum do
root :to => "forums#show", :id => 1
resources :forum_topics
resources :forum_messages
resources :forums
resources :forum_categories
resources :forum_users
resources :forum_user_images do
member do
get :rotate
end
end
resources :auths do
collection do
get :logout
end
end
end
resources :note_files resources :note_files
resources :notes resources :notes

View File

@ -0,0 +1,12 @@
class CreateForums < ActiveRecord::Migration
def change
create_table :forums do |t|
t.string :title
t.text :description
t.timestamps
end
Forum.create :title => "photo", :description => "forum photo"
end
end

View File

@ -0,0 +1,12 @@
class CreateForumCategories < ActiveRecord::Migration
def change
create_table :forum_categories do |t|
t.string :title
t.text :description
t.integer :parent_id
t.references :forum
t.timestamps
end
end
end

View File

@ -0,0 +1,13 @@
class CreateForumTopics < ActiveRecord::Migration
def change
create_table :forum_topics do |t|
t.references :forum_user
t.references :category
t.string :title
t.text :description
t.timestamps
end
add_index :forum_topics, :forum_user_id
end
end

View File

@ -0,0 +1,13 @@
class CreateForumMessages < ActiveRecord::Migration
def change
create_table :forum_messages do |t|
t.references :forum_user
t.references :forum_topic
t.string :title
t.text :description
t.timestamps
end
add_index :forum_messages, :forum_user_id
end
end

View File

@ -0,0 +1,40 @@
class CreateForumUsers < ActiveRecord::Migration
def change
create_table :forum_users do |t|
t.string :name
t.string :firstname
t.text :bio
t.string :avatar
t.string :localisation
t.boolean :moderator
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :password_digest, :null => false, :default => ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, :default => 0
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
t.boolean :lock
t.datetime :locked_at
t.timestamps
end
ForumUser.create(:email => "info@nicolasbally.com", :password => "123456", :password_confirmation => "123456")
end
end

View File

@ -0,0 +1,16 @@
class CreateForumUserImages < ActiveRecord::Migration
def change
create_table :forum_user_images do |t|
t.references :album_id
t.references :forum_user
t.string :image
t.string :title
t.integer :views
t.text :description
t.timestamps
end
add_index :forum_user_images, :album_id_id
add_index :forum_user_images, :forum_user_id
end
end

View File

@ -1,4 +1,4 @@
# -*- encoding : utf-8 -*- # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to # of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition. # incrementally modify your database, and then regenerate this schema definition.
@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20121202213550) do ActiveRecord::Schema.define(:version => 20130115105842) do
create_table "admins", :force => true do |t| create_table "admins", :force => true do |t|
t.string "email", :default => "", :null => false t.string "email", :default => "", :null => false
@ -59,6 +59,79 @@ ActiveRecord::Schema.define(:version => 20121202213550) do
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
create_table "forum_categories", :force => true do |t|
t.string "title"
t.text "description"
t.integer "parent_id"
t.integer "forum_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "forum_messages", :force => true do |t|
t.integer "forum_user_id"
t.integer "forum_topic_id"
t.string "title"
t.text "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "forum_messages", ["forum_user_id"], :name => "index_forum_messages_on_forum_user_id"
create_table "forum_topics", :force => true do |t|
t.integer "forum_user_id"
t.integer "category_id"
t.string "title"
t.text "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "forum_topics", ["forum_user_id"], :name => "index_forum_topics_on_forum_user_id"
create_table "forum_user_images", :force => true do |t|
t.integer "album_id_id"
t.integer "forum_user_id"
t.string "image"
t.string "title"
t.integer "views"
t.text "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "forum_user_images", ["album_id_id"], :name => "index_forum_user_images_on_album_id_id"
add_index "forum_user_images", ["forum_user_id"], :name => "index_forum_user_images_on_forum_user_id"
create_table "forum_users", :force => true do |t|
t.string "name"
t.string "firstname"
t.text "bio"
t.string "avatar"
t.string "email", :default => "", :null => false
t.string "password_digest", :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.boolean "lock"
t.datetime "locked_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "forums", :force => true do |t|
t.string "title"
t.text "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "newsgroups", :force => true do |t| create_table "newsgroups", :force => true do |t|
t.string "name" t.string "name"
t.text "description" t.text "description"

11
test/fixtures/forum_categories.yml vendored Normal file
View File

@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
title: MyString
description: MyText
parent_id: 1
two:
title: MyString
description: MyText
parent_id: 1

11
test/fixtures/forum_messages.yml vendored Normal file
View File

@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
forum_user:
title: MyString
description: MyText
two:
forum_user:
title: MyString
description: MyText

11
test/fixtures/forum_topics.yml vendored Normal file
View File

@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
forum_user:
title: MyString
description: MyText
two:
forum_user:
title: MyString
description: MyText

17
test/fixtures/forum_user_images.yml vendored Normal file
View File

@ -0,0 +1,17 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
album_id:
forum_user:
image: MyString
title: MyString
views: 1
description: MyText
two:
album_id:
forum_user:
image: MyString
title: MyString
views: 1
description: MyText

17
test/fixtures/forum_users.yml vendored Normal file
View File

@ -0,0 +1,17 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
name: MyString
firstname: MyString
email: MyString
password: MyString
password_confirmation: MyString
bio: MyText
two:
name: MyString
firstname: MyString
email: MyString
password: MyString
password_confirmation: MyString
bio: MyText

9
test/fixtures/forums.yml vendored Normal file
View File

@ -0,0 +1,9 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
title: MyString
description: MyText
two:
title: MyString
description: MyText

View File

@ -0,0 +1,9 @@
require 'test_helper'
class Forum::ForumUserControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ForumCategoryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ForumMessageTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

7
test/unit/forum_test.rb Normal file
View File

@ -0,0 +1,7 @@
require 'test_helper'
class ForumTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ForumTopicTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ForumUserImageTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ForumUserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class Forum::ForumUserHelperTest < ActionView::TestCase
end