wiki base sceleton
This commit is contained in:
parent
df27ec29f3
commit
eacea15a21
20 changed files with 432 additions and 0 deletions
61
app/controllers/wikis_controller.rb
Normal file
61
app/controllers/wikis_controller.rb
Normal file
|
@ -0,0 +1,61 @@
|
|||
class WikisController < ApplicationController
|
||||
before_filter :project
|
||||
layout "project"
|
||||
respond_to :html
|
||||
|
||||
def show
|
||||
@wiki = @project.wikis.find_by_slug(params[:id])
|
||||
respond_with(@wiki)
|
||||
end
|
||||
|
||||
def new
|
||||
@wiki = Wiki.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @wiki }
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@wiki = Wiki.find(params[:id])
|
||||
end
|
||||
|
||||
def create
|
||||
@wiki = Wiki.new(params[:wiki])
|
||||
|
||||
respond_to do |format|
|
||||
if @wiki.save
|
||||
format.html { redirect_to @wiki, notice: 'Wiki was successfully created.' }
|
||||
format.json { render json: @wiki, status: :created, location: @wiki }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @wiki.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@wiki = Wiki.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @wiki.update_attributes(params[:wiki])
|
||||
format.html { redirect_to @wiki, notice: 'Wiki was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @wiki.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@wiki = Wiki.find(params[:id])
|
||||
@wiki.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to wikis_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -12,6 +12,7 @@ class Project < ActiveRecord::Base
|
|||
has_many :deploy_keys, :dependent => :destroy, :foreign_key => "project_id", :class_name => "Key"
|
||||
has_many :web_hooks, :dependent => :destroy
|
||||
has_many :protected_branches, :dependent => :destroy
|
||||
has_many :wikis, :dependent => :destroy
|
||||
|
||||
acts_as_taggable
|
||||
|
||||
|
|
20
app/models/wiki.rb
Normal file
20
app/models/wiki.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
class Wiki < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
|
||||
validates :content, :title, :presence => true
|
||||
validates :title, :length => 1..250,
|
||||
:uniqueness => {:scope => :project_id, :case_sensitive => false}
|
||||
|
||||
before_save :set_slug
|
||||
|
||||
|
||||
def to_param
|
||||
slug
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_slug
|
||||
self.slug = self.title.parameterize
|
||||
end
|
||||
end
|
|
@ -11,6 +11,7 @@
|
|||
- if @project.issues_enabled
|
||||
= link_to project_issues_filter_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do
|
||||
Issues
|
||||
|
||||
- if @project.merge_requests_enabled
|
||||
= link_to project_merge_requests_path(@project), :class => (controller.controller_name == "merge_requests") ? "current" : nil do
|
||||
Merge Requests
|
||||
|
@ -18,3 +19,7 @@
|
|||
- if @project.wall_enabled
|
||||
= link_to wall_project_path(@project), :class => current_page?(:controller => "projects", :action => "wall", :id => @project) ? "current" : nil do
|
||||
Wall
|
||||
|
||||
- if @project.wiki_enabled
|
||||
-#= link_to project_wikis_path(@project), :class => current_page?(:controller => "projects", :action => "wiki", :id => @project) ? "current" : nil do
|
||||
Wiki
|
||||
|
|
|
@ -41,6 +41,10 @@
|
|||
.clearfix
|
||||
= f.label :wall_enabled, "Wall"
|
||||
.input= f.check_box :wall_enabled
|
||||
|
||||
.clearfix
|
||||
= f.label :wiki_enabled, "Wiki"
|
||||
.input= f.check_box :wiki_enabled
|
||||
|
||||
.clearfix
|
||||
= f.label :description
|
||||
|
|
16
app/views/wikis/_form.html.haml
Normal file
16
app/views/wikis/_form.html.haml
Normal file
|
@ -0,0 +1,16 @@
|
|||
= form_for @wiki do |f|
|
||||
-if @wiki.errors.any?
|
||||
#error_explanation
|
||||
%h2= "#{pluralize(@wiki.errors.count, "error")} prohibited this wiki from being saved:"
|
||||
%ul
|
||||
- @wiki.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.field
|
||||
= f.label :title
|
||||
= f.text_field :title
|
||||
.field
|
||||
= f.label :content
|
||||
= f.text_area :content
|
||||
.actions
|
||||
= f.submit 'Save'
|
7
app/views/wikis/edit.html.haml
Normal file
7
app/views/wikis/edit.html.haml
Normal file
|
@ -0,0 +1,7 @@
|
|||
%h1 Editing wiki
|
||||
|
||||
= render 'form'
|
||||
|
||||
= link_to 'Show', @wiki
|
||||
\|
|
||||
= link_to 'Back', wikis_path
|
21
app/views/wikis/index.html.haml
Normal file
21
app/views/wikis/index.html.haml
Normal file
|
@ -0,0 +1,21 @@
|
|||
%h1 Listing wikis
|
||||
|
||||
%table
|
||||
%tr
|
||||
%th Title
|
||||
%th Content
|
||||
%th
|
||||
%th
|
||||
%th
|
||||
|
||||
- @wikis.each do |wiki|
|
||||
%tr
|
||||
%td= wiki.title
|
||||
%td= wiki.content
|
||||
%td= link_to 'Show', wiki
|
||||
%td= link_to 'Edit', edit_wiki_path(wiki)
|
||||
%td= link_to 'Destroy', wiki, :confirm => 'Are you sure?', :method => :delete
|
||||
|
||||
%br
|
||||
|
||||
= link_to 'New Wiki', new_wiki_path
|
5
app/views/wikis/new.html.haml
Normal file
5
app/views/wikis/new.html.haml
Normal file
|
@ -0,0 +1,5 @@
|
|||
%h1 New wiki
|
||||
|
||||
= render 'form'
|
||||
|
||||
= link_to 'Back', wikis_path
|
7
app/views/wikis/show.html.haml
Normal file
7
app/views/wikis/show.html.haml
Normal file
|
@ -0,0 +1,7 @@
|
|||
%p#notice= notice
|
||||
|
||||
%h3= @wiki.title
|
||||
= @wiki.content
|
||||
|
||||
%br
|
||||
= link_to 'Edit', edit_project_wiki_path(@project, @wiki)
|
Loading…
Add table
Add a link
Reference in a new issue