Commit bdc42488e9b0d297e0773040e077f414b6605c3d

Authored by vsizov
1 parent 2e1f119f

wiki is done

app/assets/stylesheets/main.scss
... ... @@ -65,4 +65,6 @@ $hover: #FDF5D9;
65 65 @import "highlight.css.scss";
66 66 @import "highlight.black.css.scss";
67 67  
  68 +@import "wiki.scss";
  69 +
68 70  
... ...
app/assets/stylesheets/projects.css.scss
... ... @@ -221,3 +221,7 @@ input.git_clone_url {
221 221 width:270px;
222 222 background:#fff !important;
223 223 }
  224 +
  225 +.span12 hr{
  226 + margin-top: 2px;
  227 +}
... ...
app/assets/stylesheets/wiki.scss 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +p.time {
  2 + color: #999;
  3 + font-size: 90%;
  4 + margin: 30px 3px 3px 2px;
  5 +}
... ...
app/controllers/wikis_controller.rb
... ... @@ -42,11 +42,10 @@ class WikisController < ApplicationController
42 42 end
43 43  
44 44 def destroy
45   - @wiki = @project.wikis.find(params[:id])
46   - @wiki.destroy
  45 + @wikis = @project.wikis.where(:slug => params[:id]).delete_all
47 46  
48 47 respond_to do |format|
49   - format.html { redirect_to wikis_url }
  48 + format.html { redirect_to project_wiki_path(@project, :index), notice: "Page was successfully deleted" }
50 49 end
51 50 end
52 51 end
... ...
app/helpers/wikis_helper.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +module WikisHelper
  2 + def markdown_to_html(text)
  3 + RDiscount.new(text).to_html.html_safe
  4 + end
  5 +end
... ...
app/views/wikis/show.html.haml
1 1 %h3
2 2 = @wiki.title
  3 + = link_to edit_project_wiki_path(@project, @wiki), :class => "right btn small" do
  4 + Edit
3 5 - if can? current_user, :write_wiki, @project
4 6 = link_to history_project_wiki_path(@project, @wiki), :class => "right btn small" do
5 7 History
6   - = link_to edit_project_wiki_path(@project, @wiki), :class => "right btn small" do
7   - Edit
  8 +%hr
8 9  
9   -= markdown @wiki.content
  10 += markdown_to_html @wiki.content
  11 +
  12 +%p.time Last edited by #{@wiki.user.name}, in #{time_ago_in_words @wiki.created_at}
  13 +- if can? current_user, :write_wiki, @project
  14 + = link_to project_wiki_path(@project, @wiki), :confirm => "Are you sure you want to delete this page?", :method => :delete do
  15 + Delete this page
... ...
config/routes.rb
... ... @@ -58,7 +58,7 @@ Gitlab::Application.routes.draw do
58 58  
59 59 resources :wikis, :only => [:show, :edit, :destroy, :create] do
60 60 member do
61   - get "history"
  61 + get "history"
62 62 end
63 63 end
64 64  
... ...
db/schema.rb
... ... @@ -159,6 +159,20 @@ ActiveRecord::Schema.define(:version => 20120219193300) do
159 159 t.datetime "updated_at"
160 160 end
161 161  
  162 + create_table "wiki_pages", :force => true do |t|
  163 + t.string "slug"
  164 + t.string "title"
  165 + t.text "content"
  166 + t.integer "author_id"
  167 + t.integer "project_id"
  168 + t.datetime "created_at"
  169 + t.datetime "updated_at"
  170 + end
  171 +
  172 + add_index "wiki_pages", ["author_id"], :name => "index_wiki_pages_on_author_id"
  173 + add_index "wiki_pages", ["project_id"], :name => "index_wiki_pages_on_project_id"
  174 + add_index "wiki_pages", ["slug"], :name => "index_wiki_pages_on_slug", :unique => true
  175 +
162 176 create_table "wikis", :force => true do |t|
163 177 t.string "title"
164 178 t.text "content"
... ...