Commit e92f1ea43d286298d7ed0bd0b448b9b04dd5047a
- Date: Mon Apr 28 05:37:04 +0000 2008
- Committer: mtkd (mtkd@prj2.com)
- Author: mtkd (mtkd@prj2.com)
- Commit SHA1: e92f1ea43d286298d7ed0bd0b448b9b04dd5047a
- Tree SHA1: 2cb765de25a5d0f28c4da0e1813daa65e3f45f89
Increase wiki view count
Wiki tweaks
Commit diff
| |   |
| 4 | 4 | class ArticlesController < ApplicationController |
| 5 | 5 | |
| 6 | 6 | after_filter :after_article |
| 7 | | |
| 8 | 7 | |
| 9 | 8 | # Show all articles, render grouped by year, month |
| 10 | 9 | def index |
| toggle raw diff |
--- a/app/controllers/articles_controller.rb
+++ b/app/controllers/articles_controller.rb
@@ -4,7 +4,6 @@
class ArticlesController < ApplicationController
after_filter :after_article
-
# Show all articles, render grouped by year, month
def index |
| |   |
| 1 | 1 | class WikisController < ApplicationController |
| 2 | |
| 3 | after_filter :after_wiki |
| 2 | 4 | |
| 3 | 5 | def index |
| 4 | 6 | if params[:project_id] != nil |
| … | … | |
| 174 | 174 | def to_slug(s) |
| 175 | 175 | s.gsub(/\W+/, ' ').strip.downcase.gsub(/\ +/, '-') |
| 176 | 176 | end |
| 177 | |
| 178 | |
| 179 | protected |
| 180 | |
| 181 | # Increase view count for a wiki page |
| 182 | def after_wiki |
| 183 | if action_name == "show" and @wiki != nil then |
| 184 | @wiki.views = @wiki.views + 1 |
| 185 | @wiki.save! |
| 186 | end |
| 187 | end |
| 188 | |
| 177 | 189 | |
| 178 | 190 | end |
| 179 | 191 | |
| toggle raw diff |
--- a/app/controllers/wikis_controller.rb
+++ b/app/controllers/wikis_controller.rb
@@ -1,4 +1,6 @@
class WikisController < ApplicationController
+
+ after_filter :after_wiki
def index
if params[:project_id] != nil
@@ -172,6 +174,18 @@ class WikisController < ApplicationController
def to_slug(s)
s.gsub(/\W+/, ' ').strip.downcase.gsub(/\ +/, '-')
end
+
+
+protected
+
+ # Increase view count for a wiki page
+ def after_wiki
+ if action_name == "show" and @wiki != nil then
+ @wiki.views = @wiki.views + 1
+ @wiki.save!
+ end
+ end
+
end
|
| |   |
| 9 | 9 | |
| 10 | 10 | <tr> |
| 11 | 11 | <th width='<%= STYLE_TABLE_COL_WIDTH_ID %>'>ID</th> |
| 12 | | <th>Title</th> |
| 12 | <th><%= @project.title %> Wiki Pages</th> |
| 13 | 13 | <% if @member %> |
| 14 | 14 | <th width='100'>Status</th> |
| 15 | | <th width='100'>Format</th> |
| 16 | 15 | <th width='180'>Slug</th> |
| 17 | 16 | <% end %> |
| 17 | <th width='80'>Views</th> |
| 18 | <th width='100'>Format</th> |
| 18 | 19 | <th width='<%= STYLE_TABLE_COL_WIDTH_DDMMYYHHMM %>'>Created</th> |
| 19 | 20 | <% if @member %> |
| 20 | 21 | <th colspan='2' width='<%= STYLE_TABLE_COL_WIDTH_ACTION_SHORT.to_i * 2 %>'></th> |
| … | … | |
| 28 | 28 | <td><%= link_to wiki.title, project_wiki_path(@project.slug, wiki.slug) %></td> |
| 29 | 29 | <% if @member %> |
| 30 | 30 | <td><%= wiki.status.to_s.capitalize %></td> |
| 31 | | <td><%= wiki.format.to_s.capitalize %></td> |
| 32 | 31 | <td>/<%= wiki.slug %></td> |
| 33 | 32 | <% end %> |
| 33 | <td><%= wiki.views.to_s %></td> |
| 34 | <td><%= wiki.format.to_s.capitalize %></td> |
| 34 | 35 | <td><%= format_datetime_ddmmyyhhmm(wiki.created_at) %></td> |
| 35 | 36 | <% if @member %> |
| 36 | 37 | <td>Edit</td> |
| toggle raw diff |
--- a/app/views/wikis/ac_project_index.html.erb
+++ b/app/views/wikis/ac_project_index.html.erb
@@ -9,12 +9,13 @@
<tr>
<th width='<%= STYLE_TABLE_COL_WIDTH_ID %>'>ID</th>
- <th>Title</th>
+ <th><%= @project.title %> Wiki Pages</th>
<% if @member %>
<th width='100'>Status</th>
- <th width='100'>Format</th>
<th width='180'>Slug</th>
<% end %>
+ <th width='80'>Views</th>
+ <th width='100'>Format</th>
<th width='<%= STYLE_TABLE_COL_WIDTH_DDMMYYHHMM %>'>Created</th>
<% if @member %>
<th colspan='2' width='<%= STYLE_TABLE_COL_WIDTH_ACTION_SHORT.to_i * 2 %>'></th>
@@ -27,9 +28,10 @@
<td><%= link_to wiki.title, project_wiki_path(@project.slug, wiki.slug) %></td>
<% if @member %>
<td><%= wiki.status.to_s.capitalize %></td>
- <td><%= wiki.format.to_s.capitalize %></td>
<td>/<%= wiki.slug %></td>
<% end %>
+ <td><%= wiki.views.to_s %></td>
+ <td><%= wiki.format.to_s.capitalize %></td>
<td><%= format_datetime_ddmmyyhhmm(wiki.created_at) %></td>
<% if @member %>
<td>Edit</td> |
| |   |
| 1 | | <p>Fanatical about speed, underwhelmed by the usability of existing hosted tools, and tired of multiple logins, I decided to mash together a site using OSS.</p> |
| 1 | <p>Underwhelmed by the usability of existing hosted tools, and tired of multiple logins, I decided to mash together a site using OSS.</p> |
| 2 | 2 | <p>Two weeks later it was clear splicing together Wordpress, Wikimedia etc. was just moving the problem, so I started to code a new app from scratch - that could share a login and share a model.</p> |
| 3 | 3 | <p>The key requirements were:</p> |
| 4 | 4 | <ul> |
| toggle raw diff |
--- a/test/fixtures/article_bodies/_gitlab-dev-team-collaboration.txt
+++ b/test/fixtures/article_bodies/_gitlab-dev-team-collaboration.txt
@@ -1,4 +1,4 @@
-<p>Fanatical about speed, underwhelmed by the usability of existing hosted tools, and tired of multiple logins, I decided to mash together a site using OSS.</p>
+<p>Underwhelmed by the usability of existing hosted tools, and tired of multiple logins, I decided to mash together a site using OSS.</p>
<p>Two weeks later it was clear splicing together Wordpress, Wikimedia etc. was just moving the problem, so I started to code a new app from scratch - that could share a login and share a model.</p>
<p>The key requirements were:</p>
<ul> |
| |   |
| 1 | | <p>The project has been renamed to Gitlab (it's more meaningful and the domain was available), it will be hosted on the <a href='http://www.itlab.org'>gitlab.org</a> domain.</p> |
| 1 | <p>The <a href='http://www.gitlab.org/projects/gitlab'>project</a> has been renamed to Gitlab (it's more meaningful and the domain was available), it will be hosted on the <a href='http://www.itlab.org'>gitlab.org</a> domain.</p> |
| 2 | 2 | |
| 3 | | <p>I will probably fork the project from Gitorious this week and stop updating. Gitorious is about to add Krawek's events changes which |
| 3 | <p>I will probably fork the project from <a href='http://gitorious.org'>Gitorious</a> this week and stop updating. Gitorious is about to add Krawek's events changes which |
| 4 | 4 | conflict with events in Gitlab (also I'm now using different comment and project membership models so it's getting harder |
| 5 | 5 | to merge).</p> |
| 6 | 6 | |
| toggle raw diff |
--- a/test/fixtures/article_bodies/_gitlab-renamed-and-forked.txt
+++ b/test/fixtures/article_bodies/_gitlab-renamed-and-forked.txt
@@ -1,6 +1,6 @@
-<p>The project has been renamed to Gitlab (it's more meaningful and the domain was available), it will be hosted on the <a href='http://www.itlab.org'>gitlab.org</a> domain.</p>
+<p>The <a href='http://www.gitlab.org/projects/gitlab'>project</a> has been renamed to Gitlab (it's more meaningful and the domain was available), it will be hosted on the <a href='http://www.itlab.org'>gitlab.org</a> domain.</p>
-<p>I will probably fork the project from Gitorious this week and stop updating. Gitorious is about to add Krawek's events changes which
+<p>I will probably fork the project from <a href='http://gitorious.org'>Gitorious</a> this week and stop updating. Gitorious is about to add Krawek's events changes which
conflict with events in Gitlab (also I'm now using different comment and project membership models so it's getting harder
to merge).</p>
|
| |   |
| 5 | 5 | |
| 6 | 6 | A005: |
| 7 | 7 | id: 5 |
| 8 | | title: "Renamed and forked" |
| 8 | title: "Renamed and Forked" |
| 9 | 9 | body: "<%= File.open("#{RAILS_ROOT}/test/fixtures/article_bodies/_gitlab-renamed-and-forked.txt",'r').read %>" |
| 10 | 10 | body_summary: "<%= File.open("#{RAILS_ROOT}/test/fixtures/article_bodies/_gitlab-renamed-and-forked.txt",'r').read %>" |
| 11 | 11 | article_type: :news |
| toggle raw diff |
--- a/test/fixtures/articles.yml
+++ b/test/fixtures/articles.yml
@@ -5,7 +5,7 @@
A005:
id: 5
- title: "Renamed and forked"
+ title: "Renamed and Forked"
body: "<%= File.open("#{RAILS_ROOT}/test/fixtures/article_bodies/_gitlab-renamed-and-forked.txt",'r').read %>"
body_summary: "<%= File.open("#{RAILS_ROOT}/test/fixtures/article_bodies/_gitlab-renamed-and-forked.txt",'r').read %>"
article_type: :news |