aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2011-08-18 14:31:13 +0200
committerAlex Legler <alex@a3li.li>2011-08-18 14:31:13 +0200
commit824780cc0795fe6e0da66a3978580f806331f3eb (patch)
treedf9dcefeb920c5dc2c7aaff32de30929e6f24792
parentMigrate glsa/show views to rails-3 (diff)
downloadglsamaker-824780cc0795fe6e0da66a3978580f806331f3eb.tar.gz
glsamaker-824780cc0795fe6e0da66a3978580f806331f3eb.tar.bz2
glsamaker-824780cc0795fe6e0da66a3978580f806331f3eb.zip
Fix glsa/diff action
-rw-r--r--app/controllers/application_controller.rb1
-rw-r--r--app/controllers/glsa_controller.rb16
-rw-r--r--app/helpers/application_helper.rb10
-rw-r--r--app/views/glsa/diff.html.erb6
4 files changed, 22 insertions, 11 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 3b8b8ab..98f7de2 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -20,6 +20,7 @@ class ApplicationController < ActionController::Base
# filter_parameter_logging :password
include Authentication
+ include ApplicationHelper
protected
def deny_access(msg)
diff --git a/app/controllers/glsa_controller.rb b/app/controllers/glsa_controller.rb
index f0f2f50..22d03db 100644
--- a/app/controllers/glsa_controller.rb
+++ b/app/controllers/glsa_controller.rb
@@ -1,5 +1,5 @@
# ===GLSAMaker v2
-# Copyright (C) 2010 Alex Legler <a3li@gentoo.org>
+# Copyright (C) 2010-11 Alex Legler <a3li@gentoo.org>
# Copyright (C) 2009 Pierre-Yves Rofes <py@gentoo.org>
#
# This program is free software: you can redistribute it and/or modify
@@ -17,19 +17,19 @@ class GlsaController < ApplicationController
def requests
@pageID = "requests"
@pageTitle = "Pooled GLSA requests"
- @glsas = Glsa.find(:all, :conditions => "status = 'request'", :order => "updated_at DESC")
+ @glsas = Glsa.where(:status => 'request').order('updated_at DESC')
end
def drafts
@pageID = "drafts"
- @pageTitle = "Pooled GLSA drafts"
- @glsas = Glsa.find(:all, :conditions => "status = 'draft'", :order => "updated_at DESC")
+ @pageTitle = "Pooled GLSA drafts"
+ @glsas = Glsa.where(:status => 'draft').order('updated_at DESC')
end
def archive
@pageID = "archive"
@pageTitle = "GLSA archive"
- @glsas = Glsa.find(:all, :conditions => "status = 'release'", :order => "updated_at DESC")
+ @glsas = Glsa.where(:status => 'release').order('updated_at DESC')
end
def new
@@ -307,7 +307,7 @@ class GlsaController < ApplicationController
rev_old = @glsa.revisions.find_by_revid(params[:old])
rev_new = @glsa.revisions.find_by_revid(params[:new])
- @diff = rev_diff(@glsa, rev_old, rev_new)
+ @diff = with_format(:xml) { rev_diff(@glsa, rev_old, rev_new) }
end
def addbug
@@ -461,7 +461,7 @@ class GlsaController < ApplicationController
end
end
- return true
+ true
end
def rev_diff(glsa, rev_old, rev_new, format = :unified, context_lines = 3)
@@ -485,7 +485,7 @@ class GlsaController < ApplicationController
),
{:indent => 2, :maxcols => 80}
)
-
+
Glsamaker::Diff.diff(old_text, new_text, format, context_lines)
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index dafeb14..778d8f6 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -135,4 +135,14 @@ module ApplicationHelper
content_tag("h2", content, :class => "boxtitle")
end
+
+ def with_format(format, &block)
+ old_formats = formats
+ begin
+ self.formats = [format]
+ return block.call
+ ensure
+ self.formats = old_formats
+ end
+ end
end
diff --git a/app/views/glsa/diff.html.erb b/app/views/glsa/diff.html.erb
index 05a7cf9..4a54bd0 100644
--- a/app/views/glsa/diff.html.erb
+++ b/app/views/glsa/diff.html.erb
@@ -2,9 +2,9 @@
<div class="box buttons">
<span class="floatright">
- <%= link_to "#{image_tag 'icons/draft.png'} Back", {:controller => 'glsa', :action => 'show', :id => @glsa}, {:class => 'button'} %>
+ <%= link_to "#{image_tag 'icons/draft.png'} Back".html_safe, {:controller => 'glsa', :action => 'show', :id => @glsa}, {:class => 'button'} %>
</span>
- <% form_tag(:action => :diff, :id => @glsa.id) do %>
+ <%= form_tag(:action => :diff, :id => @glsa.id) do %>
<%= submit_tag 'Compare' %> revisions
<%= select_tag :old,
options_from_collection_for_select(@glsa.revisions, :revid, :revid) %> (old)
@@ -15,5 +15,5 @@
</div>
<pre>
-<%= h @diff %>
+<%= @diff %>
</pre> \ No newline at end of file