Commit 7b56b5c463c32db2796dc8f392874dd12604472c
1 parent
1b4b5b9e
Exists in
master
and in
28 other branches
ActionItem21: checkpoint
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@953 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
11 changed files
with
186 additions
and
43 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
... | ... | @@ -4,7 +4,22 @@ class CmsController < MyProfileController |
4 | 4 | # protect 'post_content', :profile, :only => [:edit, :new, :reorder, :delete] |
5 | 5 | |
6 | 6 | def view |
7 | - @document = profile.documents.find(params[:id]) | |
7 | + @article = profile.articles.find(params[:id]) | |
8 | + @subitems = @article.children | |
9 | + end | |
10 | + | |
11 | + def index | |
12 | + @article = profile.home_page | |
13 | + @subitems = profile.top_level_articles | |
14 | + render :action => 'view' | |
15 | + end | |
16 | + | |
17 | + post_only :set_home_page | |
18 | + def set_home_page | |
19 | + @article = profile.articles.find(params[:id]) | |
20 | + profile.home_page = @article | |
21 | + profile.save! | |
22 | + redirect_to :back | |
8 | 23 | end |
9 | 24 | |
10 | 25 | protected | ... | ... |
app/models/profile.rb
... | ... | @@ -43,6 +43,7 @@ class Profile < ActiveRecord::Base |
43 | 43 | has_many :role_assignments, :as => :resource |
44 | 44 | |
45 | 45 | has_many :articles |
46 | + belongs_to :home_page, :class_name => Article.name, :foreign_key => 'home_page_id' | |
46 | 47 | |
47 | 48 | def top_level_articles(reload = false) |
48 | 49 | if reload |
... | ... | @@ -78,11 +79,6 @@ class Profile < ActiveRecord::Base |
78 | 79 | find_tagged_with(term) + find_all_by_name(term) |
79 | 80 | end |
80 | 81 | |
81 | - def homepage(reload = false) | |
82 | - # FIXME | |
83 | - raise 'needs to be implemented' | |
84 | - end | |
85 | - | |
86 | 82 | # Returns information about the profile's owner that was made public by |
87 | 83 | # him/her. |
88 | 84 | # | ... | ... |
app/views/cms/view.rhtml
1 | -<%# FIXME %> | |
1 | +<% if @article %> | |
2 | + <h2> | |
3 | + <%= link_to profile.identifier, :action => 'index' %> | |
4 | + <%= @article.hierarchy.map {|item| " / " + ((item == @article) ? item.name : link_to(item.name, :id => item.id)) } %> | |
5 | + </h2> | |
6 | +<% end %> | |
2 | 7 | |
3 | -<h2><%= @document.title %></h2> | |
8 | +<%# list the children %> | |
9 | + | |
10 | +<div class='article-children'> | |
11 | + | |
12 | + <div class='file-manager-small'> | |
13 | + <ul> | |
14 | + <% @subitems.each do |item| %> | |
15 | + <li> | |
16 | + <%= file_manager_button(item.name, "icons-mime/#{item.icon_name}", :action => 'view', :id => item.id) %> | |
17 | + </li> | |
18 | + <% end %> | |
19 | + </ul> | |
20 | + </div> | |
21 | + | |
22 | + <% if @article %> | |
23 | + <%= link_to _('New subitem'), :action => 'new', :parent_id => @article.id %> | |
24 | + <% else %> | |
25 | + <%= link_to _('New article'), :action => 'new' %> | |
26 | + <% end %> | |
27 | + | |
28 | +</div> | |
29 | + | |
30 | +<%# display the article content %> | |
31 | + | |
32 | +<% if @article %> | |
33 | + <h2><%= @article.name %></h2> | |
34 | + <%= @article.to_html %> | |
35 | +<% end %> | ... | ... |
db/migrate/003_create_profiles.rb
... | ... | @@ -7,10 +7,11 @@ class CreateProfiles < ActiveRecord::Migration |
7 | 7 | t.column :environment_id, :integer |
8 | 8 | t.column :design_data, :text |
9 | 9 | |
10 | - | |
11 | 10 | t.column :active, :boolean, :default => true |
12 | 11 | t.column :address, :string |
13 | 12 | t.column :contact_phone, :string |
13 | + | |
14 | + t.column :home_page_id, :integer | |
14 | 15 | |
15 | 16 | #person fields |
16 | 17 | t.column :user_id, :integer | ... | ... |
... | ... | @@ -0,0 +1,46 @@ |
1 | +dlg-neu icons in Noosfero | |
2 | +========================= | |
3 | + | |
4 | +The icons in this directory are taken from the dlg-neu icon theme for GNOME, | |
5 | +section "mimetypes/". We take the SVG files and convert to 64x64 PNG images, so | |
6 | +these icons are in fact derived works based on dlg-neu's SVG files. | |
7 | + | |
8 | +Structure | |
9 | +========= | |
10 | + | |
11 | +To keep a trace back to dlg-neu theme, when rasterizing the SVG files we keep | |
12 | +the original filenames (replacing .svg by .png, obviously) and create symbolic | |
13 | +links with names more sensible for Noosfero. | |
14 | + | |
15 | +Icons rasterization | |
16 | +=================== | |
17 | + | |
18 | +With rsvg, from the librsvg2-bin package (i.e. we use the same rasterization | |
19 | +library as GNOME, so the icons must look like they do in GNOME). | |
20 | + | |
21 | +$ rsvg -w 64 -h 64 <ICON>.svg <ICON>.png | |
22 | + | |
23 | +Licensing | |
24 | +========= | |
25 | + | |
26 | +Their License is as follows (taken from | |
27 | +/usr/share/doc/gnome-icon-theme-dlg-neu/copyright on a Debian system): | |
28 | + | |
29 | + This package is free software; you can redistribute it and/or modify | |
30 | + it under the terms of the GNU General Public License as published by | |
31 | + the Free Software Foundation; either version 2 of the License, or | |
32 | + (at your option) any later version. | |
33 | + | |
34 | + This package is distributed in the hope that it will be useful, | |
35 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
36 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
37 | + GNU General Public License for more details. | |
38 | + | |
39 | + You should have received a copy of the GNU General Public License | |
40 | + along with this package; if not, write to the Free Software | |
41 | + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
42 | + 02110-1301 USA | |
43 | + | |
44 | +On Debian systems, the complete text of the GNU General | |
45 | +Public License can be found in `/usr/share/common-licenses/GPL'. | |
46 | + | ... | ... |
1.19 KB
public/stylesheets/common.css
... | ... | @@ -96,10 +96,13 @@ margin-right: 20px; |
96 | 96 | height: 20px; |
97 | 97 | } |
98 | 98 | |
99 | +/* file manager (big) style */ | |
100 | + | |
99 | 101 | div.file-manager { |
100 | 102 | clear: both; |
101 | 103 | } |
102 | 104 | |
105 | +div.file-manager | |
103 | 106 | div.file-manager-button { |
104 | 107 | float: left; |
105 | 108 | width: 140px; |
... | ... | @@ -108,9 +111,12 @@ div.file-manager-button { |
108 | 111 | margin-top: 0.5em; |
109 | 112 | } |
110 | 113 | |
114 | +div.file-manager | |
111 | 115 | div.file-manager-button a img { |
112 | 116 | border: none; |
113 | 117 | } |
118 | + | |
119 | +div.file-manager | |
114 | 120 | div.file-manager-button a { |
115 | 121 | border: 1px solid #e0e0e0; |
116 | 122 | display: block; |
... | ... | @@ -118,8 +124,39 @@ div.file-manager-button a { |
118 | 124 | height: 80px; |
119 | 125 | overflow: hidden; |
120 | 126 | } |
127 | + | |
128 | +div.file-manager | |
121 | 129 | div.file-manager-button a:hover { |
122 | 130 | border: 1px solid #006; |
123 | 131 | background: #acf; |
124 | 132 | color: #006; |
125 | 133 | } |
134 | + | |
135 | +/************* file manager (small) style *****************/ | |
136 | +div.file-manager-small li { | |
137 | + list-style: none; | |
138 | +} | |
139 | + | |
140 | +div.file-manager-small | |
141 | +div.file-manager-button a div { | |
142 | + display: inline; | |
143 | +} | |
144 | + | |
145 | +div.file-manager-small | |
146 | +div.file-manager-button a img { | |
147 | + border: none; | |
148 | + vertical-align: middle; | |
149 | +} | |
150 | + | |
151 | +div.file-manager-small | |
152 | +div.file-manager-button a { | |
153 | + border: 1px solid transparent; | |
154 | +} | |
155 | + | |
156 | +div.file-manager-small | |
157 | +div.file-manager-button a:hover { | |
158 | + border: 1px solid #006; | |
159 | + background: #acf; | |
160 | + color: #006; | |
161 | +} | |
162 | + | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -5,20 +5,40 @@ require 'cms_controller' |
5 | 5 | class CmsController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class CmsControllerTest < Test::Unit::TestCase |
8 | + | |
9 | + fixtures :environments | |
10 | + | |
8 | 11 | def setup |
9 | 12 | @controller = CmsController.new |
10 | 13 | @request = ActionController::TestRequest.new |
11 | 14 | @response = ActionController::TestResponse.new |
15 | + | |
16 | + @profile = create_user('testinguser').person | |
12 | 17 | end |
13 | 18 | |
14 | 19 | attr_reader :profile |
15 | 20 | |
16 | 21 | should 'list top level documents on index' do |
17 | - flunk 'not yet' | |
22 | + get :index, :profile => profile.identifier | |
23 | + | |
24 | + assert_template 'view' | |
25 | + assert_equal profile, assigns(:profile) | |
26 | + assert_nil assigns(:article) | |
27 | + assert_kind_of Array, assigns(:subitems) | |
18 | 28 | end |
19 | 29 | |
20 | 30 | should 'be able to view a particular document' do |
21 | - flunk 'not yet' | |
31 | + | |
32 | + a = profile.articles.build(:name => 'blablabla') | |
33 | + a.save! | |
34 | + | |
35 | + get :view, :profile => profile.identifier, :id => a.id | |
36 | + | |
37 | + assert_template 'view' | |
38 | + assert_equal a, assigns(:article) | |
39 | + assert_equal [], assigns(:subitems) | |
40 | + | |
41 | + assert_kind_of Array, assigns(:subitems) | |
22 | 42 | end |
23 | 43 | |
24 | 44 | should 'be able to edit a document' do |
... | ... | @@ -29,4 +49,8 @@ class CmsControllerTest < Test::Unit::TestCase |
29 | 49 | flunk 'not yet' |
30 | 50 | end |
31 | 51 | |
52 | + should 'be able to set home page' do | |
53 | + flunk 'pending' | |
54 | + end | |
55 | + | |
32 | 56 | end | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -46,11 +46,17 @@ class ProfileTest < Test::Unit::TestCase |
46 | 46 | end |
47 | 47 | end |
48 | 48 | |
49 | - def test_should_provide_access_to_homepage | |
49 | + should 'provide access to home page' do | |
50 | 50 | profile = Profile.create!(:identifier => 'newprofile', :name => 'New Profile') |
51 | - page = profile.homepage | |
52 | - assert_kind_of Article, page | |
53 | - assert_equal profile.identifier, page.slug | |
51 | + assert_nil profile.home_page | |
52 | + | |
53 | + page = profile.articles.build(:name => "My custom home page") | |
54 | + page.save! | |
55 | + | |
56 | + profile.home_page = page | |
57 | + profile.save! | |
58 | + | |
59 | + assert_equal page, profile.home_page | |
54 | 60 | end |
55 | 61 | |
56 | 62 | def test_name_should_be_mandatory |
... | ... | @@ -107,37 +113,11 @@ class ProfileTest < Test::Unit::TestCase |
107 | 113 | end |
108 | 114 | |
109 | 115 | def test_should_provide_recent_documents |
110 | - profile = Profile.create!(:name => 'Testing Recent documents', :identifier => 'testing_recent_documents') | |
111 | - doc1 = Article.new(:name => 'document 1', :body => 'la la la la la') | |
112 | - doc1.parent = profile.homepage | |
113 | - doc1.save! | |
114 | - | |
115 | - doc2 = Article.new(:name => 'document 2', :body => 'la la la la la') | |
116 | - doc2.parent = profile.homepage | |
117 | - doc2.save! | |
118 | - | |
119 | - docs = profile.recent_documents(2) | |
120 | - assert_equal 2, docs.size | |
121 | - assert docs.map(&:id).include?(doc1.id) | |
122 | - assert docs.map(&:id).include?(doc2.id) | |
116 | + flunk 'pending' | |
123 | 117 | end |
124 | 118 | |
125 | 119 | def test_should_provide_most_recent_documents |
126 | - profile = Profile.create!(:name => 'Testing Recent documents', :identifier => 'testing_recent_documents') | |
127 | - doc1 = Article.new(:name => 'document 1', :body => 'la la la la la') | |
128 | - doc1.parent = profile.homepage | |
129 | - doc1.save! | |
130 | - | |
131 | - docs = profile.recent_documents(1) | |
132 | - assert_equal 1, docs.size | |
133 | - assert_equal doc1.id, docs.first.id | |
134 | - end | |
135 | - | |
136 | - should 'provide a contact_email method which returns a ... contact email address' do | |
137 | - p = Profile.create!(:name => 'Profile for testing ', :identifier => 'profilefortesting') | |
138 | - assert_nil p.contact_email | |
139 | - p.user = User.new(:email => 'testprofile@example.com') | |
140 | - assert_equal 'testprofile@example.com', p.contact_email | |
120 | + flunk 'pending' | |
141 | 121 | end |
142 | 122 | |
143 | 123 | should 'affiliate and provide a list of the affiliated users' do | ... | ... |