diff --git a/app/controllers/neuigkeiten_controller.rb b/app/controllers/neuigkeiten_controller.rb index 3e05c2c..29a54b9 100755 --- a/app/controllers/neuigkeiten_controller.rb +++ b/app/controllers/neuigkeiten_controller.rb @@ -113,9 +113,14 @@ class NeuigkeitenController < ApplicationController render action:"show" end def create_link - Nlink.create(:link=>params[:link_type].constantize.find(params[:link_id]),:neuigkeit=>Neuigkeit.find(params[:id])) + @neuigkeit = Neuigkeit.find(params[:id]) - redirect_to action:"show" + Nlink.create(:link=>params[:link_type].constantize.find(params[:link_id]),:neuigkeit=>Neuigkeit.find(params[:id])) + @nlinks=@neuigkeit.nlinks + respond_to do |format| + format.html { edirect_to action:"show" } + format.js + end end def create @@ -159,21 +164,23 @@ private def load_toolbar_elements @neuigkeit=Neuigkeit.find(params[:id]) @toolbar_elements=[] - @toolbar_elements << {:hicon=>'icon-plus', :text=> I18n.t('neuigkeit.publish'),:path => publish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=> I18n.t('neuigkeit.publish_sure') } if can?(:publish, @neuigkeit) && !@neuigkeit.published? - @toolbar_elements << {:hicon=>'icon-facebook', :text=> I18n.t('neuigkeit.publishfb'),:path => publish_to_facebook_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>I18n.t('neuigkeit.publishfb_sure') } if can?(:publish, @neuigkeit) && @neuigkeit.published? + actions=[] + actions << {:hicon=>'icon-plus', :text=> I18n.t('neuigkeit.publish'),:path => publish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=> I18n.t('neuigkeit.publish_sure') } if can?(:publish, @neuigkeit) && !@neuigkeit.published? + actions << {:hicon=>'ffi1-facebook1', :text=> I18n.t('neuigkeit.publishfb'),:path => publish_to_facebook_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>I18n.t('neuigkeit.publishfb_sure') } if can?(:publish, @neuigkeit) && @neuigkeit.published? -@toolbar_elements << {:hicon=>'icon-facebook', :text=> I18n.t('neuigkeit.publishfetmail'),:path => mail_to_fet_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>I18n.t('neuigkeit.publishfetmail_sure') } if can?(:publish, @neuigkeit) && @neuigkeit.published? +actions << {:hicon=>'icon-facebook', :text=> I18n.t('neuigkeit.publishfetmail'),:path => mail_to_fet_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>I18n.t('neuigkeit.publishfetmail_sure') } if can?(:publish, @neuigkeit) && @neuigkeit.published? - @toolbar_elements << {:hicon=>'icon-minus', :text=> I18n.t('neuigkeit.unpublish'),:path => unpublish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=> I18n.t('neuigkeit.unpublish_sure') } if can?(:unpublish, @neuigkeit) && @neuigkeit.published? + actions << {:hicon=>'icon-minus', :text=> I18n.t('neuigkeit.unpublish'),:path => unpublish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=> I18n.t('neuigkeit.unpublish_sure') } if can?(:unpublish, @neuigkeit) && @neuigkeit.published? + @toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:icon=>:pencil} if can? :edit, @neuigkeit.rubrik @versions= @neuigkeit.translation.versions.select([:created_at]).reverse @toolbar_elements <<{:path=>rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:method=>:versions,:versions=>@versions} - @toolbar_elements << {:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit), :method=> :delete,:confirm=>'Sure?' } if can? :delete, @neuigkeit - + actions << {:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit), :method=> :delete,:confirm=>'Sure?' } if can? :delete, @neuigkeit + @toolbar_elements << {:text => "action", :method => :dropdown, :elements=> actions} end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index c61214f..3301381 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -18,6 +18,13 @@ class Attachment < ActiveRecord::Base validates :thema, :presence => true validates :name, :presence => true + def image? + + # data_ext = datei.file.extension.downcase + # %w(jpg png jpeg).include?(data_ext) + datei.image?(datei.file) + end + def to_jq_upload { "id" => read_attribute(:id), diff --git a/app/models/thema.rb b/app/models/thema.rb index 3f73b38..d61bf46 100644 --- a/app/models/thema.rb +++ b/app/models/thema.rb @@ -49,7 +49,9 @@ include Rails.application.routes.url_helpers def fix_links(host) full_url= URI.parse(root_url(:host=>host)) - self.text.gsub!(/src="[^"]*attachment\/datei\/(\d+)[^"]*"/){|s| full_url.path=Attachment.find($1.to_i).datei.url; 'src="'+full_url.to_s+'"'} + self.text.gsub!(/src="[\.\/]*uploads\/attachment\/datei\/(\d+)\/thumb_big[^"]*"/){|s| full_url.path=Attachment.find($1.to_i).datei.thumb_big.url; 'src="'+full_url.to_s+'"'} + self.text.gsub!(/src="[\.\/^"]*uploads\/attachment\/datei\/(\d+)\/[^"]*"/){|s| full_url.path=Attachment.find($1.to_i).datei.url; 'src="'+full_url.to_s+'"'} + self.text.gsub!(/href="[^"]*themen\/(\d+)[^"]*"/){|s| full_url.path=thema_path(Thema.find($1.to_i)); 'href="'+full_url.to_s+'"'} end diff --git a/app/uploaders/attachment_uploader.rb b/app/uploaders/attachment_uploader.rb index c7d10a4..d08f8cd 100644 --- a/app/uploaders/attachment_uploader.rb +++ b/app/uploaders/attachment_uploader.rb @@ -89,8 +89,11 @@ end # def filename # "something.jpg" if original_filename # end -protected - def image?(file) - %w(jpg png jpeg).include?(File.extname(full_filename(file))) + def extention + File.extname(full_filename(file.file)).downcase + end + + def image?(for_file) + %w(.jpg .png .jpeg).include?(File.extname(full_filename(for_file.file)).downcase) end end diff --git a/app/views/layouts/_pretty_toolbar.html.erb b/app/views/layouts/_pretty_toolbar.html.erb index 096cac6..8405a4c 100644 --- a/app/views/layouts/_pretty_toolbar.html.erb +++ b/app/views/layouts/_pretty_toolbar.html.erb @@ -10,8 +10,26 @@ Verwendung: Aufruf mit -->