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/ability.rb b/app/models/ability.rb index 616979b..99fe04a 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -40,6 +40,7 @@ class Ability can :showintern, Thema can :manage, Thema can :manage, Themengruppe + can :manage, Attachment end unless user.has_role?("fetadmin") cannot :delete, Themengruppe 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 -->
<% toolbar_elements.each do |t| %> <% unless t[:method]==:versions %> - <% text=''.html_safe+t[:text] %> + <% unless t[:method]==:dropdown %> + + <% text=ff_icon(t[:hicon])+t[:text] %> <%= link_to text, t[:path], :method=>t[:method], :confirm=>t[:confirm].to_s, :data=>t[:data], :class=>((t[:method].to_s=='delete') ? "btn btn-danger" : "btn") ,:remote=>(t[:remote])?true : false %> + <% else %> +
+ + <%= t[:text] %> + + +<% end %> <% else %>
@@ -28,9 +46,9 @@ Verwendung: Aufruf mit q= q.merge(URI.decode_www_form(uri.query)) unless uri.query.nil? uri.query= URI.encode_www_form(q<<["version",i.to_s]) - %> + %> <%= link_to I18n.l(v[:created_at]).to_s,uri.to_s ,:version=>v[:id] %> -<% end %> + <% end %> <% end %> diff --git a/app/views/neuigkeiten/_nlink_list_search.html.erb b/app/views/neuigkeiten/_nlink_list_search.html.erb index be5a2c9..c50ead3 100644 --- a/app/views/neuigkeiten/_nlink_list_search.html.erb +++ b/app/views/neuigkeiten/_nlink_list_search.html.erb @@ -1,11 +1,12 @@
  • <%= link_to nlink_list_search.title, nlink_list_search %> - <%= link_to "add:"+nlink_list_search.title, create_link_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit, :link_id=>nlink_list_search.id, :link_type=>nlink_list_search.class.to_s) %> + <%= link_to create_link_rubrik_neuigkeit_path(@neuigkeit.rubrik, @neuigkeit, :link_id=>nlink_list_search.id, :link_type=>nlink_list_search.class.to_s), remote: true do %>
    <% p = nlink_list_search.class.to_s.downcase.pluralize+"/nlink" %> <%= render :partial=>p, :object=>nlink_list_search %>
    +<% end %>
  • diff --git a/app/views/neuigkeiten/create_link.js.erb b/app/views/neuigkeiten/create_link.js.erb new file mode 100644 index 0000000..d24f9fc --- /dev/null +++ b/app/views/neuigkeiten/create_link.js.erb @@ -0,0 +1,2 @@ +$('#nlink_list_search').html(""); +$('#nlink_list').html("<%= escape_javascript( render partial:"nlink_list", collection: @nlinks )%>"); \ No newline at end of file diff --git a/app/views/themen/_attachment_list.html.erb b/app/views/themen/_attachment_list.html.erb index a210446..818aa05 100644 --- a/app/views/themen/_attachment_list.html.erb +++ b/app/views/themen/_attachment_list.html.erb @@ -8,9 +8,15 @@ <% if editor %> -<%= link_to "Edit", edit_thema_attachment_path(a.thema,a) %> -<%= link_to "Delete", thema_attachment_path(a.thema,a), method: "DELETE", confirm: "Sure?" %> - +
    <% end %> diff --git a/app/views/themen/_select.html.erb b/app/views/themen/_select.html.erb index a693ec0..02401a7 100644 --- a/app/views/themen/_select.html.erb +++ b/app/views/themen/_select.html.erb @@ -2,19 +2,33 @@ <% select.attachments.each_slice(6) do |row| %>
    <% row.each do |attachment| - data_ext = attachment.datei.file.extension.downcase %> +%>
    - <%= link_to attachment.name, edit_thema_attachment_path(@thema,attachment) %>
    - <% if (!["jpg","png","jpeg"].find_index(data_ext).nil?) %> +
    <% end %>
    diff --git a/app/views/themen/_verw_liste.html.erb b/app/views/themen/_verw_liste.html.erb index 777a730..0c6f554 100644 --- a/app/views/themen/_verw_liste.html.erb +++ b/app/views/themen/_verw_liste.html.erb @@ -1,8 +1,13 @@ <% verw_liste.each do |thema| %> -
  • <%= thema.title %>
    - -<%= link_to thema_path(thema),:remote=>true do %> Show <% end %> -<%= link_to edit_thema_path(thema),:remote=>true do %> Edit <% end %> -<%= link_to fragen_thema_path(thema),:remote=>true do %> Fragen <% end %> -<%= link_to attachments_thema_path(thema),:remote=>true do %> Attachments <% end %>
  • +
  • +
  • <% end %> diff --git a/app/views/themengruppen/_themengruppe.html.erb b/app/views/themengruppen/_themengruppe.html.erb index 7e99e23..73c5c4f 100644 --- a/app/views/themengruppen/_themengruppe.html.erb +++ b/app/views/themengruppen/_themengruppe.html.erb @@ -1,4 +1,5 @@ <%= link_to themengruppe,{:class=>'linkbox color-1-dark'} do %> +
    @@ -45,5 +46,5 @@
    - +
    <% end %> diff --git a/app/views/themengruppen/index.html.erb b/app/views/themengruppen/index.html.erb index 9e5acf4..f2cc8a9 100644 --- a/app/views/themengruppen/index.html.erb +++ b/app/views/themengruppen/index.html.erb @@ -2,21 +2,21 @@ <%= render :partial=>'layouts/pretty_toolbar' %> -

    - +

    + + +