mirror of
https://github.com/neocities/neocities.git
synced 2025-07-22 18:46:07 +02:00
fixes for tags
This commit is contained in:
parent
c3da5cc262
commit
70a58176fa
4 changed files with 31 additions and 2 deletions
8
app.rb
8
app.rb
|
@ -233,7 +233,13 @@ 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
|
|
||||||
|
if current_site.valid?
|
||||||
|
current_site.save
|
||||||
|
else
|
||||||
|
flash[:errors] = current_site.errors[:tags].first
|
||||||
|
end
|
||||||
|
|
||||||
redirect request.referer
|
redirect request.referer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -386,7 +386,6 @@ class Site < Sequel::Model
|
||||||
|
|
||||||
if @new_tags_string
|
if @new_tags_string
|
||||||
new_tags = @new_tags_string.split ','
|
new_tags = @new_tags_string.split ','
|
||||||
new_tags.uniq!
|
|
||||||
new_tags.compact!
|
new_tags.compact!
|
||||||
@new_filtered_tags = []
|
@new_filtered_tags = []
|
||||||
|
|
||||||
|
@ -416,7 +415,10 @@ class Site < Sequel::Model
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
next if tags.collect {|t| t.name}.include? tag
|
||||||
|
|
||||||
@new_filtered_tags << tag
|
@new_filtered_tags << tag
|
||||||
|
@new_filtered_tags.uniq!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -127,6 +127,16 @@ describe 'signup' do
|
||||||
page.must_have_content /Cannot have more than \d tags for your site/
|
page.must_have_content /Cannot have more than \d tags for your site/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not duplicate tags' do
|
||||||
|
fill_in_valid
|
||||||
|
fill_in 'tags', with: 'one, one'
|
||||||
|
click_button 'Create Home Page'
|
||||||
|
|
||||||
|
site = Site.last
|
||||||
|
site.tags.length.must_equal 1
|
||||||
|
site.tags.first.name.must_equal 'one'
|
||||||
|
end
|
||||||
|
|
||||||
it 'succeeds with no tags' do
|
it 'succeeds with no tags' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'tags', with: ''
|
fill_in 'tags', with: ''
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
<div class="header-Outro with-site-image">
|
<div class="header-Outro with-site-image">
|
||||||
|
<% if flash.keys.length > 0 %>
|
||||||
|
<div class="row content">
|
||||||
|
<div class="alert txt-Center">
|
||||||
|
<p style="padding:5px">
|
||||||
|
<% flash.keys.each do |key| %>
|
||||||
|
<%= flash[key] %>
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<div class="row content">
|
<div class="row content">
|
||||||
<div class="col col-50 signup-Area large">
|
<div class="col col-50 signup-Area large">
|
||||||
<div class="signup-Form">
|
<div class="signup-Form">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue