Dashboard agora com rss e ical
This commit is contained in:
@@ -19,6 +19,8 @@ class LogController < ApplicationController
|
|||||||
@log_entries = @course.log_entries.find(:all, :limit => 50) #.paginate(:page => params[:page], :per_page => 30)
|
@log_entries = @course.log_entries.find(:all, :limit => 50) #.paginate(:page => params[:page], :per_page => 30)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
|
format.rss { response.content_type = Mime::RSS }
|
||||||
|
format.xml { render :xml => @log_entries }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class UsersController < ApplicationController
|
|||||||
@user.save!
|
@user.save!
|
||||||
setup_session(@user)
|
setup_session(@user)
|
||||||
flash[:message] = 'User account created'[]
|
flash[:message] = 'User account created'[]
|
||||||
redirect_to user_path(@user)
|
redirect_to dashboard_url
|
||||||
rescue ActiveRecord::RecordInvalid
|
rescue ActiveRecord::RecordInvalid
|
||||||
flash[:warning] = 'Não foi possível cadastrar a conta.'
|
flash[:warning] = 'Não foi possível cadastrar a conta.'
|
||||||
end
|
end
|
||||||
@@ -82,7 +82,7 @@ class UsersController < ApplicationController
|
|||||||
@user.save!
|
@user.save!
|
||||||
@color = @user.pref_color
|
@color = @user.pref_color
|
||||||
flash[:message] = 'Settings updated'[]
|
flash[:message] = 'Settings updated'[]
|
||||||
redirect_to index_path
|
redirect_to dashboard_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -110,11 +110,24 @@ class UsersController < ApplicationController
|
|||||||
@news = []
|
@news = []
|
||||||
@events = []
|
@events = []
|
||||||
|
|
||||||
unless @current_user.courses.empty?
|
if params[:format] == 'html'
|
||||||
@news = News.find(:all, :conditions => [ 'receiver_id in (?)', @current_user.courses ],
|
return unless require_login
|
||||||
|
@user = @current_user
|
||||||
|
else
|
||||||
|
@user = User.find_by_secret(params[:secret])
|
||||||
|
end
|
||||||
|
|
||||||
|
unless @user.courses.empty?
|
||||||
|
@news = News.find(:all, :conditions => [ 'receiver_id in (?)', @user.courses ],
|
||||||
:order => 'timestamp desc', :limit => 5)
|
:order => 'timestamp desc', :limit => 5)
|
||||||
@events = Event.find(:all, :conditions => [ 'course_id in (?) and (time > ?) and (time < ?)',
|
@events = Event.find(:all, :conditions => [ 'course_id in (?) and (time > ?) and (time < ?)',
|
||||||
@current_user.courses, 1.day.ago, 21.days.from_now ], :order => 'time')
|
@user.courses, 1.day.ago, 21.days.from_now ], :order => 'time')
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.rss { response.content_type = Mime::RSS }
|
||||||
|
format.ics { response.content_type = Mime::ICS; render :text => Event.to_ical(@user.courses) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,21 @@ class LogEntry < ActiveRecord::Base
|
|||||||
belongs_to :course
|
belongs_to :course
|
||||||
|
|
||||||
def reversible?() false end
|
def reversible?() false end
|
||||||
|
|
||||||
|
def to_xml(options = {})
|
||||||
|
options[:indent] ||= 2
|
||||||
|
xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
|
||||||
|
xml.instruct! unless options[:skip_instruct]
|
||||||
|
xml.log_entry do
|
||||||
|
xml.id self.id
|
||||||
|
xml.course_id self.course_id
|
||||||
|
xml.created_at self.created_at
|
||||||
|
xml.target_id self.target_id
|
||||||
|
xml.user_id self.user_id
|
||||||
|
xml.type self.type
|
||||||
|
xml.version self.version unless self.version.nil?
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'log_entry/attachment_log_entry.rb'
|
require 'log_entry/attachment_log_entry.rb'
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ class User < ActiveRecord::Base
|
|||||||
xml.user do
|
xml.user do
|
||||||
xml.id self.id
|
xml.id self.id
|
||||||
xml.name self.name
|
xml.name self.name
|
||||||
|
xml.display_name self.display_name
|
||||||
|
xml.login self.login
|
||||||
xml.created_at self.created_at
|
xml.created_at self.created_at
|
||||||
xml.last_seen self.last_seen
|
xml.last_seen self.last_seen
|
||||||
xml.description self.description
|
xml.description self.description
|
||||||
@@ -91,6 +93,7 @@ class User < ActiveRecord::Base
|
|||||||
|
|
||||||
def before_save
|
def before_save
|
||||||
self.salt = User.random_string(10) if !self.salt?
|
self.salt = User.random_string(10) if !self.salt?
|
||||||
|
self.secret = User.random_string(32) if !self.secret?
|
||||||
self.hashed_password = User.encrypt(@password, self.salt) if !@password.blank?
|
self.hashed_password = User.encrypt(@password, self.salt) if !@password.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
%h4.title= h(@course.full_name)
|
%h4.title= h(@course.full_name)
|
||||||
%h1.title Mudanças recentes
|
%h1.title Mudanças recentes
|
||||||
|
|
||||||
|
= auto_discovery_link_tag :rss, formatted_course_log_url(@course, :rss)
|
||||||
|
|
||||||
.box
|
.box
|
||||||
%table
|
%table
|
||||||
%tr
|
%tr
|
||||||
@@ -11,9 +13,4 @@
|
|||||||
%tr
|
%tr
|
||||||
%td= entry.created_at.strftime("%d/%m/%y %H:%M:%S")
|
%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)
|
%td= link_to truncate(h(entry.user.display_name), 20), user_path(entry.user)
|
||||||
%td
|
%td= render(:partial => 'log/log_entry', :locals => { :entry => entry })
|
||||||
= render(:partial => 'log/attachment_log_entry', :locals => { :entry => entry }) if entry.kind_of?(AttachmentLogEntry)
|
|
||||||
= render(:partial => 'log/event_log_entry', :locals => { :entry => entry }) if entry.kind_of?(EventLogEntry)
|
|
||||||
= render(:partial => 'log/news_log_entry', :locals => { :entry => entry }) if entry.kind_of?(NewsLogEntry)
|
|
||||||
= render(:partial => 'log/wiki_log_entry', :locals => { :entry => entry }) if entry.kind_of?(WikiLogEntry)
|
|
||||||
= "(" + link_to("undo", undo_course_log_url(@course, entry)) + ")" if entry.reversible?
|
|
||||||
|
|||||||
@@ -28,11 +28,6 @@ h1, h2, h3, h4, h5, th {
|
|||||||
background-color: <%= color[0] %>;
|
background-color: <%= color[0] %>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#footer {
|
|
||||||
background-color: <%= color[3] %>;
|
|
||||||
border-top: 5px solid <%= color[3] %>;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon img:hover {
|
.icon img:hover {
|
||||||
background-color: <%= color[1] %>;
|
background-color: <%= color[1] %>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,13 +120,15 @@ body {
|
|||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
min-width: 780px;
|
min-width: 780px;
|
||||||
|
|
||||||
background-image: url(<%= App.base_path %>/images/bg_body.png);
|
background-color: #fff;
|
||||||
background-repeat: repeat-x;
|
|
||||||
background-color: #f4f4f4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#wrapper {
|
#wrapper {
|
||||||
margin: 0em auto;
|
margin: 0em -9px;
|
||||||
|
padding: 0px 9px;
|
||||||
|
background-image: url(<%= App.base_path %>/images/bg_body.png);
|
||||||
|
background-repeat: repeat-x;
|
||||||
|
background-color: #f4f4f4;
|
||||||
}
|
}
|
||||||
|
|
||||||
#header {
|
#header {
|
||||||
@@ -194,16 +196,14 @@ body {
|
|||||||
#site {
|
#site {
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
margin-top: 18px;
|
margin-top: 18px;
|
||||||
border-bottom: 30px solid #eee;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#footer {
|
#footer {
|
||||||
display: none;
|
border-top: 3px solid #f0f0f0;
|
||||||
background-image: url(<%= App.base_path %>/images/footer_bg.png);
|
margin: 0px -9px;
|
||||||
background-position: top;
|
padding: 18px 0px;
|
||||||
background-repeat: repeat-x;
|
text-align: center;
|
||||||
margin: 0em;
|
color: #aaa;
|
||||||
height: 10em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.float_panel_left {
|
.float_panel_left {
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
%h4.title Dashboard
|
%h4.title Dashboard
|
||||||
%h1.title= "Bem vindo, #{h(@current_user.display_name)}"
|
%h1.title= "Bem vindo, #{h(@current_user.display_name)}"
|
||||||
|
|
||||||
|
= auto_discovery_link_tag :rss, formatted_dashboard_url(:secret => @current_user.secret, :format => 'rss')
|
||||||
|
|
||||||
.dashboard
|
.dashboard
|
||||||
.box
|
.box
|
||||||
|
.cmd
|
||||||
|
=link_to "rss", formatted_dashboard_url(:secret => @current_user.secret, :format => 'rss')
|
||||||
- last_time = nil
|
- last_time = nil
|
||||||
%h3 Notícias Recentes
|
|
||||||
|
|
||||||
|
%h3 Notícias Recentes
|
||||||
- if @news.empty?
|
- if @news.empty?
|
||||||
%ul
|
%ul
|
||||||
%li.no_itens Nenhum notícia recente
|
%li.no_itens Nenhum notícia recente
|
||||||
|
|
||||||
%table
|
%table
|
||||||
- @news.each do |n|
|
- @news.each do |n|
|
||||||
%tr
|
%tr
|
||||||
@@ -22,13 +25,14 @@
|
|||||||
%p= h(n.body)
|
%p= h(n.body)
|
||||||
|
|
||||||
.box
|
.box
|
||||||
|
.cmd
|
||||||
|
=link_to "ical", formatted_dashboard_url(:secret => @current_user.secret, :format => 'ics')
|
||||||
- last_time = nil
|
- last_time = nil
|
||||||
%h3 Próximos Eventos
|
|
||||||
|
|
||||||
|
%h3 Próximos Eventos
|
||||||
- if @events.empty?
|
- if @events.empty?
|
||||||
%ul
|
%ul
|
||||||
%li.no_itens Nenhum evento próximo
|
%li.no_itens Nenhum evento próximo
|
||||||
|
|
||||||
%table
|
%table
|
||||||
- @events.each do |n|
|
- @events.each do |n|
|
||||||
%tr
|
%tr
|
||||||
@@ -49,3 +53,4 @@
|
|||||||
|
|
||||||
- @current_user.courses.each do |course|
|
- @current_user.courses.each do |course|
|
||||||
%li= link_to(h(course.full_name), course_url(course))
|
%li= link_to(h(course.full_name), course_url(course))
|
||||||
|
|
||||||
|
|||||||
18
app/views/users/dashboard.rss.builder
Normal file
18
app/views/users/dashboard.rss.builder
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
xml.instruct! :xml, :version=>"1.0"
|
||||||
|
xml.rss(:version=>"2.0") do
|
||||||
|
xml.channel do
|
||||||
|
xml.title("#{App.title} - " + "News"[].titleize)
|
||||||
|
xml.link(dashboard_url)
|
||||||
|
xml.language(App.language)
|
||||||
|
xml.description("{app} news"[:news_about, App.title])
|
||||||
|
for news_item in @news
|
||||||
|
xml.item do
|
||||||
|
xml.title(news_item.course.short_name + ": " + news_item.title)
|
||||||
|
xml.description(news_item.body)
|
||||||
|
xml.pubDate(news_item.timestamp.rfc2822)
|
||||||
|
xml.link(course_news_url(news_item.course, news_item))
|
||||||
|
xml.guid(course_news_url(news_item.course, news_item))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -71,7 +71,8 @@ ActionController::Routing::Routes.draw do |map|
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Pagina pessoal
|
# Pagina pessoal
|
||||||
map.dashboard '/dashboard', :controller => 'users', :action => 'dashboard'
|
map.dashboard '/dashboard', :controller => 'users', :action => 'dashboard', :format => 'html'
|
||||||
|
map.formatted_dashboard '/dashboard/:secret.:format', :controller => 'users', :action => 'dashboard'
|
||||||
|
|
||||||
# Stylesheets
|
# Stylesheets
|
||||||
map.connect 'stylesheets/:action.:format', :controller => 'stylesheets'
|
map.connect 'stylesheets/:action.:format', :controller => 'stylesheets'
|
||||||
|
|||||||
13
db/migrate/030_user_secret.rb
Normal file
13
db/migrate/030_user_secret.rb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
class UserSecret < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :users, :secret, :string, :null => true
|
||||||
|
User.find(:all).each do |user|
|
||||||
|
user.update_attribute(:secret, User.random_string(32))
|
||||||
|
end
|
||||||
|
change_column :users, :secret, :string, :null => false
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :users, :secret
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 29) do
|
ActiveRecord::Schema.define(:version => 30) do
|
||||||
|
|
||||||
create_table "attachments", :force => true do |t|
|
create_table "attachments", :force => true do |t|
|
||||||
t.string "file_name", :null => false
|
t.string "file_name", :null => false
|
||||||
@@ -87,6 +87,7 @@ ActiveRecord::Schema.define(:version => 29) do
|
|||||||
t.datetime "last_seen", :null => false
|
t.datetime "last_seen", :null => false
|
||||||
t.string "login_key"
|
t.string "login_key"
|
||||||
t.boolean "admin", :default => false, :null => false
|
t.boolean "admin", :default => false, :null => false
|
||||||
|
t.string "secret", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "wiki_page_versions", :force => true do |t|
|
create_table "wiki_page_versions", :force => true do |t|
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ wiki_page_removed: Página wiki removida
|
|||||||
wiki_page_updated: Página wiki atualizada
|
wiki_page_updated: Página wiki atualizada
|
||||||
wiki_page_restored: Página wiki restaurada
|
wiki_page_restored: Página wiki restaurada
|
||||||
|
|
||||||
|
recent_changes: Mudanças recentes
|
||||||
|
log_about: Mudanças recentes em {disciplina}
|
||||||
|
|
||||||
undo: Desfazer
|
undo: Desfazer
|
||||||
login_required: É necessário fazer login para acessar esta área do site
|
login_required: É necessário fazer login para acessar esta área do site
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user