Skip to content

Commit

Permalink
mas...
Browse files Browse the repository at this point in the history
  • Loading branch information
dani committed Jan 20, 2009
1 parent 0983ac4 commit 12192fb
Show file tree
Hide file tree
Showing 22 changed files with 155 additions and 33 deletions.
4 changes: 4 additions & 0 deletions IDEAS
@@ -0,0 +1,4 @@

Blog.Calendario.Mensajes.Documentos.Archivos.Grupos.Usuarios

todos los clips tienen: destinatario (visibilidad), fecha (para eventos)
1 change: 1 addition & 0 deletions README
@@ -0,0 +1 @@

3 changes: 1 addition & 2 deletions app/controllers/admin_controller.rb
Expand Up @@ -8,8 +8,7 @@ def index
def create_group
Group.transaction do
g = Group.create(params[:group])
Clip.create(:title => 'Nuevo grupo', :description => "Celebramos la creación del grupo #{g.name}",
:content_class => 'Group', :content_type => 'group', :content_id => g.id, :user_id => @current.id)
g.new_clip(@current).save
show_admin 'Grupo creado con éxito'
end
end
Expand Down
12 changes: 12 additions & 0 deletions app/controllers/cyl_controller.rb
Expand Up @@ -42,6 +42,18 @@ def change_password
end
end

def blog_new
end

def blog_create
Document.transaction do
d = Document.create(params[:blog])
Clip.create(:title => 'Entrada al blog', :description => d.summary, :content_class => 'Document',
:content_type => 'blog', :recipient_id => 1, :user_id => @current.id, :content_id => d.id )
redirect_to :action => 'blog'
end
end

private
def render_login(error = nil)
flash[:error] = error
Expand Down
10 changes: 8 additions & 2 deletions app/helpers/application_helper.rb
@@ -1,13 +1,19 @@
# Methods added to this helper will be available to all templates in the application.
# Methods added to this helper will be available to all templates in the
# application.
module ApplicationHelper
include CylFormsHelper

def title(page_title)
content_for(:title) { page_title }
end

def clip_info(clip)
content_tag( :p, content_tag( :label, 'publicado ') << fecha(clip.created_at) ) <<
content_tag(:p, content_tag(:label, 'de ' ) << clip.user.name << content_tag(:label, ' para ') << clip.recipient.name)
end

def flash_div(name)
content_tag( :div, flash[name], :class => name.to_s ) if flash[name]
content_tag( :div, flash[name], :class => name.to_s ) if flash[name]
end

def fecha(date)
Expand Down
9 changes: 8 additions & 1 deletion app/helpers/cyl_forms_helper.rb
@@ -1,5 +1,12 @@
module CylFormsHelper

def field_info(label, value)
content_tag(:label, label) << content_tag(:p, value, :class => 'info') << content_tag(:br)
end

def field_area(label, group, name)
content_tag(:label, label) << text_area_tag("#{group}[#{name}]") << content_tag(:br)
end

def field_text(label, group, name, options = {:validate => []})
content_tag(:label, label) << text_field_tag("#{group}[#{name}]", '', :class => options[:validate].join(' ')) << content_tag(:br)
Expand All @@ -15,7 +22,7 @@ def field_select(label, group, name, collection)

def field_submit(name, id)
content_tag(:label, '&nbsp;') << content_tag(:a, name, :href => 'javascript: void(0);',
:onclick => "$('##{id}').valida();", :class => 'submit button') << content_tag(:br)
:onclick => "$('##{id}').valida();", :class => 'submit button') << content_tag(:br)
end

end
Expand Down
3 changes: 3 additions & 0 deletions app/models/clip.rb
@@ -1,3 +1,6 @@
class Clip < ActiveRecord::Base
belongs_to :user
belongs_to :recipient, :class_name => 'Group'

named_scope :posts, :conditions => {:content_type => 'blog'}
end
5 changes: 5 additions & 0 deletions app/models/document.rb
@@ -1,2 +1,7 @@
class Document < ActiveRecord::Base
DIALECTS = [:plain, :html, :textile]

def summary
"<h1>#{title}</h1>#{body}"
end
end
14 changes: 13 additions & 1 deletion app/models/group.rb
@@ -1,5 +1,17 @@
class Group < ActiveRecord::Base
has_and_belongs_to_many :users
named_scope :gaks, :conditions => {:gak => true}


GROUPS = {:cyl => 1, :web => 2}


def self.get(name)
Group::GROUPS[name]
end

def new_clip(user)
Clip.new(:title => 'Nuevo grupo', :description => "Celebramos la creación del grupo #{self.name}",
:content_class => 'Group', :content_type => 'group', :content_id => self.id,
:user_id => user.id, :recipient_id => Group.get(:web))
end
end
4 changes: 2 additions & 2 deletions app/views/clips/index.html.erb
Expand Up @@ -3,9 +3,9 @@
<table>
<% for clip in @clips %>
<tr>
<td class="date"><%= fecha clip.created_at %> <%= clip.user.name %></td>
<td class="info"><%= clip_info clip %></td>
<td class="title"><%=h clip.title %></td>
<td class="description"><%=h clip.description %></td>
<td class="description blog"><%= clip.description %></td>
</tr>
<% end %>
</table>
Expand Down
14 changes: 14 additions & 0 deletions app/views/cyl/blog.html.erb
@@ -0,0 +1,14 @@
<div class="actions">
<%= link_to 'Crear entrada', {:action => 'blog_new'}, :class => 'button' %>
</div>

<h1>Entradas del blog</h1>
<table>
<% for post in Clip.posts -%>
<tr>
<td class="info"><%= clip_info post %></td>
<td class="title"><%= Document.find(post.content_id).title %> </td>
<td class="description"><%= link_to 'editar', {:action => 'blog_edit', :id => post.id}, :class => 'button' %></td>
</tr>
<% end -%>
</table>
8 changes: 8 additions & 0 deletions app/views/cyl/blog_new.html.erb
@@ -0,0 +1,8 @@
<h1>Crear una entrada de blog</h1>

<% form_tag( {:action => 'blog_create'}, :id => 'blog_create') do -%>
<%= field_text 'Título', :blog, :title, :validate => [:not_empty] %>
<%= field_select 'Dialecto', :blog, :dialect, Document::DIALECTS %>
<%= field_area 'Contenido', :blog, :body %>
<%= field_submit 'Crear entrada', :blog_create %>
<% end -%>
10 changes: 10 additions & 0 deletions app/views/cyl/message_new.html.erb
@@ -0,0 +1,10 @@
<h1>Enviar un nuevo mensaje</h1>

<% form_tag({:action => 'message_create'}, :id => 'message_create') do -%>
<%= field_info 'De', @current.name %>
<%= field_select 'Para', :message, :to, 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, :subject %>
<%= field_area 'Texto', :message, :body %>
<%= field_submit 'Enviar mensaje', :message_create %>
<% end -%>
9 changes: 7 additions & 2 deletions app/views/layouts/simplex.html.erb
Expand Up @@ -12,15 +12,20 @@
</head>
<body>
<div class="page">
<div class="navigation"><%= link_to 'Gente', users_path %><%= link_to 'Grupos', groups_path %>
<%= link_to 'Clips', clips_path %><%= link_to 'Entradas', documents_path %>
<div class="navigation"><%= link_to 'Blog', :controller => 'cyl', :action => 'blog' %>
<%= link_to 'Calendario', :controller => 'cyl', :action => 'calendario' %>
<%= link_to 'Mensajes', :controller => 'cyl', :action => 'message_new' %>
<%= link_to 'Gente', users_path %><%= link_to 'Grupos', groups_path %>
<%= link_to 'Clips', clips_path %>
<div class="login">hola, <%= link_to @current.name, @current %>.
<%= link_to('Eres administrador', :controller => 'admin' ) if @current.admin %>.
<%= link_to 'Salir', :controller => 'cyl', :action => 'logout' %></div>
</div>
<!--
<div class="quick">
<ul class="labels"><% for label in Label.all -%><li><%= link_to label.name, label %></li><% end -%></ul>
</div>
-->
<div class="content"><%= yield %></div>
</div>
</body>
Expand Down
22 changes: 22 additions & 0 deletions config/database.sql3.yml
@@ -0,0 +1,22 @@
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
Binary file modified db/development.sqlite3
Binary file not shown.
4 changes: 3 additions & 1 deletion db/migrate/20090117184417_create_clips.rb
Expand Up @@ -4,9 +4,11 @@ def self.up
t.string 'title', :null => false
t.string 'description', :null => false
t.string 'content_class'
t.string 'content_type'
t.string 'content_type'
t.references 'content'
t.references 'recipient', :null => false
t.references 'user', :null => false
t.timestamp 'date'
t.timestamps
end
end
Expand Down
9 changes: 5 additions & 4 deletions db/migrate/20090117203811_create_groups.rb
Expand Up @@ -12,14 +12,15 @@ def self.up
t.references :user
end

cyl = Group.new(:name => 'CyL', :gak => false, :description => 'tod@s estamos en Crestas y Lechugas')
cyl = Group.new(:id => Group.get(:cyl), :name => 'CyL', :gak => false, :description => 'Tod@s estamos en Crestas y Lechugas.')
cyl.users << User.find(:all)
cyl.save

ci = Group.create(:name => 'comisión técnica', :gak => false,
:description => 'se encarga de todas las labores guapas guapas de la hüerta')
ci.users << User.find(1)
ci = Group.create(:id => Group.get(:web), :name => 'Administración web', :gak => false,
:description => 'Se encargan de mantener la web de Crestas y Lechugas.')
ci.users << User.find(:all)
ci.save

end

def self.down
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20090117222705_create_documents.rb
Expand Up @@ -2,8 +2,8 @@ class CreateDocuments < ActiveRecord::Migration
def self.up
create_table :documents do |t|
t.string :dialect
t.string :title
t.text :body

t.timestamps
end
end
Expand Down
4 changes: 4 additions & 0 deletions db/migrate/20090119201232_create_labels.rb
Expand Up @@ -6,6 +6,10 @@ def self.up

t.timestamps
end

Label.create(:name => 'trabajo en la huerta', :description => 'todo lo relacionado con trabajo en la huerta')
Label.create(:name => 'pregunta', :description => 'utiliza este tipo de mensaje para preguntar')
Label.create(:name => 'convocatorias', :description => 'convocatoria')
end

def self.down
Expand Down
3 changes: 3 additions & 0 deletions db/schema.rb
Expand Up @@ -29,13 +29,16 @@
t.string "content_class"
t.string "content_type"
t.integer "content_id"
t.integer "recipient_id", :null => false
t.integer "user_id", :null => false
t.datetime "date"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "documents", :force => true do |t|
t.string "dialect"
t.string "title"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
Expand Down
38 changes: 21 additions & 17 deletions public/stylesheets/simplex.css
Expand Up @@ -7,7 +7,7 @@ html {
}

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

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

Expand All @@ -17,41 +17,41 @@ h2 { font-size: 1.5em; margin-top: 2em; padding: 0.5em 0 0.5em 20%;
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);}
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);}

.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);}
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;
border-top: 1px solid rgba(30, 40, 30, 0.4); border-bottom: 1px solid rgba(30, 40, 30, 0.4);}
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);}
.navigation .login {float: right; margin: 0.2em 1em 0 0;}
.navigation .login a {display: inline; margin: 0; padding: 0; float: none; color: rgba(255, 255, 255, 0.8);}

.quick {float: right; margin-top: 3em; width: 18%;}
.content {width: 80%;}
.content {width: 100%;}
.labels a {display: block; padding-left: 0.5em;
color: rgba(0, 0, 0, 0.7); border-top: 1px solid rgba(30, 40, 30, 0.4);
color: rgba(0, 0, 0, 0.7); border-top: 1px solid rgba(30, 40, 30, 0.4);
}
.labels a:hover {
color: rgba(255, 255, 255, 0.7); background-color: rgba(0, 0, 0, 0.3);
color: rgba(255, 255, 255, 0.7); background-color: rgba(0, 0, 0, 0.3);
}

form label {display: block; float: left; width: 18%; margin-right: 2%; text-align: right; margin-top: 4px;}
form input {display: block; float: left;}
form input[type=text], form input[type=password] {width: 60%; border: 1px solid white; margin: 2px; padding: 2px;
background-color: rgba(255, 255, 255, 0.8);}
form p.info {display: block; float: left; width: 60%; margin-top: 0.2em; color: rgba(0, 0, 0, 0.6); font-weight: bold;}
form input, form textarea {display: block; float: left;}
form input[type=text], form input[type=password], form textarea {width: 60%; border: 1px solid white; margin: 2px; padding: 2px;
background-color: rgba(255, 255, 255, 0.8);}
form select {width: 60%; margin: 0.3em 0; }
form select {width: 20%;}
form input.error {border: 1px solid #c00;}

form textarea {height: 20em;}
form input[type=submit] {margin-top: 0.5em;}
form br {clear: both;}
form textarea {width: 80%;}
form a.submit {font-size: 0.9em;}
form p.error {margin-left: 20%; color: #c00; clear: both;}

Expand All @@ -60,14 +60,18 @@ form p.error {margin-left: 20%; color: #c00; clear: both;}
table { width: 100%;
color: rgba(30, 40, 30, 0.6); }
tr {border-top: 1px solid rgba(30, 40, 30, 0.4);}
td {vertical-align: bottom; padding: 0.5em;}
td.date {width: 20%;}
td.title {padding: 0.25em 0; font-size: 2em; width: 20%; letter-spacing:-0.05em; line-height:1em;}
td {vertical-align: top; padding: 0.5em;}
td.info {text-align: right; width: 20%; font-size: 0.8em; font-weight: bold;}
td.info label {font-weight: normal;}
td.title {padding: 0.25em 0; font-size: 2em; width: 30%; letter-spacing:-0.05em; line-height:1em;}
td.title a {color:rgba(30, 40, 30, 0.9); }
td.title a:hover {color:rgba(0, 10, 0, 0.9); }

td.description {font-size:0.75em; line-height:1.125em;}

td.blog {vertical-align: top;}
td.blog h1 {display: block; font-size: 1.5em; float: left; margin: 0 0.5em 0 0;
color:rgba(30, 40, 30, 0.6); }

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); }
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);}

0 comments on commit 12192fb

Please sign in to comment.