From 83b9ba6e7e326d4f667c3baafc17887ac56dce7e Mon Sep 17 00:00:00 2001 From: Florent Solt Date: Wed, 27 Mar 2013 19:25:05 +0100 Subject: [PATCH 1/9] Allow api && add more lang --- app/controllers/pastes_controller.rb | 2 ++ app/helpers/pastes_helper.rb | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/pastes_controller.rb b/app/controllers/pastes_controller.rb index d3dab54..e36075f 100644 --- a/app/controllers/pastes_controller.rb +++ b/app/controllers/pastes_controller.rb @@ -27,6 +27,8 @@ class PastesController < ApplicationController accept_rss_auth :index + accept_api_auth :create + def index @limit = per_page_option diff --git a/app/helpers/pastes_helper.rb b/app/helpers/pastes_helper.rb index adca49e..8068501 100644 --- a/app/helpers/pastes_helper.rb +++ b/app/helpers/pastes_helper.rb @@ -20,7 +20,8 @@ module PastesHelper PASTEBIN_LANGS = ["Plain Text", "C", "C++", "Java", "JavaScript", - "Python", "Ruby", "PHP", "SQL", "XML", "Diff"] + "Python", "Ruby", "PHP", "SQL", "XML", "Diff", + "Clojure", "CSS", "HAML", "HTML", "JSON", "YAML"] # This maps pretty language/syntax name to identifier that CodeRay # can understand. If a language is not mapped, unchanged name is @@ -57,7 +58,7 @@ def pastebin_language_name(lang) end def pastebin_language_choices - PASTEBIN_LANGS.map { |v| [v, pastebin_lang_to_scanner(v)] } + PASTEBIN_LANGS.sort.map { |v| [v, pastebin_lang_to_scanner(v)] } end def pastebin_expiration_choices From 78761217d4f5b476278af4953e81d55b08f2dd19 Mon Sep 17 00:00:00 2001 From: Florent Solt Date: Wed, 27 Mar 2013 19:33:41 +0100 Subject: [PATCH 2/9] Beter index listing --- app/views/pastes/index.html.erb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/views/pastes/index.html.erb b/app/views/pastes/index.html.erb index b511890..eb9c287 100644 --- a/app/views/pastes/index.html.erb +++ b/app/views/pastes/index.html.erb @@ -6,6 +6,12 @@ .paste { margin-bottom: 1.5em; } +.paste .author, .paste .actions { + float: right; +} +.paste .box { + margin-bottom: 2px; +} <% end %> @@ -20,12 +26,16 @@ <% unless @project %> <%= link_to_project paste.project %> – <% end %> - <%= pastebin_language_name(paste.lang) %>
+
+ <%= render :partial => "authorship", :locals => { :paste => paste } %> +
+ <%= pastebin_language_name(paste.lang) %>
<%=h paste.short_text %>
- <%= render :partial => "authorship", :locals => { :paste => paste } %>
- <%= manage_paste_links(paste) %> +
+ <%= manage_paste_links(paste) %> +
<% end %> From bb2f49392027e541bc18168dd9d6944aa8d321e6 Mon Sep 17 00:00:00 2001 From: Florent Solt Date: Wed, 27 Mar 2013 19:35:59 +0100 Subject: [PATCH 3/9] Beter index listing --- app/views/pastes/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/pastes/index.html.erb b/app/views/pastes/index.html.erb index eb9c287..9b7ff5c 100644 --- a/app/views/pastes/index.html.erb +++ b/app/views/pastes/index.html.erb @@ -4,7 +4,7 @@ <% content_for :header_tags do %> <% end %> -<% html_title @paste.title %> +<% cache("paste-#{@paste.id}-#{User.current.language}", skip_digest: true) do %> + <% html_title @paste.title %> -

<%=h @paste.title %>

+

<%=h @paste.title %>

-

-<%= l(:label_paste_link_here, :link => link_to(paste_url(@paste), @paste)).html_safe %> -

+

+ <%= l(:label_paste_link_here, :link => link_to(paste_url(@paste), @paste)).html_safe %> +

-

-<%= render :partial => "authorship", :locals => { :paste => @paste } %>
-<%=l :label_paste_syntax, :lang => pastebin_language_name(@paste.lang) %> -

+

+ <%= render :partial => "authorship", :locals => { :paste => @paste } %>
+ <%=l :label_paste_syntax, :lang => pastebin_language_name(@paste.lang) %> +

-
-<%= highlighted_content_for_paste(@paste) %> -
- -

-<%= manage_paste_links(@paste) %> -

+
+ <%= highlighted_content_for_paste(@paste) %> +
+

+ <%= manage_paste_links(@paste) %> +

+<% end %> <%= render "sidebar" if @project %> From 2505ccd6ef10ca03eb89d83be210d69380c615f0 Mon Sep 17 00:00:00 2001 From: Sys Date: Mon, 8 Jun 2015 16:31:40 +0200 Subject: [PATCH 8/9] Fix for Redmine3 --- app/models/paste.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/paste.rb b/app/models/paste.rb index 433c8f2..b108212 100644 --- a/app/models/paste.rb +++ b/app/models/paste.rb @@ -50,7 +50,7 @@ class Paste < ActiveRecord::Base scope :visible, lambda{ |user=nil, options={}| user ||= User.current - s = where(Project.allowed_to_condition(user, :view_pastes, options)).includes(:project) + s = Paste.where(Project.allowed_to_condition(user, :view_pastes, options)).joins(:project) unless user.admin? s = s.where(["access_token IS NULL OR author_id = ?", user.id]) end @@ -83,7 +83,7 @@ def self.visible_to(user, options={}) :id => o.to_param } } acts_as_activity_provider :scope => preload(:project, :author), - :author_key => :author_id + :author_key => :author_id def title t = super From 6a12cf7e9a18dd3ccb08a3f304bc634cc9554c8f Mon Sep 17 00:00:00 2001 From: Sys Date: Wed, 28 Oct 2015 15:13:24 +0100 Subject: [PATCH 9/9] Fix when bad text --- app/models/paste.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/paste.rb b/app/models/paste.rb index b108212..f174db1 100644 --- a/app/models/paste.rb +++ b/app/models/paste.rb @@ -103,6 +103,7 @@ def description SHORT_TEXT_LIMIT = 100 def short_text + return "" if not text if text.length < SHORT_TEXT_LIMIT text else