diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index df61cc81c5d372caa0a577a617a75e9e1b5f26a1..841b4307886cdf24f479598b0211bf9701ce99bd 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -65,4 +65,6 @@ $hover: #FDF5D9; @import "highlight.css.scss"; @import "highlight.black.css.scss"; +@import "wiki.scss"; + diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index b54e12c87427d0baf6bd6ae19d6ab2043302f11a..487925db7af92fbd926e529da7ccc968df4d23bd 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -221,3 +221,7 @@ input.git_clone_url { width:270px; background:#fff !important; } + +.span12 hr{ + margin-top: 2px; +} diff --git a/app/assets/stylesheets/wiki.scss b/app/assets/stylesheets/wiki.scss new file mode 100644 index 0000000000000000000000000000000000000000..acc37b969fd92e691661901e881fd57f71cd52cc --- /dev/null +++ b/app/assets/stylesheets/wiki.scss @@ -0,0 +1,5 @@ +p.time { + color: #999; + font-size: 90%; + margin: 30px 3px 3px 2px; +} diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb index 9a1638f2e4afd29b8957079a3c8769594ba01b52..544f98872586feea8026a904146fce82333d8b32 100644 --- a/app/controllers/wikis_controller.rb +++ b/app/controllers/wikis_controller.rb @@ -42,11 +42,10 @@ class WikisController < ApplicationController end def destroy - @wiki = @project.wikis.find(params[:id]) - @wiki.destroy + @wikis = @project.wikis.where(:slug => params[:id]).delete_all respond_to do |format| - format.html { redirect_to wikis_url } + format.html { redirect_to project_wiki_path(@project, :index), notice: "Page was successfully deleted" } end end end diff --git a/app/helpers/wikis_helper.rb b/app/helpers/wikis_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..0c24f57add6025ab6bf8306be1a50e5a74608b5a --- /dev/null +++ b/app/helpers/wikis_helper.rb @@ -0,0 +1,5 @@ +module WikisHelper + def markdown_to_html(text) + RDiscount.new(text).to_html.html_safe + end +end diff --git a/app/views/wikis/show.html.haml b/app/views/wikis/show.html.haml index 5a4b904534e8804a9332dfea2d4ec13a28302bb4..63a166fe88828bfa48bb97aa9426fd9b6f0f6469 100644 --- a/app/views/wikis/show.html.haml +++ b/app/views/wikis/show.html.haml @@ -1,9 +1,15 @@ %h3 = @wiki.title + = link_to edit_project_wiki_path(@project, @wiki), :class => "right btn small" do + Edit - if can? current_user, :write_wiki, @project = link_to history_project_wiki_path(@project, @wiki), :class => "right btn small" do History - = link_to edit_project_wiki_path(@project, @wiki), :class => "right btn small" do - Edit +%hr -= markdown @wiki.content += markdown_to_html @wiki.content + +%p.time Last edited by #{@wiki.user.name}, in #{time_ago_in_words @wiki.created_at} +- if can? current_user, :write_wiki, @project + = link_to project_wiki_path(@project, @wiki), :confirm => "Are you sure you want to delete this page?", :method => :delete do + Delete this page diff --git a/config/routes.rb b/config/routes.rb index eae5b7ea1c9e7709ebca6c5a9b9c611b04053660..653ec0892663d8e89db4d56194fdcfddb3065d9b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -58,7 +58,7 @@ Gitlab::Application.routes.draw do resources :wikis, :only => [:show, :edit, :destroy, :create] do member do - get "history" + get "history" end end diff --git a/db/schema.rb b/db/schema.rb index c32df7ea198fa4beb9e2916f09358f0d76c8ea7d..cf4b226c9107d0e9569b6b8bb59054f8d880e885 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -159,6 +159,20 @@ ActiveRecord::Schema.define(:version => 20120219193300) do t.datetime "updated_at" end + create_table "wiki_pages", :force => true do |t| + t.string "slug" + t.string "title" + t.text "content" + t.integer "author_id" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "wiki_pages", ["author_id"], :name => "index_wiki_pages_on_author_id" + add_index "wiki_pages", ["project_id"], :name => "index_wiki_pages_on_project_id" + add_index "wiki_pages", ["slug"], :name => "index_wiki_pages_on_slug", :unique => true + create_table "wikis", :force => true do |t| t.string "title" t.text "content"