wiki page work
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
class WikiPageVersionsController < ApplicationController
|
||||
respond_to :json, :html, :xml
|
||||
|
||||
def index
|
||||
@search = WikiPageVersion.search(params[:search])
|
||||
@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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class WikiPagesController < ApplicationController
|
||||
respond_to :html, :xml, :json
|
||||
respond_to :html, :xml, :json, :js
|
||||
before_filter :member_only, :except => [:index, :show]
|
||||
before_filter :moderator_only, :only => [:destroy]
|
||||
before_filter :normalize_search_params, :only => [:index]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class WikiPageVersion < ActiveRecord::Base
|
||||
belongs_to :wiki_page
|
||||
belongs_to :updater
|
||||
belongs_to :updater, :class_name => "User"
|
||||
|
||||
def updater_name
|
||||
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">
|
||||
<% form_tag({:action => "diff"}, :method => :get) do %>
|
||||
<%= hidden_field_tag "title", params[:title] %>
|
||||
|
||||
<table width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">From</th>
|
||||
<th width="5%">To</th>
|
||||
<th width="10%">IP Address</th>
|
||||
<th width="80%">Last edited</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2"><%= submit_tag "Compare" %></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<% @wiki_pages.each_with_index do |wiki_page, i| %>
|
||||
<tr class="<%= cycle 'even', 'odd' %>">
|
||||
<td><%= radio_button_tag "from", wiki_page.version, i==1, :id => "from_#{wiki_page.version}" %></td>
|
||||
<td><%= radio_button_tag "to", wiki_page.version, i==0, :id => "to_#{wiki_page.version}" %></td>
|
||||
<td>
|
||||
<% if @current_user.is_admin? %>
|
||||
<%= h wiki_page.ip_addr %>
|
||||
<% end %>
|
||||
</td>
|
||||
<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>
|
||||
</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>
|
||||
<section id="content">
|
||||
<table width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="60%">Title</th>
|
||||
<th width="10%">IP Address</th>
|
||||
<th width="30%">Last edited</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @wiki_page_versions.each do |wiki_page_version| %>
|
||||
<tr>
|
||||
<td><%= wiki_page_version.title %></td>
|
||||
<td>
|
||||
<% if CurrentUser.is_admin? %>
|
||||
<%= wiki_page_version.updater_ip_addr %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to wiki_page_version.updated_at.strftime("%m/%d/%Y %I:%M"), wiki_page_version_path(wiki_page_version) %>
|
||||
by
|
||||
<%= link_to wiki_page_version.updater.name, user_path(wiki_page_version.updater) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<%= render :partial => "footer" %>
|
||||
<%= render :partial => "wiki_pages/secondary_links" %>
|
||||
|
||||
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 %>
|
||||
<% if @wiki_page_version %>
|
||||
<li>|</li>
|
||||
<li><%= link_to "Current", wiki_page_path(@wiki_page_version.wiki_page_id) %></li>
|
||||
<% end %>
|
||||
</menu>
|
||||
<% end %>
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
<% end %>
|
||||
</section>
|
||||
|
||||
<%= render "recent_changes" %>
|
||||
<%= render "wiki_pages/recent_changes" %>
|
||||
</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
|
||||
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#destroy', :via => :delete, :as => "favorite"
|
||||
|
||||
@@ -396,12 +396,13 @@ div#artists div#show {
|
||||
font-style: italic; }
|
||||
|
||||
/*** 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 {
|
||||
width: 500px;
|
||||
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 ***/
|
||||
div.users div.new {
|
||||
|
||||
@@ -665,6 +665,14 @@ div#artists {
|
||||
|
||||
/*** Wiki Pages ***/
|
||||
div#c-wiki-pages {
|
||||
span.version {
|
||||
color: #AAA;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
div#a-edit, div#a-new {
|
||||
textarea {
|
||||
width: 500px;
|
||||
@@ -672,10 +680,6 @@ div#c-wiki-pages {
|
||||
}
|
||||
|
||||
div#preview {
|
||||
h1:first-child {
|
||||
color: #333;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user