diff --git a/app/assets/stylesheets/style.css b/app/assets/stylesheets/style.css index 0bf628d7a2..a13cb906be 100644 --- a/app/assets/stylesheets/style.css +++ b/app/assets/stylesheets/style.css @@ -256,7 +256,7 @@ a .fa-white, color: #666; clear:both; margin-top: 40px; - padding: 30px; + padding: 30px !important; border-top: 1px solid #E5E5E5; background-color: #f8f8f8; } diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 7aefcbb6dd..5c99117c68 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -5,7 +5,8 @@ def home if current_user redirect_to '/dashboard' else - blog + @projects = Tag.find_nodes_by_type('project:featured', 'page') + .sample(3) # random sampling @title = I18n.t('home_controller.science_community') render template: 'home/home' end @@ -13,7 +14,8 @@ def home # route for seeing the front page even if you are logged in def front - blog + @projects = Tag.find_nodes_by_type('project:featured', 'page') + .sample(3) # random sampling @title = I18n.t('home_controller.environmental_investigation') render template: 'home/home' @unpaginated = true diff --git a/app/models/node.rb b/app/models/node.rb index 950978f277..b4cc1c5280 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -275,15 +275,14 @@ def author User.find(uid) end - def coauthors - User.where(username: power_tags('with')) if has_power_tag('with') - end - - # for wikis: def authors revisions.collect(&:author).uniq end + def coauthors + User.where(username: power_tags('with')) if has_power_tag('with') + end + # tag- and node-based followers def subscribers(conditions = false) users = TagSelection.where(tid: tags.collect(&:tid)) @@ -312,6 +311,10 @@ def body latest&.body end + def summary + body.split('\n')&.first + end + # was unable to set up this relationship properly with ActiveRecord associations def drupal_main_image DrupalMainImage.order('vid') diff --git a/app/views/home/home.html.erb b/app/views/home/home.html.erb index 896fdda04b..5ce0f302fa 100644 --- a/app/views/home/home.html.erb +++ b/app/views/home/home.html.erb @@ -1,18 +1,119 @@ -
- <% cache('feature_home-intro', skip_digest: true) do %> <%= feature("home-intro") %> <% end %> -
- <% cache('home-blog', expires_in: 60.minutes, skip_digest: true) do %> -
- <% unless @notes.nil? || @notes.length == 0 %> - <%= render partial: "notes/notes", locals: { paginated: false } %> -

Read more

+
+ +
+ <% #cache('home-blog', expires_in: 60.minutes, skip_digest: true) do %> + <% unless @projects.nil? || @projects.length == 0 %> + + <% @projects.each_with_index do |project, index| %> + +
"> +
"> + + + +
+
"> + +

<%= project.title %>

+ +

<%= project.summary %>

+ +

Read more »

+ +
+ + + +
+ +
+
+ <% end %> -
- <% end %> + +

More projects

+ + <% end %> + <% # end %>
+ + + +<% cache('feature_home-footer', skip_digest: true) do %> + <%= feature("home-footer") %> +<% end %> + diff --git a/public/photos/original/missing.png b/public/photos/original/missing.png new file mode 100644 index 0000000000..0855f90c41 Binary files /dev/null and b/public/photos/original/missing.png differ diff --git a/test/fixtures/node_tags.yml b/test/fixtures/node_tags.yml index 4f1468e359..674ab1df28 100644 --- a/test/fixtures/node_tags.yml +++ b/test/fixtures/node_tags.yml @@ -189,3 +189,13 @@ test3_lon: uid: 16 nid: 25 date: <%= DateTime.now.to_i %> + +project: + tid: 28 + uid: 1 + nid: 13 + +project2: + tid: 28 + uid: 1 + nid: 7 diff --git a/test/fixtures/tags.yml b/test/fixtures/tags.yml index c6c66b818b..bde654e051 100644 --- a/test/fixtures/tags.yml +++ b/test/fixtures/tags.yml @@ -107,3 +107,7 @@ balloon: place: tid: 27 name: place + +project: + tid: 28 + name: project diff --git a/test/unit/node_test.rb b/test/unit/node_test.rb index d3eb32e31a..71c7e79189 100644 --- a/test/unit/node_test.rb +++ b/test/unit/node_test.rb @@ -15,6 +15,8 @@ def setup assert_equal 1, node.status assert !node.answered assert_equal [], node.location_tags + assert node.body + assert node.summary end test 'basic question attributes' do @@ -513,6 +515,13 @@ def setup # assert_equal wiki, graph_wiki.values.sum end + # node.authors should be anyone who's written a revision for this node (a wiki, presumably) + test 'authors' do + authors = Node.last.authors + assert authors + assert_equal 1, authors.length + end + test 'find by tagname and user id' do # Should test for each type of node: wiki, notes, questions assert_equal 'Chicago', Node.find_by_tag_and_author('chapter', 1, 'wiki').first.title