mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
one word tags, fix captcha two word mention
This commit is contained in:
parent
9cedbd086d
commit
ba840423a6
5 changed files with 10 additions and 10 deletions
2
app.rb
2
app.rb
|
@ -374,7 +374,7 @@ post '/create' do
|
|||
session[:id] = @site.id
|
||||
redirect '/'
|
||||
else
|
||||
@site.errors.add :captcha, 'You must type in the two words correctly! Try again.' if !recaptcha_is_valid
|
||||
@site.errors.add :captcha, 'You must type in the captcha correctly! Try again.' if !recaptcha_is_valid
|
||||
|
||||
erb :'/new'
|
||||
end
|
||||
|
|
|
@ -425,12 +425,12 @@ class Site < Sequel::Model
|
|||
end
|
||||
|
||||
if tag.match(/ /)
|
||||
errors.add :tags, "Tag \"#{tag}\" cannot have more than one space between words."
|
||||
errors.add :tags, "Tag \"#{tag}\" cannot have spaces."
|
||||
break
|
||||
end
|
||||
|
||||
if tag.split(' ').length > Tag::NAME_WORDS_MAX
|
||||
errors.add :tags, "Tag \"#{tag}\" cannot be more than two words."
|
||||
errors.add :tags, "Tag \"#{tag}\" cannot be more than #{Tag::NAME_WORDS_MAX} word."
|
||||
break
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Tag < Sequel::Model
|
||||
NAME_LENGTH_MAX = 20
|
||||
NAME_WORDS_MAX = 2
|
||||
NAME_WORDS_MAX = 1
|
||||
many_to_many :sites
|
||||
|
||||
def before_create
|
||||
|
|
|
@ -103,14 +103,14 @@ describe 'signup' do
|
|||
fill_in_valid
|
||||
fill_in 'tags', with: 'police officer, hi'
|
||||
click_button 'Create Home Page'
|
||||
page.must_have_content /Tag.+cannot have more than one space/
|
||||
page.must_have_content /Tag.+cannot have spaces/
|
||||
end
|
||||
|
||||
it 'fails for tag with too many words' do
|
||||
fill_in_valid
|
||||
fill_in 'tags', with: 'police officer club'
|
||||
fill_in 'tags', with: 'police officer'
|
||||
click_button 'Create Home Page'
|
||||
page.must_have_content /Tag.+cannot be more than two words/
|
||||
page.must_have_content /Tag.+cannot be more than #{Tag::NAME_WORDS_MAX} word/
|
||||
end
|
||||
|
||||
it "fails for tag longer than #{Tag::NAME_LENGTH_MAX} characters" do
|
||||
|
@ -154,10 +154,10 @@ describe 'signup' do
|
|||
|
||||
it 'succeeds with valid tags' do
|
||||
fill_in_valid
|
||||
fill_in 'tags', with: 'derpie, shoujo manga'
|
||||
fill_in 'tags', with: 'derpie, shoujo'
|
||||
click_button 'Create Home Page'
|
||||
page.must_have_content 'Your Feed'
|
||||
Site.last.tags.collect {|t| t.name}.must_equal ['derpie', 'shoujo manga']
|
||||
Site.last.tags.collect {|t| t.name}.must_equal ['derpie', 'shoujo']
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
|
||||
<hr>
|
||||
|
||||
<p>You can optionally enter some tags! Tags will allow others to find your site based on your interests, or your site's theme. <b>Separate multiple tags with commas</b>. Don't think too hard about this, you can change them later. You can have a maximum of five tags, and tags can only contain letters (A-Z) and numbers (0-9). There is a two word per tag maximum.</p>
|
||||
<p>You can optionally enter some tags! Tags will allow others to find your site based on your interests, or your site's theme. <b>Separate multiple tags with commas</b>. Don't think too hard about this, you can change them later. You can have a maximum of five tags, tags can only contain letters (A-Z) and numbers (0-9), no spaces.</p>
|
||||
|
||||
<h5>Tags</h5>
|
||||
<input class="input-Area" name="tags" type="text" style="width: 400px; max-width:100%" placeholder="pokemon, video games, bulbasaur" value="<%= params[:tags] %>" autocapitalize="off" autocorrect="off">
|
||||
|
|
Loading…
Add table
Reference in a new issue