mirror of
https://github.com/neocities/neocities.git
synced 2025-07-22 10:36: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
|
||||
require_login
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
@ -386,7 +386,6 @@ class Site < Sequel::Model
|
|||
|
||||
if @new_tags_string
|
||||
new_tags = @new_tags_string.split ','
|
||||
new_tags.uniq!
|
||||
new_tags.compact!
|
||||
@new_filtered_tags = []
|
||||
|
||||
|
@ -416,7 +415,10 @@ class Site < Sequel::Model
|
|||
break
|
||||
end
|
||||
|
||||
next if tags.collect {|t| t.name}.include? tag
|
||||
|
||||
@new_filtered_tags << tag
|
||||
@new_filtered_tags.uniq!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -127,6 +127,16 @@ describe 'signup' do
|
|||
page.must_have_content /Cannot have more than \d tags for your site/
|
||||
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
|
||||
fill_in_valid
|
||||
fill_in 'tags', with: ''
|
||||
|
|
|
@ -1,4 +1,15 @@
|
|||
<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="col col-50 signup-Area large">
|
||||
<div class="signup-Form">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue