diff --git a/app/controllers/log_controller.rb b/app/controllers/log_controller.rb index 6d1130c..4fc04a6 100644 --- a/app/controllers/log_controller.rb +++ b/app/controllers/log_controller.rb @@ -19,7 +19,12 @@ class LogController < ApplicationController before_filter :find_course def index - @log_entries = @course.log_entries.find(:all, :limit => 50) #.paginate(:page => params[:page], :per_page => 30) + if @course + @log_entries = @course.log_entries.find(:all, :limit => 50) #.paginate(:page => params[:page], :per_page => 30) + else + @log_entries = LogEntry.find(:all, :limit => 50) + end + respond_to do |format| format.html format.rss { response.content_type = Mime::RSS } @@ -38,7 +43,9 @@ class LogController < ApplicationController protected def find_course - params[:course_id] = Course.find_by_short_name(params[:course_id]).id if !params[:course_id].is_numeric? and !Course.find_by_short_name(params[:course_id]).nil? - @course = Course.find(params[:course_id]) + unless params[:course_id].nil? + params[:course_id] = Course.find_by_short_name(params[:course_id]).id if !params[:course_id].is_numeric? and !Course.find_by_short_name(params[:course_id]).nil? + @course = Course.find(params[:course_id]) + end end end diff --git a/app/views/layouts/log.html.haml b/app/views/layouts/log.html.haml index dc155df..aa08e8f 100644 --- a/app/views/layouts/log.html.haml +++ b/app/views/layouts/log.html.haml @@ -1,11 +1,21 @@ -- @title = "#{App.title} - #{h(@course.full_name)} - Mudanças recentes" -- @location = capture do - = link_to(App.title, index_url) + "›" - = link_to("Disciplinas", courses_url) + "›" - = link_to(h(@course.full_name), course_url(@course)) + "›" - = link_to("Log", course_log_url(@course)) - -- @left_panel = render 'courses/_left_panel' -- @content = yield +- if @course + - @title = "#{App.title} - #{h(@course.full_name)} - Mudanças recentes" + - @location = capture do + = link_to(App.title, index_url) + "›" + = link_to("Disciplinas", courses_url) + "›" + = link_to(h(@course.full_name), course_url(@course)) + "›" + = link_to("Log", course_log_url(@course)) + + - @left_panel = render 'courses/_left_panel' + - @content = yield + +- else + - @title = "#{App.title} - Mudanças recentes" + - @location = capture do + = link_to(App.title, index_url) + "›" + = link_to("Mudanças recentes", log_url) + + - @content = yield + - @left_panel = render('widgets/menu_navigation') + render('widgets/menu_user') = render 'layouts/base' diff --git a/app/views/log/_attachment_log_entry.html.haml b/app/views/log/_attachment_log_entry.html.haml index 1961f45..ce04bdb 100644 --- a/app/views/log/_attachment_log_entry.html.haml +++ b/app/views/log/_attachment_log_entry.html.haml @@ -1,4 +1,4 @@ -= "Anexo " + link_to(h(entry.attachment.file_name), course_attachment_url(@course, entry.attachment)) += "Anexo " + link_to(h(entry.attachment.file_name), course_attachment_url(entry.course, entry.attachment)) = "criado " if entry.kind_of?(AttachmentCreateLogEntry) = "editado " if entry.kind_of?(AttachmentEditLogEntry) diff --git a/app/views/log/_event_log_entry.html.haml b/app/views/log/_event_log_entry.html.haml index 7cb855d..95d6743 100644 --- a/app/views/log/_event_log_entry.html.haml +++ b/app/views/log/_event_log_entry.html.haml @@ -1,4 +1,4 @@ -= "Evento " + link_to(h(entry.event.title), course_event_url(@course, entry.event)) += "Evento " + link_to(h(entry.event.title), course_event_url(entry.course, entry.event)) = "criado " if entry.kind_of?(EventCreateLogEntry) = "editado " if entry.kind_of?(EventEditLogEntry) diff --git a/app/views/log/_log_entry.html.haml b/app/views/log/_log_entry.html.haml index b8d1aaa..8e2b376 100644 --- a/app/views/log/_log_entry.html.haml +++ b/app/views/log/_log_entry.html.haml @@ -2,4 +2,4 @@ = render(:partial => 'log/event_log_entry.html.haml', :locals => { :entry => entry }) if entry.kind_of?(EventLogEntry) = render(:partial => 'log/news_log_entry.html.haml', :locals => { :entry => entry }) if entry.kind_of?(NewsLogEntry) = render(:partial => 'log/wiki_log_entry.html.haml', :locals => { :entry => entry }) if entry.kind_of?(WikiLogEntry) -= "(" + link_to("undo", undo_course_log_url(@course, entry)) + ")" if entry.reversible? += "(" + link_to("undo", undo_course_log_url(entry.course, entry.id)) + ")" if entry.reversible? diff --git a/app/views/log/_news_log_entry.html.haml b/app/views/log/_news_log_entry.html.haml index 53ff72e..1e4eeb3 100644 --- a/app/views/log/_news_log_entry.html.haml +++ b/app/views/log/_news_log_entry.html.haml @@ -1,4 +1,4 @@ -= "Notícia " + link_to(h(entry.news.title), course_news_url(@course, entry.news)) += "Notícia " + link_to(h(entry.news.title), course_news_url(entry.course, entry.news)) = "criada " if entry.kind_of?(NewsCreateLogEntry) = "editada " if entry.kind_of?(NewsEditLogEntry) diff --git a/app/views/log/_wiki_log_entry.html.haml b/app/views/log/_wiki_log_entry.html.haml index 56b824a..78db92d 100644 --- a/app/views/log/_wiki_log_entry.html.haml +++ b/app/views/log/_wiki_log_entry.html.haml @@ -1,4 +1,4 @@ -= "Página " + link_to(h(entry.wiki_page.versions.last.title), course_wiki_url(@course, entry.wiki_page.id, :version => entry.wiki_page.version)) += "Página " + link_to(h(entry.wiki_page.versions.last.title), course_wiki_url(entry.course, entry.wiki_page.id, :version => entry.wiki_page.version)) = "criada " if entry.kind_of?(WikiCreateLogEntry) = "editada " if entry.kind_of?(WikiEditLogEntry) @@ -8,6 +8,6 @@ - if entry.kind_of?(WikiEditLogEntry) - if entry.wiki_page.description and !entry.wiki_page.description.empty? = "(#{h(entry.wiki_page.description)})" - = "(" + link_to("diff", diff_course_wiki_url(@course, entry.wiki_page.id, :from => entry.wiki_page.version - 1, :to => entry.wiki_page.version)) + ")" - = "(" + link_to("edit", edit_course_wiki_url(@course, entry.wiki_page.id, :description => "Revertendo para versão #{entry.wiki_page.version}", :version => entry.wiki_page.version)) + ")" - = "(" + link_to("undo", edit_course_wiki_url(@course, entry.wiki_page.id, :description => "Revertendo para versão #{entry.wiki_page.version-1}", :version => entry.wiki_page.version - 1)) + ")" + = "(" + link_to("diff", diff_course_wiki_url(entry.course, entry.wiki_page.id, :from => entry.wiki_page.version - 1, :to => entry.wiki_page.version)) + ")" + = "(" + link_to("edit", edit_course_wiki_url(entry.course, entry.wiki_page.id, :description => "Revertendo para versão #{entry.wiki_page.version}", :version => entry.wiki_page.version)) + ")" + = "(" + link_to("undo", edit_course_wiki_url(entry.course, entry.wiki_page.id, :description => "Revertendo para versão #{entry.wiki_page.version-1}", :version => entry.wiki_page.version - 1)) + ")" diff --git a/app/views/log/index.html.haml b/app/views/log/index.html.haml index 90acefe..5718c81 100644 --- a/app/views/log/index.html.haml +++ b/app/views/log/index.html.haml @@ -1,16 +1,21 @@ -%h4.title= h(@course.full_name) +%h4.title= @course ? h(@course.full_name) : App.title %h1.title Mudanças recentes -= auto_discovery_link_tag :rss, formatted_course_log_url(@course, :rss) +- if @course + = auto_discovery_link_tag :rss, formatted_course_log_url(@course, :rss) .box %table %tr %th Data %th Usuário + - unless @course + %th Disciplina %th Descrição - @log_entries.each do |entry| %tr %td= entry.created_at.strftime("%d/%m/%y %H:%M:%S") %td= link_to truncate(h(entry.user.display_name), 20), user_path(entry.user) + - unless @course + %td= link_to h(entry.course.short_name), course_url(entry.course) %td= render(:partial => 'log/log_entry', :locals => { :entry => entry }) diff --git a/app/views/widgets/menu_navigation.html.haml b/app/views/widgets/menu_navigation.html.haml index 6200b49..4f619d2 100644 --- a/app/views/widgets/menu_navigation.html.haml +++ b/app/views/widgets/menu_navigation.html.haml @@ -3,3 +3,4 @@ %ul %li= link_to "Courses"[].titleize, courses_url %li= link_to "Users"[].titleize, users_url + %li= link_to "Mudanças recentes", log_url diff --git a/config/routes.rb b/config/routes.rb index e0dff5e..6e6530e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -77,6 +77,10 @@ ActionController::Routing::Routes.draw do |map| # Stylesheets map.connect 'stylesheets/cache/:action.:format', :controller => 'stylesheets' map.connect 'stylesheets/cache/:action.:color.:format', :controller => 'stylesheets' + + # Mudancas recentes global + map.log 'log', :controller => 'log', :action => 'index', :format => 'html' + map.formatted_log 'log.:format', :controller => 'log', :action => 'index' # Front page map.index '', :controller => 'courses', :action => 'index'