migration admin portfolio front
This commit is contained in:
parent
424de4ab38
commit
9b95460c8e
@ -1,7 +1,5 @@
|
||||
/*
|
||||
*= require jquery.js
|
||||
|
||||
*= require jquery_ujs
|
||||
|
||||
|
||||
|
||||
@ -38,60 +36,65 @@ function init_portfolio_images(){
|
||||
});
|
||||
}
|
||||
|
||||
function init_markdown(){
|
||||
$("textarea.markdown").each(function(){
|
||||
var r;
|
||||
var ed;
|
||||
|
||||
|
||||
|
||||
r = Math.floor((Math.random()*1000)+1);
|
||||
|
||||
$(this).data("id", r);
|
||||
$(this).removeClass("markdown");
|
||||
|
||||
$(this).attr("id", r+"-textarea");
|
||||
$(this).after('<p style="height:400px;"></p>');
|
||||
$(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());
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(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());
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
init_markdown();
|
||||
//upload
|
||||
|
||||
drop = $('.portfolio .images');
|
||||
|
@ -122,23 +122,8 @@ body {
|
||||
|
||||
}
|
||||
|
||||
.ace_editor{
|
||||
height:400px;
|
||||
width:57%;
|
||||
border:solid 1px #C9C9C9;
|
||||
|
||||
|
||||
.ace_scroller{
|
||||
|
||||
|
||||
background:transparent !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
.page_form{
|
||||
|
||||
.form{
|
||||
|
@ -16,6 +16,36 @@ body{
|
||||
font-family:Palatino, Georgia;
|
||||
|
||||
|
||||
#admin_over{
|
||||
|
||||
.ace_editor{
|
||||
height:400px;
|
||||
width:57%;
|
||||
border:solid 1px #C9C9C9;
|
||||
|
||||
|
||||
.ace_scroller{
|
||||
|
||||
|
||||
background:transparent !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
position:fixed;
|
||||
top:0px;
|
||||
left:0px;
|
||||
z-index:3;
|
||||
|
||||
#portfolio_form{
|
||||
background:rgba(250,250,250, 0.9);
|
||||
padding:1em;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#top{
|
||||
background:#383838;
|
||||
color:white;
|
||||
@ -27,6 +57,8 @@ body{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#small_index{
|
||||
position:fixed;
|
||||
left:252px;
|
||||
@ -106,56 +138,52 @@ width:100px;
|
||||
.portfolio{
|
||||
|
||||
|
||||
.intro{
|
||||
text-align:center;
|
||||
max-width:70%;
|
||||
margin:auto;
|
||||
*{
|
||||
|
||||
text-align:center;
|
||||
}
|
||||
}
|
||||
.fileupload{
|
||||
display:none;
|
||||
|
||||
.intro{
|
||||
text-align:center;
|
||||
max-width:70%;
|
||||
margin:auto;
|
||||
*{
|
||||
text-align:center;
|
||||
}
|
||||
}
|
||||
|
||||
.fileupload{
|
||||
display:none;
|
||||
}
|
||||
|
||||
.images{
|
||||
min-height:400px;
|
||||
text-align:center;
|
||||
|
||||
font-family:courier;
|
||||
.portfolio_image_block{
|
||||
|
||||
.image_block{
|
||||
display:inline-block;
|
||||
max-width:90%;
|
||||
|
||||
|
||||
margin:auto;
|
||||
margin-top:2em;
|
||||
position:relative;
|
||||
|
||||
.image{
|
||||
|
||||
max-height:90%;
|
||||
max-width:100%;
|
||||
//box-shadow: #AFAFAF 0px 0px 5px;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.title{
|
||||
text-align:left;
|
||||
color:gray;
|
||||
|
||||
.exifs{
|
||||
position:absolute;
|
||||
right:0;
|
||||
top:0px;
|
||||
width:110%;
|
||||
|
||||
font-size:0.6em;
|
||||
text-align:right;
|
||||
|
||||
@include transform-origin(top, right);
|
||||
@include rotate(-90deg);
|
||||
|
||||
text-align:right;
|
||||
|
||||
&:hover{
|
||||
font-size:1em;
|
||||
}
|
||||
@ -177,12 +205,18 @@ text-align:center;
|
||||
position:absolute;
|
||||
top:0px;
|
||||
left:0px;
|
||||
bottom:1em;
|
||||
width : 200px;
|
||||
background:rgba(250,250,250, 0.9);
|
||||
overflow:auto;
|
||||
z-index:2;
|
||||
|
||||
}
|
||||
|
||||
&:hover{
|
||||
.admin{
|
||||
display:block;
|
||||
}
|
||||
.admin{
|
||||
display:block;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -209,7 +243,7 @@ text-align:center;
|
||||
|
||||
max-height:85%;
|
||||
max-width:100%;
|
||||
//box-shadow: #AFAFAF 0px 0px 5px;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,62 +0,0 @@
|
||||
class Admin::PortfoliosController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
before_filter :authenticate_admin!
|
||||
|
||||
def index
|
||||
|
||||
@portfolios = Portfolio.all
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
@portfolio = Portfolio.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
|
||||
def new
|
||||
@portfolio = Portfolio.new
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@portfolio = Portfolio.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@portfolio = Portfolio.new(params[:portfolio])
|
||||
|
||||
if @portfolio.save
|
||||
redirect_to admin_portfolios_path
|
||||
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@portfolio = Portfolio.find(params[:id])
|
||||
|
||||
if @portfolio.update_attributes(params[:portfolio])
|
||||
redirect_to admin_portfolios_path
|
||||
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
def destroy
|
||||
@portfolio = Portfolio.find(params[:id])
|
||||
@portfolio.destroy
|
||||
redirect_to admin_portfolios_path
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
@ -1,21 +1,25 @@
|
||||
class PortfoliosController < ApplicationController
|
||||
|
||||
|
||||
before_filter :authenticate_admin!, :except => [:index, :show]
|
||||
|
||||
|
||||
def index
|
||||
@index_images = PortfolioImage.order("Created_at DESC").limit(20)
|
||||
end
|
||||
|
||||
def show
|
||||
@slug = params[:slug]
|
||||
@slug = params[:id]
|
||||
|
||||
if params[:slug]
|
||||
@portfolio = Portfolio.find_by_slug(params[:slug])
|
||||
if params[:id]
|
||||
@portfolio = Portfolio.find_by_slug(params[:id])
|
||||
|
||||
@images = @portfolio.images.page(params[:page]).per(1)
|
||||
@images = @portfolio.images.page(params[:page]).per(@portfolio.content_type? ? @portfolio.content_type.to_i : 1)
|
||||
|
||||
|
||||
@prev_page = @images.current_page.to_i > 1 ? @images.current_page.to_i-1 : @images.total_count
|
||||
@prev_page = @images.current_page.to_i > 1 ? @images.current_page.to_i-1 : @images.num_pages
|
||||
|
||||
@next_page = @images.current_page.to_i < @images.total_count ? @images.current_page.to_i+1 : 1
|
||||
@next_page = @images.current_page.to_i < @images.num_pages ? @images.current_page.to_i+1 : 1
|
||||
|
||||
|
||||
@next_image = @portfolio.images.page(@next_page).per(1).first
|
||||
@ -26,4 +30,47 @@ class PortfoliosController < ApplicationController
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def new
|
||||
@portfolio = Portfolio.new
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@portfolio = Portfolio.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@portfolio = Portfolio.new(params[:portfolio])
|
||||
|
||||
if @portfolio.save
|
||||
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@portfolio = Portfolio.find(params[:id])
|
||||
|
||||
if @portfolio.update_attributes(params[:portfolio])
|
||||
|
||||
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
def destroy
|
||||
@portfolio = Portfolio.find(params[:id])
|
||||
@portfolio.destroy
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
@ -9,6 +9,14 @@ class PortfolioImage < ActiveRecord::Base
|
||||
|
||||
scope :after, lambda {|time| {:conditions => ["shoot_at > ?", time]}}
|
||||
|
||||
def width
|
||||
self.photo.geometry[:width]
|
||||
end
|
||||
|
||||
def height
|
||||
self.photo.geometry[:height]
|
||||
end
|
||||
|
||||
def rotate(degrees=90)
|
||||
versions = [self.photo.path, self.photo.large.path, self.photo.thumb.path]
|
||||
|
||||
|
@ -17,6 +17,13 @@ class ImageUploader < CarrierWave::Uploader::Base
|
||||
def geometry
|
||||
@geometry ||= get_geometry
|
||||
end
|
||||
|
||||
def get_geometry
|
||||
if @file
|
||||
img = ::Magick::Image::read(@file.file).first
|
||||
geometry = { width: img.columns, height: img.rows }
|
||||
end
|
||||
end
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
|
@ -1,8 +0,0 @@
|
||||
= semantic_form_for [:admin, @portfolio_image], :remote => true do |f|
|
||||
=f.inputs :name => "Basic" do
|
||||
= f.input :title, :label => "Titre", :input_html => { :onchange => "$(this).closest('form').submit();", :onkeyup => "$(this).closest('form').submit();"}
|
||||
= f.input :portfolios, :collection => Portfolio.all, :as => :check_boxes, :input_html => { :onchange => "$(this).closest('form').submit();"}
|
||||
|
||||
=f.submit "Sauvegarder"
|
||||
|
||||
|
@ -1 +1 @@
|
||||
$('#portfolio_image_<%=@portfolio_image.id%>').remove();
|
||||
$('#image_<%=@portfolio_image.id%>').remove();
|
@ -1 +1 @@
|
||||
$('#portfolio_image_form_<%= @portfolio_image.id %>').replaceWith("<%= escape_javascript(render(:partial => 'form'))%>");
|
||||
$('#image_form_<%= @portfolio_image.id %>').replaceWith("<%= escape_javascript(render(:partial => 'form'))%>");
|
@ -1,2 +1,2 @@
|
||||
|
||||
$('#portfolio_image_<%= @portfolio_image.id %>').replaceWith("<%= escape_javascript(render(@portfolio_image))%>");
|
||||
$('#image_<%= @portfolio_image.id %>').replaceWith("<%= escape_javascript(render(@portfolio_image))%>");
|
@ -1,17 +0,0 @@
|
||||
= semantic_form_for [:admin, @portfolio] do |f|
|
||||
=f.inputs :name => "Basic" do
|
||||
|
||||
=f.select :content_type, [1,2]
|
||||
= f.input :title, :label => "Titre"
|
||||
= f.input :slug, :label => "Slug"
|
||||
= f.input :description, :label => "Description"
|
||||
= f.input :keywords, :label => "Mot clefs"
|
||||
|
||||
.page_form
|
||||
=f.text_area :markdown_content, :class => "markdown"
|
||||
%p{:style => "height:400px;"}
|
||||
|
||||
|
||||
=f.submit "Sauvegarder"
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
%tr.portfolio#portfolio{:id => portfolio.id}
|
||||
|
||||
%td=portfolio.title
|
||||
%td= link_to(portfolio.path,portfolio.path)
|
||||
|
||||
|
||||
%td
|
||||
=link_to "voir", [:admin, portfolio]
|
||||
=link_to "modifier", edit_admin_portfolio_path(portfolio)
|
||||
=link_to "supprimer", [:admin, portfolio], :method => :delete, :confirm => "Voulez-vous vraiment supprimer cette portfolio ?"
|
@ -1 +0,0 @@
|
||||
=render :partial => "form"
|
@ -1,13 +0,0 @@
|
||||
=link_to "nouveau portfolio", new_admin_portfolio_path, :class => "button", :style => "margin:1em 0em;float:right"
|
||||
|
||||
%h1 Liste des portfolios
|
||||
|
||||
%table
|
||||
%tr
|
||||
%th{:style => "width:50px;"}
|
||||
%th Nom
|
||||
%th Messages
|
||||
%th Topics
|
||||
|
||||
%th Actions
|
||||
=render @portfolios
|
@ -1 +0,0 @@
|
||||
=render :partial => "form"
|
@ -1,32 +0,0 @@
|
||||
.portfolio
|
||||
%h1=@portfolio.title
|
||||
=markdown @portfolio.markdown_content
|
||||
|
||||
.portfolio_images
|
||||
|
||||
|
||||
|
||||
|
||||
%form.fileupload{:action => admin_portfolio_images_path(:portfolio_id => @portfolio.id), :enctype => "multipart/form-data", :method => "POST"}
|
||||
|
||||
.upload
|
||||
.progress
|
||||
.bar{:style => "height:1em;"}
|
||||
|
||||
%button.add_files ajouter des photos
|
||||
|
||||
%input{:multiple => "", :name => "portfolio_image[photo]", :type => "file", :style => "float:right;"}
|
||||
|
||||
|
||||
%br
|
||||
|
||||
%br
|
||||
= hidden_field_tag "portfolio_image[portfolio_ids][]", @portfolio.id
|
||||
|
||||
|
||||
|
||||
:javascript
|
||||
init_portfolio_images();
|
||||
|
||||
%br
|
||||
.images=render @portfolio.images
|
@ -21,7 +21,7 @@
|
||||
|
||||
|
||||
%body
|
||||
|
||||
|
||||
#left
|
||||
|
||||
|
||||
@ -32,12 +32,10 @@
|
||||
|
||||
|
||||
%h4 Portfolios
|
||||
=link_to "nouveau portfolio", new_portfolio_path, :remote => true if current_admin
|
||||
|
||||
%ul
|
||||
-Portfolio.all.each do |p|
|
||||
|
||||
%li=link_to p.title, p.path
|
||||
|
||||
%ul.portfolios_links
|
||||
=render Portfolio.order(:title)
|
||||
|
||||
=link_to raw("<h4>Contact</h4>")
|
||||
|
||||
@ -48,3 +46,8 @@
|
||||
=render :partial => "portfolios/pagination"
|
||||
|
||||
#main= yield
|
||||
|
||||
-if current_admin
|
||||
#admin_over
|
||||
|
||||
|
||||
|
41
app/views/portfolio_images/_portfolio_image.haml
Normal file
41
app/views/portfolio_images/_portfolio_image.haml
Normal file
@ -0,0 +1,41 @@
|
||||
-if image.photo?
|
||||
|
||||
|
||||
#image.image_block{:id => image.id, :style => "margin-top:"+(image.ratio > 1 ? "3%" : "0.5%")+";"}
|
||||
|
||||
|
||||
|
||||
=image_tag image.photo.url, :class => "image"
|
||||
%br
|
||||
|
||||
%span.title
|
||||
-if current_admin
|
||||
= form_for [:admin, image], :remote => true do |f|
|
||||
= f.text_field :title, :onchange => "$(this).closest('form').submit();", :onkeyup => "$(this).closest('form').submit();", :style => "display:inline-block !important;width:auto;font-family:courier;", :size => "n"
|
||||
-else
|
||||
=image.title
|
||||
|
||||
="-"
|
||||
=l image.shoot_at, :format => :date if image.shoot_at
|
||||
-if image.exif
|
||||
.exifs
|
||||
=image.exif.model
|
||||
="-"
|
||||
="f "+image.exif.f_number.to_f.to_s
|
||||
="-"
|
||||
=image.exif.exposure_time.to_s+" s"
|
||||
="-"
|
||||
=image.exif.iso_speed_ratings.to_s+" iso"
|
||||
="-"
|
||||
© Nicolas Bally
|
||||
|
||||
-if current_admin
|
||||
.admin
|
||||
#image_form{:id => image.id}
|
||||
=render :partial => "image_form", :locals => {:image => image}
|
||||
|
||||
|
||||
|
||||
%br
|
||||
|
||||
|
18
app/views/portfolios/_form.haml
Normal file
18
app/views/portfolios/_form.haml
Normal file
@ -0,0 +1,18 @@
|
||||
#portfolio_form
|
||||
|
||||
= semantic_form_for @portfolio, :remote => true do |f|
|
||||
=f.inputs :name => "Basic" do
|
||||
|
||||
= f.input :content_type, :label => "nbr images /pages :"
|
||||
= f.input :title, :label => "Titre"
|
||||
= f.input :slug, :label => "Slug"
|
||||
= f.input :description, :label => "Description"
|
||||
= f.input :keywords, :label => "Mot clefs"
|
||||
|
||||
|
||||
=f.text_area :markdown_content, :class => "markdown"
|
||||
|
||||
=f.submit "Sauvegarder"
|
||||
=link_to "fermer", "#", :onclick => "$('#admin_over').html('');return false;"
|
||||
|
||||
|
10
app/views/portfolios/_image_form.haml
Normal file
10
app/views/portfolios/_image_form.haml
Normal file
@ -0,0 +1,10 @@
|
||||
= semantic_form_for [:admin, image], :remote => true do |f|
|
||||
=f.inputs :name => "Basic" do
|
||||
= f.input :title, :label => "Titre", :input_html => { :onchange => "$(this).closest('form').submit();", :onkeyup => "$(this).closest('form').submit();"}
|
||||
= f.input :portfolios, :collection => Portfolio.all, :as => :check_boxes, :input_html => { :onchange => "$(this).closest('form').submit();"}
|
||||
|
||||
=f.submit "Sauvegarder"
|
||||
|
||||
= link_to i(:rotate, :gray_light, "12x14"), rotate_admin_portfolio_image_path(:id => image.id, :manager => params[:manager], :multiple => params[:multiple]), :remote => true
|
||||
= link_to i(:rotate_right, :gray_light, "12x14"), rotate_admin_portfolio_image_path(:id => image.id, :manager => params[:manager], :multiple => params[:multiple], :direction => :right), :remote => true
|
||||
=link_to "supprimer", [:admin, image], :method => :delete, :confirm => "Voulez-vous vraiment supprimer cette image ?", :remote => true
|
@ -1,6 +1,6 @@
|
||||
-if @images
|
||||
#pagination
|
||||
|
||||
|
||||
-if @next_image and @prev_image
|
||||
-url_1 = @next_image.photo.url+"?"+@next_image.updated_at.to_s.to_slug
|
||||
-url_2 =@prev_image.photo.url+"?"+@next_image.updated_at.to_s.to_slug
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
</script>
|
||||
|
||||
%span{:style => "position:relative;top:-0.5em;position:absolute;top:20px;left:0px;right:10px;text-align:center;"}="#"+@images.current_page.to_s+"/"+@images.total_count.to_s
|
||||
%span{:style => "position:relative;top:-0.5em;position:absolute;top:20px;left:0px;right:10px;text-align:center;"}="#"+@images.current_page.to_s+"/"+@images.num_pages.to_s
|
||||
=link_to "<", portfolio_path(:slug => @portfolio.slug, :page => @prev_page, :format => :js), :style => "font-size:3em;position:absolute;bottom:10px;right:60px;", :remote => true, :id => "prev"
|
||||
|
||||
=link_to ">", portfolio_path(:slug => @portfolio.slug, :page => @next_page, :format => :js), :style => "font-size:4em;position:absolute;bottom:10px;right:15px;", :remote => true, :id => "next"
|
6
app/views/portfolios/_portfolio.haml
Normal file
6
app/views/portfolios/_portfolio.haml
Normal file
@ -0,0 +1,6 @@
|
||||
%li#portfolio_line{:id => portfolio.id}
|
||||
=link_to portfolio.title, portfolio.path
|
||||
|
||||
-if current_admin
|
||||
=link_to "m", edit_portfolio_path(portfolio, :format => "js"), :remote => true
|
||||
=link_to "s", portfolio_path(portfolio, :format => "js"), :method => :delete, :confirm => "Voulez-vous vraiment supprimer cette portfolio ?", :remote => true
|
@ -1,42 +0,0 @@
|
||||
-if portfolio_image.photo?
|
||||
|
||||
|
||||
#portfolio_image.portfolio_image_block{:id => portfolio_image.id, :style => "margin-top:"+(portfolio_image.ratio > 1 ? "3%" : "0.5%")+";"}
|
||||
|
||||
|
||||
|
||||
=image_tag portfolio_image.photo.url+"?"+portfolio_image.updated_at.to_s.to_slug, :class => "image"
|
||||
%br
|
||||
|
||||
%span.title
|
||||
-if current_admin
|
||||
= form_for [:admin, portfolio_image], :remote => true do |f|
|
||||
= f.text_field :title, :onchange => "$(this).closest('form').submit();", :onkeyup => "$(this).closest('form').submit();", :style => "display:inline-block !important;width:auto;font-family:courier;", :size => "n"
|
||||
-else
|
||||
=portfolio_image.title
|
||||
="-"
|
||||
=l portfolio_image.shoot_at, :format => :date if portfolio_image.shoot_at
|
||||
-if portfolio_image.exif
|
||||
.exifs
|
||||
=portfolio_image.exif.model
|
||||
="-"
|
||||
="f "+portfolio_image.exif.f_number.to_f.to_s
|
||||
="-"
|
||||
=portfolio_image.exif.exposure_time.to_s+" s"
|
||||
="-"
|
||||
=portfolio_image.exif.iso_speed_ratings.to_s+" iso"
|
||||
="-"
|
||||
© Nicolas Bally
|
||||
|
||||
-if current_admin
|
||||
.admin
|
||||
#portfolio_image_form{:id => portfolio_image.id}
|
||||
|
||||
= link_to i(:rotate, :gray_light, "12x14"), rotate_admin_portfolio_image_path(:id => portfolio_image.id, :manager => params[:manager], :multiple => params[:multiple]), :remote => true
|
||||
= link_to i(:rotate_right, :gray_light, "12x14"), rotate_admin_portfolio_image_path(:id => portfolio_image.id, :manager => params[:manager], :multiple => params[:multiple], :direction => :right), :remote => true
|
||||
=link_to "modifier", edit_admin_portfolio_image_path(portfolio_image), :remote => true
|
||||
=link_to "supprimer", [:admin, portfolio_image], :method => :delete, :confirm => "Voulez-vous vraiment supprimer cette image ?", :remote => true
|
||||
|
||||
%br
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
.portfolio
|
||||
#intro{:style => "padding:10px;margin:1em auto;"}
|
||||
%h1=@portfolio.title
|
||||
=markdown @portfolio.markdown_content
|
||||
|
||||
#style_2_portfolio_images{:style => "margin:0 auto;"}
|
||||
|
||||
|
||||
|
||||
-@portfolio.images.each do |img|
|
||||
-if img.photo?
|
||||
|
||||
|
||||
.box=image_tag img.photo.thumb.url+"?"+img.updated_at.to_s, :class => "image", :style => "width:"+(img.ratio > 1 ? "200" : "200")+"px;padding:5px;"
|
||||
|
@ -1,34 +0,0 @@
|
||||
.portfolio
|
||||
-if 1==2
|
||||
.intro
|
||||
%h1=@portfolio.title
|
||||
=markdown @portfolio.markdown_content
|
||||
|
||||
.portfolio_images
|
||||
|
||||
-if current_admin
|
||||
|
||||
|
||||
%form.fileupload{:action => admin_portfolio_images_path(:portfolio_id => @portfolio.id), :enctype => "multipart/form-data", :method => "POST"}
|
||||
|
||||
.upload
|
||||
.progress
|
||||
.bar{:style => "height:1em;"}
|
||||
|
||||
%button.add_files ajouter des photos
|
||||
|
||||
%input{:multiple => "", :name => "portfolio_image[photo]", :type => "file", :style => "float:right;"}
|
||||
|
||||
|
||||
%br
|
||||
|
||||
%br
|
||||
= hidden_field_tag "portfolio_image[portfolio_ids][]", @portfolio.id
|
||||
|
||||
|
||||
|
||||
:javascript
|
||||
init_portfolio_images();
|
||||
|
||||
%br
|
||||
.images=render :collection => @images, :partial => "portfolios/portfolio_image"
|
2
app/views/portfolios/create.js.erb
Normal file
2
app/views/portfolios/create.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('.portfolios_links').html("<%= escape_javascript(render(Portfolio.order(:title)))%>");
|
||||
$('#admin_over').html("");
|
1
app/views/portfolios/destroy.js.erb
Normal file
1
app/views/portfolios/destroy.js.erb
Normal file
@ -0,0 +1 @@
|
||||
$('#portfolio_line_<%=@portfolio.id%>').remove();
|
2
app/views/portfolios/edit.js.erb
Normal file
2
app/views/portfolios/edit.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
$('#admin_over').html("<%= escape_javascript(render(:partial => 'form'))%>");
|
3
app/views/portfolios/new.js.erb
Normal file
3
app/views/portfolios/new.js.erb
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
$('#admin_over').html("<%= escape_javascript(render(:partial => 'form'))%>");
|
||||
init_markdown();
|
@ -1,4 +1,40 @@
|
||||
#small_index
|
||||
-@portfolio.images.each do |img|
|
||||
=link_to image_tag(img.photo.thumb.url, :style => "height:100px;float:left;padding:5px;"), portfolio_path(:slug => @portfolio.slug, :format => "js", :page => (@portfolio.images.after(img.shoot_at).count+1)), :onclick => '$("#small_index").toggleClass("active");' ,:remote => true
|
||||
#image_place=render :partial => "style_2"
|
||||
|
||||
|
||||
.portfolio
|
||||
-if 1==2
|
||||
.intro
|
||||
%h1=@portfolio.title
|
||||
=markdown @portfolio.markdown_content
|
||||
|
||||
.portfolio_images
|
||||
|
||||
-if current_admin
|
||||
|
||||
|
||||
%form.fileupload{:action => admin_portfolio_images_path(:portfolio_id => @portfolio.id), :enctype => "multipart/form-data", :method => "POST"}
|
||||
|
||||
.upload
|
||||
.progress
|
||||
.bar{:style => "height:1em;"}
|
||||
|
||||
%button.add_files ajouter des photos
|
||||
|
||||
%input{:multiple => "", :name => "portfolio_image[photo]", :type => "file", :style => "float:right;"}
|
||||
|
||||
|
||||
%br
|
||||
|
||||
%br
|
||||
= hidden_field_tag "portfolio_image[portfolio_ids][]", @portfolio.id
|
||||
|
||||
|
||||
|
||||
:javascript
|
||||
init_portfolio_images();
|
||||
|
||||
%br
|
||||
.images=render :collection => @images, :partial => "portfolio_images/portfolio_image", :as => :image
|
||||
|
@ -1,6 +1,12 @@
|
||||
$("#image_place").fadeOut(300,function(){
|
||||
$("#image_place").html("<%= escape_javascript(render(:partial => 'style_2')) %>");
|
||||
$("#image_place").fadeIn(300);
|
||||
|
||||
$(".images").fadeOut(300,function(){
|
||||
|
||||
$(".images").html("<%= escape_javascript(render(:collection => @images, :partial => "portfolio_images/portfolio_image", :as => :image)) %>");
|
||||
|
||||
$(".images").fadeIn(300, function(){
|
||||
$("html, body").animate({ scrollTop: 0 }, 1);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
2
app/views/portfolios/update.js.erb
Normal file
2
app/views/portfolios/update.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('.portfolios_links').html("<%= escape_javascript(render(Portfolio.order(:title)))%>");
|
||||
$('#admin_over').html("");
|
@ -1,8 +1,12 @@
|
||||
SitePerso::Application.routes.draw do
|
||||
|
||||
match "portfolios/:slug.:format" => 'portfolios#show', :as => :portfolio, :format => "html"
|
||||
|
||||
|
||||
|
||||
match ":slug.:format" => 'pages#show', :as => :page, :format => "html"
|
||||
resources :portfolios
|
||||
|
||||
#match "galerie/:slug.:format" => 'portfolios#show', :as => :portfolio, :format => "html", :via => :get
|
||||
|
||||
namespace :admin do
|
||||
root :to => "dashboard#index"
|
||||
|
Loading…
x
Reference in New Issue
Block a user