artist urls: add /artist_urls index page.
This commit is contained in:
@@ -1,6 +1,14 @@
|
|||||||
class ArtistUrlsController < ApplicationController
|
class ArtistUrlsController < ApplicationController
|
||||||
respond_to :json
|
respond_to :json, :xml, :html
|
||||||
before_action :member_only
|
before_action :member_only, except: [:index]
|
||||||
|
|
||||||
|
def index
|
||||||
|
@artist_urls = ArtistUrl.includes(:artist).search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||||
|
respond_with(@artist_urls) do |format|
|
||||||
|
format.json { render json: @artist_urls.to_json(include: "artist",) }
|
||||||
|
format.xml { render xml: @artist_urls.to_xml(include: "artist", root: "artist-urls") }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@artist_url = ArtistUrl.find(params[:id])
|
@artist_url = ArtistUrl.find(params[:id])
|
||||||
|
|||||||
@@ -45,6 +45,24 @@ class ArtistUrl < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.search(params = {})
|
||||||
|
q = super
|
||||||
|
|
||||||
|
q = q.attribute_matches(:artist_id, params[:artist_id])
|
||||||
|
q = q.attribute_matches(:is_active, params[:is_active])
|
||||||
|
|
||||||
|
case params[:order]
|
||||||
|
when /\A(id|artist_id|url|normalized_url|is_active|created_at|updated_at)(?:_(asc|desc))?\z/i
|
||||||
|
dir = $2 || :desc
|
||||||
|
q = q.order($1 => dir).order(id: :desc)
|
||||||
|
else
|
||||||
|
q = q.apply_default_order(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
q
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def parse_prefix
|
def parse_prefix
|
||||||
case url
|
case url
|
||||||
when /^-/
|
when /^-/
|
||||||
|
|||||||
44
app/views/artist_urls/index.html.erb
Normal file
44
app/views/artist_urls/index.html.erb
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<div id="c-artist-urls">
|
||||||
|
<div id="a-index">
|
||||||
|
<%= simple_form_for(:search, url: artist_urls_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||||
|
<%= f.input :is_active, label: "Active?", collection: [["Yes", true], ["No", false]], include_blank: true, selected: params[:search][:is_active] %>
|
||||||
|
<%= f.input :order, collection: [["ID", "id"], ["Created", "created_at"], ["Updated", "updated_at"]], selected: params[:search][:order] %>
|
||||||
|
<%= f.submit "Search" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<table class="striped" width="100%">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Artist Name</th>
|
||||||
|
<th>URL</th>
|
||||||
|
<th>Normalized URL</th>
|
||||||
|
<th>Active?</th>
|
||||||
|
<th>Created</th>
|
||||||
|
<th>Updated</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @artist_urls.each do |artist_url| %>
|
||||||
|
<tr>
|
||||||
|
<%= tag.td artist_url.id %>
|
||||||
|
<%= tag.td link_to(artist_url.artist.name, artist_url.artist) %>
|
||||||
|
<%= tag.td external_link_to(artist_url.url.to_s) %>
|
||||||
|
<%= tag.td external_link_to(artist_url.normalized_url) %>
|
||||||
|
<%= tag.td artist_url.is_active.to_s %>
|
||||||
|
<%= tag.td artist_url.created_at %>
|
||||||
|
<%= tag.td artist_url.updated_at %>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%= numbered_paginator(@artist_urls) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render "artists/secondary_links" %>
|
||||||
|
|
||||||
|
<% content_for(:page_title) do %>
|
||||||
|
Artist URLs - <%= Danbooru.config.app_name %>
|
||||||
|
<% end %>
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
<%= subnav_link_to "Banned", banned_artists_path %>
|
<%= subnav_link_to "Banned", banned_artists_path %>
|
||||||
<%= subnav_link_to "New", new_artist_path %>
|
<%= subnav_link_to "New", new_artist_path %>
|
||||||
<%= subnav_link_to "Recent changes", artist_versions_path %>
|
<%= subnav_link_to "Recent changes", artist_versions_path %>
|
||||||
|
<%= subnav_link_to "URLs", artist_urls_path %>
|
||||||
<% if @artist && !@artist.new_record? %>
|
<% if @artist && !@artist.new_record? %>
|
||||||
<li>|</li>
|
<li>|</li>
|
||||||
<%= subnav_link_to "Posts (#{Post.fast_count(@artist.name)})", posts_path(:tags => @artist.name) %>
|
<%= subnav_link_to "Posts (#{Post.fast_count(@artist.name)})", posts_path(:tags => @artist.name) %>
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ Rails.application.routes.draw do
|
|||||||
get :banned
|
get :banned
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :artist_urls, only: [:update]
|
resources :artist_urls, only: [:index, :update]
|
||||||
resources :artist_versions, :only => [:index] do
|
resources :artist_versions, :only => [:index] do
|
||||||
collection do
|
collection do
|
||||||
get :search
|
get :search
|
||||||
|
|||||||
Reference in New Issue
Block a user