Skip to content

Commit

Permalink
calendar with bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
danigb committed Jan 21, 2009
1 parent c99576f commit 1903148
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 21 deletions.
7 changes: 7 additions & 0 deletions app/controllers/cyl_controller.rb
Expand Up @@ -39,6 +39,13 @@ def change_password
end
end

def calendar
today = Date.today
params[:month] ||= today.month
params[:year] ||= today.year
@cal = {:month => params[:month].to_i, :year => params[:year].to_i}
end

def blog_create
Document.transaction do
d = Document.create(params[:blog])
Expand Down
1 change: 1 addition & 0 deletions app/helpers/application_helper.rb
Expand Up @@ -2,6 +2,7 @@
# application.
module ApplicationHelper
include CylFormsHelper
include MonthlyHelper

def title(page_title)
content_for(:title) { page_title }
Expand Down
16 changes: 16 additions & 0 deletions app/helpers/cyl_helper.rb
@@ -0,0 +1,16 @@
module CylHelper

def calendar_action(cal, month_offset)
month = cal[:month]
year = cal[:year]
month += month_offset
if month < 1
year -= 1
month = 12
elsif month > 12
year += 1
month = 1
end
{:action => 'calendar', :month => month, :year => year}
end
end
2 changes: 0 additions & 2 deletions app/helpers/groups_helper.rb

This file was deleted.

58 changes: 58 additions & 0 deletions app/helpers/monthly_helper.rb
@@ -0,0 +1,58 @@

module MonthlyHelper

SHORT_DAY_NAMES = ['D','L', 'M', 'X', 'J', 'V','S']
DAY_NAMES = %w(domingo lunes martes miércoles jueves viernes sábado)

MES = %w(Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre Noviembre Diciembre)

def mes(number)
MES[number - 1]
end

def monthly(options = {}, &block)

block ||= Proc.new {|date| date.day}
today = Date.today
defaults = {
:year => today.year,
:month => today.mon,
:first_day_of_week => 1,
:table_class => 'calendar',
:day_names => MonthlyHelper::DAY_NAMES
}
options = defaults.merge options

month_start = Date.civil(options[:year], options[:month], 1)
month_end = Date.civil(options[:year], options[:month], -1)
first_weekday = options[:first_day_of_week]
first_day = month_start - (month_start.wday - first_weekday).days
last_day = month_end + (6 - month_end.wday + options[:first_day_of_week]).days
total_weeks = (last_day - first_day + 1).to_i / 7

day_names = options[:day_names].dup
first_weekday.times do
day_names.push(day_names.shift)
end

current = first_day

concat %(<table class="#{options[:table_class]}">)
concat %(<tr class="names")
day_names.each {|name| concat %(<td>#{name}</td>)}
concat %(</tr>)
total_weeks.times do
concat %(<tr">)
0.upto(6) do
tdc = (today.month == current.month && current.day == today.day) ? 'today' : ''
concat %(<td class="#{tdc}">#{capture(options[:month], current, &block)}</td>)
current += 1.day
end
concat %(</tr>)
end
end




end
11 changes: 11 additions & 0 deletions app/views/cyl/calendar.html.erb
@@ -0,0 +1,11 @@

<h3><%= link_to "Hoy es #{fecha Time.now}", :action => 'calendar', :month => nil, :year => nil %></h3>
<h1><%= link_to '-', calendar_action(@cal, -1), :class => 'button' %> <%= mes(@cal[:month]) %> del <%= @cal[:year] %>
<%= link_to '+', calendar_action(@cal, 1), :class => 'button' %></h1>

<% monthly(@cal) do |month, date| -%>
<% if date.month == month -%>
<%= link_to date.day, {}, :class => 'button new_event' %>
<% end -%>
<% end -%>

9 changes: 0 additions & 9 deletions app/views/cyl/calendario.html.erb

This file was deleted.

1 change: 0 additions & 1 deletion app/views/cyl/message_new.html.erb
Expand Up @@ -3,7 +3,6 @@
<% form_tag({:action => 'message_create'}, :id => 'message_create') do -%>
<%= field_info 'De', @current.name %>
<%= field_select 'Para', :clip, :recipient, Group.all.collect {|p| [ p.name, p.id ] } %>
<%= field_select 'Tipo', :message, :type, Label.all.collect {|p| [ p.name, p.id ] } %>
<%= field_text 'Asunto', :message, :title %>
<%= field_area 'Texto', :message, :body %>
<%= field_submit 'Enviar mensaje', :message_create %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/simplex.html.erb
Expand Up @@ -13,7 +13,7 @@
<body>
<div class="page">
<div class="navigation"><%= link_to 'Blog', :controller => 'cyl', :action => 'blog' %>
<%= link_to 'Calendario', :controller => 'cyl', :action => 'calendario' %>
<%= link_to 'Calendario', :controller => 'cyl', :action => 'calendar' %>
<%= link_to 'Mensajes', :controller => 'cyl', :action => 'message' %>
<%= link_to 'Mediateca', :controller => 'cyl', :action => 'mediateca' %>
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Expand Up @@ -6,6 +6,8 @@

map.root :controller => 'cyl'

map.connect 'calendario/:month/:year', :controller => 'cyl', :action => 'calendar'
map.connect 'calendario', :controller => 'cyl', :action => 'calendar'
map.connect 'admin/:action/:id', :controller => 'admin'
map.connect ':action/:id', :controller => 'cyl'
map.connect ':action/:id.:format', :controller => 'cyl'
Expand Down
33 changes: 25 additions & 8 deletions public/stylesheets/simplex.css
Expand Up @@ -6,26 +6,32 @@ html {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}

h1, h2, h3 {display: block; letter-spacing: -0.05em; line-height: 1em;
color: rgba(255, 255, 255, 0.9)}

h1 { font-size: 3em; margin: 1em 0 0.5em 20%; font-weight: bold;}

h2 { font-size: 1.5em; margin-top: 2em; padding: 0.5em 0 0.5em 20%;
border-top: 1px solid rgba(30, 40, 30, 0.4); }

a {text-decoration: none;}
a:hover {}
a.button {display: block; float: left; margin: 0.3em 0.1em; padding: 0.2em 0.8em 0.2em 0.8em;
background-color: rgba(255, 255, 255, 0.8); -moz-border-radius: 0.2em; color: rgba(30, 40, 30, 0.7);}
a.button:hover {background-color: rgba(255, 255, 255, 0.9); color: rgba(30, 40, 30, 1);}

h1, h2, h3 {display: block; letter-spacing: -0.05em; line-height: 1em;
color: rgba(255, 255, 255, 0.9);}

h1 { font-size: 3em; margin: 0em 0 0.5em 20%; font-weight: bold;}

h2 { font-size: 1.5em; margin-top: 2em; padding: 0.5em 0 0.5em 20%;
border-top: 1px solid rgba(30, 40, 30, 0.4); }

h3 {margin: 0 0 0.5em 20%;}
h3 a {color: rgba(255, 255, 255, 0.9);}

h1 a.button {float: none; display: inline; font-size: 0.5em;}

.notice {display: block; margin: 0 10%; padding: 0.2em 0.8em 0.2em 0.8em; text-align: center;
background-color: rgba(255, 138, 0, 0.8); -moz-border-radius: 0.2em; color: rgba(30, 40, 30, 0.9);}

.page {width: 60em; margin: 2em auto;}

.navigation {width: 100%; overflow: hidden;
.navigation {width: 100%; overflow: hidden; margin-bottom: 2em;
border-top: 1px solid rgba(30, 40, 30, 0.4); border-bottom: 1px solid rgba(30, 40, 30, 0.4);}
.navigation a {display: block; float: left; margin: 0.2em 1em; color: black;letter-spacing:-0.05em;}
.navigation a:hover {color: rgba(255, 255, 255, 0.8); margin-bottom: 0; border-bottom: 0.2em solid rgba(30, 40, 30, 0.4);}
Expand Down Expand Up @@ -75,3 +81,14 @@ td.blog h1 {display: block; font-size: 1.5em; float: left; margin: 0 0.5em 0 0;
td.links a {font-size: 0.8em; display: block; float: left; margin: 0.2em; padding: 0em 0.8em 0.2em 0.8em;
background-color: rgba(255, 255, 255, 0.8); -moz-border-radius: 0.2em; color: rgba(30, 40, 30, 0.9); }
td.links a:hover {background-color: rgba(255, 255, 255, 0.9); color: rgba(30, 40, 30, 1);}

table.calendar {width: 100%; border-collapse: separate; border-spacing: 5px;}
table.calendar tr {border-top: 0;}
table.calendar tr.names td {height: 1em; border-top: 0px; color: rgba(255, 255, 255, 0.9)}
table.calendar td.today {background-color: rgba(255, 225, 255, 0.3); border: 1px solid rgba(30, 40, 30, 0.6);}
table.calendar td {width: 11%; height: 10em; padding: 0em; border-top: 1px solid rgba(30, 40, 30, 0.4); margin-right: 0.5em;}
table.calendar p.number {float: left;}

.calendar td a.new_event {float: none; font-size: 0.7em; pading: 0.1em 1em; margin: 0 0 2px 0;
background-color: rgba(255, 255, 255, 0.3);}
.calendar td a.new_event:hover {background-color: rgba(255, 255, 255, 0.8);}

0 comments on commit 1903148

Please sign in to comment.