wiki page work
This commit is contained in:
@@ -1,6 +1,14 @@
|
|||||||
class WikiPageVersionsController < ApplicationController
|
class WikiPageVersionsController < ApplicationController
|
||||||
|
respond_to :json, :html, :xml
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@search = WikiPageVersion.search(params[:search])
|
@search = WikiPageVersion.search(params[:search])
|
||||||
@wiki_page_versions = @search.paginate(:page => params[:page])
|
@wiki_page_versions = @search.paginate(:page => params[:page])
|
||||||
|
respond_with(@wiki_page_versions)
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@wiki_page_version = WikiPageVersion.find(params[:id])
|
||||||
|
respond_with(@wiki_page_version)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class WikiPagesController < ApplicationController
|
class WikiPagesController < ApplicationController
|
||||||
respond_to :html, :xml, :json
|
respond_to :html, :xml, :json, :js
|
||||||
before_filter :member_only, :except => [:index, :show]
|
before_filter :member_only, :except => [:index, :show]
|
||||||
before_filter :moderator_only, :only => [:destroy]
|
before_filter :moderator_only, :only => [:destroy]
|
||||||
before_filter :normalize_search_params, :only => [:index]
|
before_filter :normalize_search_params, :only => [:index]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class WikiPageVersion < ActiveRecord::Base
|
class WikiPageVersion < ActiveRecord::Base
|
||||||
belongs_to :wiki_page
|
belongs_to :wiki_page
|
||||||
belongs_to :updater
|
belongs_to :updater, :class_name => "User"
|
||||||
|
|
||||||
def updater_name
|
def updater_name
|
||||||
User.id_to_name(updater_id)
|
User.id_to_name(updater_id)
|
||||||
|
|||||||
@@ -1,70 +1,36 @@
|
|||||||
<%= render :partial => "sidebar" %>
|
<div id="c-wiki-pages">
|
||||||
|
<div id="a-index">
|
||||||
|
<%= render :partial => "wiki_pages/sidebar" %>
|
||||||
|
|
||||||
<div class="content">
|
<section id="content">
|
||||||
<% form_tag({:action => "diff"}, :method => :get) do %>
|
<table width="100%">
|
||||||
<%= hidden_field_tag "title", params[:title] %>
|
<thead>
|
||||||
|
<tr>
|
||||||
<table width="100%">
|
<th width="60%">Title</th>
|
||||||
<thead>
|
<th width="10%">IP Address</th>
|
||||||
<tr>
|
<th width="30%">Last edited</th>
|
||||||
<th width="5%">From</th>
|
</tr>
|
||||||
<th width="5%">To</th>
|
</thead>
|
||||||
<th width="10%">IP Address</th>
|
<tbody>
|
||||||
<th width="80%">Last edited</th>
|
<% @wiki_page_versions.each do |wiki_page_version| %>
|
||||||
</tr>
|
<tr>
|
||||||
</thead>
|
<td><%= wiki_page_version.title %></td>
|
||||||
<tfoot>
|
<td>
|
||||||
<tr>
|
<% if CurrentUser.is_admin? %>
|
||||||
<td colspan="2"><%= submit_tag "Compare" %></td>
|
<%= wiki_page_version.updater_ip_addr %>
|
||||||
</tr>
|
<% end %>
|
||||||
</tfoot>
|
</td>
|
||||||
<tbody>
|
<td>
|
||||||
<% @wiki_pages.each_with_index do |wiki_page, i| %>
|
<%= link_to wiki_page_version.updated_at.strftime("%m/%d/%Y %I:%M"), wiki_page_version_path(wiki_page_version) %>
|
||||||
<tr class="<%= cycle 'even', 'odd' %>">
|
by
|
||||||
<td><%= radio_button_tag "from", wiki_page.version, i==1, :id => "from_#{wiki_page.version}" %></td>
|
<%= link_to wiki_page_version.updater.name, user_path(wiki_page_version.updater) %>
|
||||||
<td><%= radio_button_tag "to", wiki_page.version, i==0, :id => "to_#{wiki_page.version}" %></td>
|
</td>
|
||||||
<td>
|
</tr>
|
||||||
<% if @current_user.is_admin? %>
|
<% end %>
|
||||||
<%= h wiki_page.ip_addr %>
|
</tbody>
|
||||||
<% end %>
|
</table>
|
||||||
</td>
|
</section>
|
||||||
<td><%= link_to wiki_page.updated_at.strftime("%m/%d/%Y %I:%M"), :action => "show", :title => wiki_page.title, :version => wiki_page.version %> by <%= link_to h(wiki_page.author), :controller => "user", :action => "show", :id => wiki_page.user_id %></td>
|
</div>
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
var from;
|
|
||||||
var to;
|
|
||||||
|
|
||||||
function validateFrom(self)
|
|
||||||
{
|
|
||||||
if(Number(self.value) >= to) return false;
|
|
||||||
from = new Number(self.value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function validateTo(self)
|
|
||||||
{
|
|
||||||
if(Number(self.value) <= from) return false;
|
|
||||||
to = new Number(self.value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(var i=1, elem; i <= <%= @wiki_pages.length %>; i++)
|
|
||||||
{
|
|
||||||
elem = $("from_"+i);
|
|
||||||
elem.onclick = function() {return validateFrom(this);};
|
|
||||||
if(elem.checked) from = i;
|
|
||||||
|
|
||||||
elem = $("to_"+i);
|
|
||||||
elem.onclick = function() {return validateTo(this);};
|
|
||||||
if(elem.checked) to = i;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<%= render :partial => "wiki_pages/secondary_links" %>
|
||||||
<%= render :partial => "footer" %>
|
|
||||||
|
|||||||
15
app/views/wiki_page_versions/show.html.erb
Normal file
15
app/views/wiki_page_versions/show.html.erb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<div id="c-wiki-pages">
|
||||||
|
<div id="a-show">
|
||||||
|
<%= render "wiki_pages/sidebar" %>
|
||||||
|
|
||||||
|
<section id="content">
|
||||||
|
<h1 id="wiki-page-title"><%= @wiki_page_version.pretty_title %> <span class="version">(<%= time_ago_in_words(@wiki_page_version.updated_at) %> ago)</span></h1>
|
||||||
|
|
||||||
|
<div id="wiki-page-body" class="dtext">
|
||||||
|
<%= format_text(@wiki_page_version.body) %>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render "wiki_pages/secondary_links" %>
|
||||||
@@ -14,5 +14,9 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if @wiki_page_version %>
|
||||||
|
<li>|</li>
|
||||||
|
<li><%= link_to "Current", wiki_page_path(@wiki_page_version.wiki_page_id) %></li>
|
||||||
|
<% end %>
|
||||||
</menu>
|
</menu>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -6,5 +6,5 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<%= render "recent_changes" %>
|
<%= render "wiki_pages/recent_changes" %>
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
1
app/views/wiki_pages/destroy.js.erb
Normal file
1
app/views/wiki_pages/destroy.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
window.location.href = "/wiki_pages";
|
||||||
@@ -66,7 +66,7 @@ Danbooru::Application.routes.draw do
|
|||||||
put :revert
|
put :revert
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :wiki_page_versions, :only => [:index]
|
resources :wiki_page_versions, :only => [:index, :show]
|
||||||
|
|
||||||
match '/favorites/:id' => 'favorites#create', :via => :post, :as => "favorite"
|
match '/favorites/:id' => 'favorites#create', :via => :post, :as => "favorite"
|
||||||
match '/favorites/:id' => 'favorites#destroy', :via => :delete, :as => "favorite"
|
match '/favorites/:id' => 'favorites#destroy', :via => :delete, :as => "favorite"
|
||||||
|
|||||||
@@ -396,12 +396,13 @@ div#artists div#show {
|
|||||||
font-style: italic; }
|
font-style: italic; }
|
||||||
|
|
||||||
/*** Wiki Pages ***/
|
/*** Wiki Pages ***/
|
||||||
|
div#c-wiki-pages span.version {
|
||||||
|
color: #AAA; }
|
||||||
|
div#c-wiki-pages h1 {
|
||||||
|
margin-bottom: 0.5em; }
|
||||||
div#c-wiki-pages div#a-edit textarea, div#c-wiki-pages div#a-new textarea {
|
div#c-wiki-pages div#a-edit textarea, div#c-wiki-pages div#a-new textarea {
|
||||||
width: 500px;
|
width: 500px;
|
||||||
height: 40em; }
|
height: 40em; }
|
||||||
div#c-wiki-pages div#a-edit div#preview h1:first-child, div#c-wiki-pages div#a-new div#preview h1:first-child {
|
|
||||||
color: #333;
|
|
||||||
margin-bottom: 0.5em; }
|
|
||||||
|
|
||||||
/*** Users ***/
|
/*** Users ***/
|
||||||
div.users div.new {
|
div.users div.new {
|
||||||
|
|||||||
@@ -665,6 +665,14 @@ div#artists {
|
|||||||
|
|
||||||
/*** Wiki Pages ***/
|
/*** Wiki Pages ***/
|
||||||
div#c-wiki-pages {
|
div#c-wiki-pages {
|
||||||
|
span.version {
|
||||||
|
color: #AAA;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
div#a-edit, div#a-new {
|
div#a-edit, div#a-new {
|
||||||
textarea {
|
textarea {
|
||||||
width: 500px;
|
width: 500px;
|
||||||
@@ -672,10 +680,6 @@ div#c-wiki-pages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div#preview {
|
div#preview {
|
||||||
h1:first-child {
|
|
||||||
color: #333;
|
|
||||||
margin-bottom: 0.5em;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user