mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
finish basic implementation of tags, misc cleanups
This commit is contained in:
parent
575189656b
commit
769a122b03
8 changed files with 75 additions and 37 deletions
12
app.rb
12
app.rb
|
@ -222,7 +222,17 @@ end
|
||||||
post '/tags/add' do
|
post '/tags/add' do
|
||||||
require_login
|
require_login
|
||||||
current_site.new_tags_string = params[:tags]
|
current_site.new_tags_string = params[:tags]
|
||||||
current_site.save validate: false
|
current_site.save
|
||||||
|
redirect request.referer
|
||||||
|
end
|
||||||
|
|
||||||
|
post '/tags/remove' do
|
||||||
|
require_login
|
||||||
|
|
||||||
|
DB.transaction {
|
||||||
|
params[:tags].each {|tag| current_site.remove_tag Tag[name: tag]}
|
||||||
|
}
|
||||||
|
|
||||||
redirect request.referer
|
redirect request.referer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
9
migrations/033_add_site_id_to_site_change_files.rb
Normal file
9
migrations/033_add_site_id_to_site_change_files.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Sequel.migration do
|
||||||
|
up {
|
||||||
|
DB.add_column :site_change_files, :site_id, :integer
|
||||||
|
}
|
||||||
|
|
||||||
|
down {
|
||||||
|
DB.drop_column :site_change_files, :site_id
|
||||||
|
}
|
||||||
|
end
|
|
@ -267,6 +267,8 @@ class Site < Sequel::Model
|
||||||
screenshots_delete(filename) if ext.match HTML_REGEX
|
screenshots_delete(filename) if ext.match HTML_REGEX
|
||||||
thumbnails_delete(filename) if ext.match IMAGE_REGEX
|
thumbnails_delete(filename) if ext.match IMAGE_REGEX
|
||||||
|
|
||||||
|
SiteChangeFile.filter(site_id: self.id, filename: filename).delete
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class SiteChange < Sequel::Model
|
||||||
site_change_file = site_change.site_change_files_dataset.filter(filename: filename).first
|
site_change_file = site_change.site_change_files_dataset.filter(filename: filename).first
|
||||||
|
|
||||||
if !site_change_file
|
if !site_change_file
|
||||||
site_change.add_site_change_file filename: filename
|
site_change.add_site_change_file site_id: site.id, filename: filename
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
2
public/css/bootstrap.min.css
vendored
2
public/css/bootstrap.min.css
vendored
|
@ -1,4 +1,4 @@
|
||||||
@import url("http://fonts.googleapis.com/css?family=Lato:400,700,900,400italic");/*!
|
@import url("//fonts.googleapis.com/css?family=Lato:400,700,900,400italic");/*!
|
||||||
* Bootstrap v2.3.2
|
* Bootstrap v2.3.2
|
||||||
*
|
*
|
||||||
* Copyright 2012 Twitter, Inc
|
* Copyright 2012 Twitter, Inc
|
||||||
|
|
|
@ -22,30 +22,33 @@
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<div class="icon"></div>
|
<div class="icon"></div>
|
||||||
<% event_site_username = event.site_dataset.select(:username).first.username %>
|
<% event_site_username = event.site_dataset.select(:username).first.username %>
|
||||||
<a href="http://<%= event_site_username %>.neocities.org" class="user"><%= event_site_username %>.neocities.org</a> has been updated <span class="date"><%= event.created_at.ago %></span>
|
<a href="http://<%= event_site_username %>.neocities.org" class="user"><%= event_site_username %>.neocities.org</a> has been updated. <span class="date"><%= event.created_at.ago %></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<% site_change_filenames = event.site_change.site_change_filenames %>
|
||||||
<div class="files">
|
<% unless site_change_filenames.empty? %>
|
||||||
<% event.site_change.site_change_filenames.each do |f| %>
|
<div class="content">
|
||||||
<div class="file">
|
<div class="files">
|
||||||
<div class="html-thumbnail <%= site_change_file_display_class f %>">
|
<% event.site_change.site_change_filenames.each do |f| %>
|
||||||
<a href="http://<%= site.username %>.neocities.org/<%= f %>">
|
<div class="file">
|
||||||
<% if site_change_file_display_class(f) == 'html' %>
|
<div class="html-thumbnail <%= site_change_file_display_class f %>">
|
||||||
<img src="<%= site.screenshot_url(f, '90x63') %>">
|
<a href="http://<%= site.username %>.neocities.org/<%= f %>">
|
||||||
<% elsif site_change_file_display_class(f) == 'image' %>
|
<% if site_change_file_display_class(f) == 'html' %>
|
||||||
<img src="<%= site.thumbnail_url(f, '90x63') %>">
|
<img src="<%= site.screenshot_url(f, '90x63') %>">
|
||||||
<% elsif site_change_file_display_class(f) == 'misc' %>
|
<% elsif site_change_file_display_class(f) == 'image' %>
|
||||||
<span class="misc-icon">
|
<img src="<%= site.thumbnail_url(f, '90x63') %>">
|
||||||
<%= File.extname(f).sub('.', '') %>
|
<% elsif site_change_file_display_class(f) == 'misc' %>
|
||||||
</span>
|
<span class="misc-icon">
|
||||||
<% end %>
|
<%= File.extname(f).sub('.', '') %>
|
||||||
<span class="title"><%= f %></span>
|
</span>
|
||||||
</a>
|
<% end %>
|
||||||
|
<span class="title"><%= f %></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<% end %>
|
||||||
<% end %>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%== erb :'_news_actions', layout: false, locals: {event: event} %>
|
<%== erb :'_news_actions', layout: false, locals: {event: event} %>
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
|
|
||||||
<% if is_current_site %>
|
<% if is_current_site %>
|
||||||
<div class="clear">
|
<div class="clear">
|
||||||
<a href="#addTag" data-toggle="modal">Add Tags</a>
|
<a href="#addTag" data-toggle="modal">Add</a>
|
||||||
|
|
||||||
|
<a href="#removeTag" data-toggle="modal">Remove</a>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -24,7 +26,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>
|
<p>
|
||||||
Tags must only be a single word, and can only contain letters and numbers. Separate multiple tags with commas (example: pokemon, gardening, bicycles).
|
Tags must only be a single word, and can only contain letters and numbers, and you can only have up to five tags. Separate multiple tags with commas (example: pokemon, gardening, bicycles).
|
||||||
</p>
|
</p>
|
||||||
<p>Tags:</p>
|
<p>Tags:</p>
|
||||||
<input type="text" name="tags">
|
<input type="text" name="tags">
|
||||||
|
@ -34,4 +36,27 @@
|
||||||
<button type="submit" class="btn btn-Action">Add Tag(s)</button>
|
<button type="submit" class="btn btn-Action">Add Tag(s)</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal hide fade" id="removeTag" tabindex="-1" role="dialog" aria-labelledby="removeTagLabel" aria-hidden="true">
|
||||||
|
<form method="POST" action="/tags/remove">
|
||||||
|
<input type="hidden" value="<%= csrf_token %>" name="csrf_token">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">x</button>
|
||||||
|
<h3 id="removeTagLabel">Remove Tags</h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>
|
||||||
|
Select the tags you would like to remove:
|
||||||
|
</p>
|
||||||
|
<% site.tags.each do |tag| %>
|
||||||
|
<input name="tags[]" type="checkbox" value="<%= tag.name %>"> <%= tag.name %>
|
||||||
|
<br>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
||||||
|
<button type="submit" class="btn btn-Action">Remove Tag(s)</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
|
@ -97,17 +97,6 @@
|
||||||
|
|
||||||
<%== erb :'_follows', layout: false, locals: {site: site, is_current_site: site == current_site} %>
|
<%== erb :'_follows', layout: false, locals: {site: site, is_current_site: site == current_site} %>
|
||||||
|
|
||||||
<!--
|
|
||||||
<h3>Archives</h3>
|
|
||||||
<div class="archives">
|
|
||||||
<a href=""><img src="http://neocities.org/site_screenshots/codeventurer.jpg"></a>
|
|
||||||
<a href=""><img src="http://neocities.org/site_screenshots/codeventurer.jpg"></a>
|
|
||||||
<a href=""><img src="http://neocities.org/site_screenshots/codeventurer.jpg"></a>
|
|
||||||
<a href=""><img src="http://neocities.org/site_screenshots/codeventurer.jpg"></a>
|
|
||||||
<a href="" class="more">See all versions</a>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<%== erb :'_tags', layout: false, locals: {site: site, is_current_site: site == current_site} %>
|
<%== erb :'_tags', layout: false, locals: {site: site, is_current_site: site == current_site} %>
|
||||||
|
|
||||||
<div class="report">
|
<div class="report">
|
||||||
|
|
Loading…
Add table
Reference in a new issue