diff --git a/.gitignore b/.gitignore index 11d2dcc..c78ff3f 100755 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ console *# Gemfile.lock /config/database.yml +/config/start_topic.yml diff --git a/Gemfile b/Gemfile index a83dee3..4d026e7 100755 --- a/Gemfile +++ b/Gemfile @@ -91,7 +91,7 @@ gem "simple_calendar", "~> 0.1.9" gem 'rmagick' gem 'bootstrap-addons-rails' -gem "jquery-fileupload-rails" +gem "jquery-fileupload-rails", "0.4.1" gem "jquery-ui-rails","~> 4.1.1" gem "font-awesome-rails" gem "jquery-datetimepicker-rails" @@ -115,4 +115,8 @@ gem 'sunspot_solr' gem 'sitemap_generator' gem 'whenever' gem 'yaml_db' -gem 'etherpad-lite' \ No newline at end of file +gem 'etherpad-lite' + +# Image gallery +gem 'blueimp-gallery' +gem 'blueimp-gallery-rails' \ No newline at end of file diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e2b42f1..7dbcce6 100755 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -23,12 +23,11 @@ //= require bootstrap //= require bootstrap/colorpicker //= require bootstrap/datepicker -//= require bootstrap/load-image.min -//= require bootstrap/image-gallery.min //= require jquery-fileupload // require jquery.remotipart //= require jquery.datetimepicker + function insertAttachment(url,name) { var ext = url.split('.').pop().toLowerCase(); var img_ext = [ "jpg", "png", "bmp" , "jpeg" ]; diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 65e39bf..34fa42c 100755 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -1,22 +1,21 @@ /* - * 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_tree . - *= require 'calendars' - *= require jquery.fileupload-ui - * require 'bootstrap' - *= require 'tinymce' - - */ +* 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_tree . +*= require 'calendars' +*= require jquery.fileupload-ui +* require 'bootstrap' +*= require 'tinymce' + +*/ // Colorshema #0A64A4 $color_prim: #0A64A4; $color_prim_light: #0B65A5; @@ -45,34 +44,34 @@ $sansFontFamily: Helvetica, Arial; @import 'font-awesome'; h1 { - font-size: 23px +font-size: 23px } h2 { - font-size: 19px +font-size: 19px } body,html { - padding:0; - margin:0; +padding:0; +margin:0; } a:hover { - text-decoration:none; +text-decoration:none; } div.header { - display: block; - // background: url('/header1.png') no-repeat; - background-color: #FFF; - background-position: right; - border-bottom:1px solid black; - height:41px; - color:#000; - padding-left:87px; - padding-top:0px; - overflow:hidden; - margin-bottom: 20px +display: block; +// background: url('/header1.png') no-repeat; +background-color: #FFF; +background-position: right; +border-bottom:1px solid black; +height:41px; +color:#000; +padding-left:87px; +padding-top:0px; +overflow:hidden; +margin-bottom: 20px } div.header h1 { padding:0; @@ -81,40 +80,40 @@ font-size:20px; line-height:32px; } #menudiv { - width:100%; +width:100%; } - + .navbar .nav li { - min-width:100%; +min-width:100%; } .navbar .nav .divider { - border-style: solid; - border-width: 1px 0px 0px 0px; - border-color: grey; - min-width: 100%; +border-style: solid; +border-width: 1px 0px 0px 0px; +border-color: grey; +min-width: 100%; } .navbar .navbar-inner { - border:none; - box-shadow:none; +border:none; +box-shadow:none; } #contentdiv { - background: #FFFFFF +background: #FFFFFF } #contentdiv .container-fluid { - padding:0; +padding:0; } a.linkbox, div.contentbox { - display:block; - padding:5px; - border-radius: 10px; - border: lightgray solid 1px; +display:block; +padding:5px; +border-radius: 10px; +border: lightgray solid 1px; } @@ -132,16 +131,18 @@ margin-bottom:10px; } ul.linkbox-list { - max-width:70em; +max-width:70em; } div.contentbox { - margin: 5px; +margin: 5px; } .navbar .nav li { min-width:100%; background:44F; -} \ No newline at end of file +} + +@import 'galleries'; \ No newline at end of file diff --git a/app/assets/stylesheets/galleries.css.scss b/app/assets/stylesheets/galleries.css.scss index 27e63bf..0689e8e 100644 --- a/app/assets/stylesheets/galleries.css.scss +++ b/app/assets/stylesheets/galleries.css.scss @@ -2,39 +2,6 @@ // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ -//.modal.fade { -// top: -25%; -// transition: opacity 0.3s linear 0s, top 0.3s ease-out 0s; -//} -//.modal-gallery { -// max-height: none; -// outline: medium none; -// width: auto; -//} -//.modal { -// color: #333333; -//} -//.hide { -// display: none; -//} -//.modal { -//background-clip: padding-box; -// background-color: #FFFFFF; -// border: 1px solid rgba(0, 0, 0, 0.3); -//border-radius: 6px 6px 6px 6px; -// box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); -// left: 50%; -// margin-left: -280px; -// outline: medium none; -// position: fixed; -// top: 10%;; -// z-index: 1050; -//} -//.fade { -// opacity: 0; -// transition: opacity 0.15s linear 0s; -//} - div.gallery-block { padding: 10px; diff --git a/app/assets/stylesheets/layout.css.scss b/app/assets/stylesheets/layout.css.scss index 8cf1d2f..6c63179 100755 --- a/app/assets/stylesheets/layout.css.scss +++ b/app/assets/stylesheets/layout.css.scss @@ -1,3 +1,13 @@ + +@import 'blueimp-gallery-all'; +.left +{ + float: left; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + /* etc. */ +} h1 { font-size: 23px } diff --git a/app/assets/stylesheets/themes/blue1/application.css.scss b/app/assets/stylesheets/themes/blue1/application.css.scss index 53484fe..d30ce83 100755 --- a/app/assets/stylesheets/themes/blue1/application.css.scss +++ b/app/assets/stylesheets/themes/blue1/application.css.scss @@ -11,11 +11,11 @@ * *= require_self * require_tree . + *= require blueimp-gallery-all *= require jquery.fileupload-ui *= require jquery.datetimepicker *= require jquery.ui.dialog * require 'bootstrap' - * require 'neuigkeiten' */ diff --git a/app/controllers/fotos_controller.rb b/app/controllers/fotos_controller.rb index 5d762b3..b97f105 100644 --- a/app/controllers/fotos_controller.rb +++ b/app/controllers/fotos_controller.rb @@ -87,10 +87,11 @@ class FotosController < ApplicationController # DELETE /fotos/1.json def destroy @foto = Foto.find(params[:id]) + gallery = @foto.gallery_id @foto.destroy respond_to do |format| - format.html { redirect_to galleries_url } + format.html { redirect_to gallery_path(gallery) } format.json { head :no_content } end end diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 7745872..978f200 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -18,23 +18,42 @@ class GalleriesController < ApplicationController # GET /galleries/1.json def show @gallery = Gallery.find(params[:id]) - - @pppage_array = [ 25 , 50 , 100 ] #defines number & size of picture chunks + + @pppage_array = [ 25 , 50 , 100, "all"] #defines number & size of picture chunks @pppage = 0 #starting index of pppage_array - - if params[:pppage].to_i <= 2 && params[:pppage].to_i >= 0 + + if !params[:pppage].nil? && params[:pppage].to_i <= 3 && params[:pppage].to_i >= 0 @pppage = params[:pppage].to_i end - + @page = params[:page].nil? ? 1 : params[:page].to_i - # @fotos = Foto.where(:gallery_id => params[:id]).limit(@pppage_array[@pppage]).offset(@pppage_array[@pppage]*(@page-1)) + # @fotos = Foto.where(:gallery_id => params[:id]).limit(@pppage_array[@pppage]).offset(@pppage_array[@pppage]*(@page-1)) @fotos = Foto.where(:gallery_id => params[:id]) - @pages = (Foto.where(:gallery_id => params[:id]).count/(@pppage_array[@pppage])+1) -@showind=[] - @showind.fill(0,@pppage_array[@pppage]){ |i| i+ @pppage_array[@pppage]*(@page-1)} # Hier ausrechnen welche angezeigt werden sollen + if @fotos.nil? || @fotos.empty? + @fotos_p = [] + @fotos_n = [] + @pages = 1 + + else + if @pppage_array[@pppage] != "all" + @fotos_p = @fotos.page(@page).per(@pppage_array[@pppage]) + + @fotos_n = @fotos- @fotos_p + @foto_ind = @fotos.find_index(@fotos_p.first) + @fotos_n = @fotos_n.rotate(@foto_ind) + @pages = (Foto.where(:gallery_id => params[:id]).count/(@pppage_array[@pppage])+1) + else + @fotos_p = @fotos + @fotos_n = [] + @pages = 1 + end + end + + # Hier ausrechnen welche angezeigt werden sollen @toolbar_elements << {:hicon=>'icon-plus', :text=> I18n.t('fotos.new-fotos'), :path=>new_gallery_foto_path(@gallery)} @toolbar_elements << {:hicon=>'icon-pencil', :text => I18n.t('common.edit'), :path=>edit_gallery_path(@gallery)} @toolbar_elements << {:hicon=>'icon-arrow-left', :text=>I18n.t('common.back'), :path=>galleries_path()} + @toolbar_elements << {:hicon => 'icon-remove-circle', :text => I18n.t('common.delete'), :path => gallery_path(@gallery),:confirm=>'Sure?', :method=>:delete} if can? :delete, Gallery respond_to do |format| format.html # show.html.erb @@ -56,6 +75,7 @@ class GalleriesController < ApplicationController # GET /galleries/1/edit def edit @gallery = Gallery.find(params[:id]) + @fotos_old = @gallery.fotos end # POST /galleries @@ -81,6 +101,10 @@ class GalleriesController < ApplicationController @foto = Foto.new respond_to do |format| if @gallery.update_attributes(params[:gallery]) + + Foto.where(:gallery_id=>nil).each do |tbd| + tbd.destroy + end format.html { redirect_to @gallery, notice: 'Gallery was successfully updated.' } format.json { head :no_content } else diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 2c015f6..0410a28 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -2,8 +2,12 @@ class HomeController < ApplicationController def index @beispiele = Beispiel.last([Beispiel.count, 3].min) @neuigkeiten = Neuigkeit.recent + if Thema.count>0 t=YAML.load_file("#{::Rails.root.to_s}/config/start_topic.yml") @starttopic= @themen = Thema.where(:id=>t).first + else + @starttopic=@themen = nil + end end def dev diff --git a/app/controllers/neuigkeiten_controller.rb b/app/controllers/neuigkeiten_controller.rb index 02da1fb..05af5d3 100755 --- a/app/controllers/neuigkeiten_controller.rb +++ b/app/controllers/neuigkeiten_controller.rb @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- class NeuigkeitenController < ApplicationController + before_filter :load_toolbar_elements, :only=>[:show,:find_link] before_filter :load_toolbar_elements_edit, :only=>[:edit] diff --git a/app/models/gallery.rb b/app/models/gallery.rb index 7c2079e..2dcbadc 100644 --- a/app/models/gallery.rb +++ b/app/models/gallery.rb @@ -12,8 +12,8 @@ class Gallery < ActiveRecord::Base WORD_COUNT = 20 - attr_accessible :datum, :desc, :name - has_many :fotos + attr_accessible :datum, :desc, :name, :foto_ids + has_many :fotos, :dependent => :destroy # Delete fotos if gallery is destroyed has_many :nlinks, as: :link # scope :search, ->(query) {where("name like ? or galleries.desc like ?", "%#{query}%", "%#{query}%")} searchable do diff --git a/app/views/galleries/_form.html.erb b/app/views/galleries/_form.html.erb index 6322dc2..1e8d6e5 100644 --- a/app/views/galleries/_form.html.erb +++ b/app/views/galleries/_form.html.erb @@ -1,11 +1,20 @@ -<%= semantic_form_for @gallery do |f| %> - <%= f.inputs do %> - <%= f.input :name %> - <%= f.input :desc %> - <%= f.input :datum %> - <% end %> +