create a counter of anonymous notes in a cookie, read by new note controller to display an encouragement to contribute in the already existing anonymous warning if the anonymous visitor has already created at least 10 anonymous notes. Cookie deleted on log-in and sign-up after email validation
newNoteMarker.dragging.disable();
createNote(location, text, (feature) => {
+ if (typeof OSM.user === "undefined") {
+ var anonymousNotesCount = Number(Cookies.get("_osm_anonymous_notes_count")) || 0;
+ Cookies.set("_osm_anonymous_notes_count", anonymousNotesCount + 1, { secure: true, expires: 30, path: "/", samesite: "lax" });
+ }
content.find("textarea").val("");
addCreatedNoteMarker(feature);
OSM.router.route("/note/" + feature.properties.id);
session[:fingerprint] = user.fingerprint
session_expires_after 28.days if session[:remember_me]
+ cookies.delete :_osm_anonymous_notes_count
+
target = referer || url_for(:controller => :site, :action => :index)
# The user is logged in, so decide where to send them:
user.email_valid = true
flash[:notice] = gravatar_status_message(user) if gravatar_enable(user)
user.save!
+ cookies.delete :_osm_anonymous_notes_count
referer = safe_referer(params[:referer]) if params[:referer]
pending_user = session.delete(:pending_user)
end
def new
+ @anonymous_notes_count = request.cookies["_osm_anonymous_notes_count"].to_i || 0
render :action => :new_readonly if api_status != "online"
end
end
<div class="note">
<p class="alert alert-info"><%= t(".intro") %></p>
<% if !current_user %>
- <p class="alert alert-warning"><%= t ".anonymous_warning_html",
- :log_in => link_to(t(".anonymous_warning_log_in"), login_path(:referer => new_note_path)),
- :sign_up => link_to(t(".anonymous_warning_sign_up"), new_user_path) %></p>
+ <div class="alert alert-warning pb-0">
+ <p><%= t ".anonymous_warning_html",
+ :log_in => link_to(t(".anonymous_warning_log_in"), login_path(:referer => new_note_path)),
+ :sign_up => link_to(t(".anonymous_warning_sign_up"), new_user_path) %></p>
+ <% if @anonymous_notes_count >= 10 %>
+ <p><%= t ".counter_warning_html",
+ :x_anonymous_notes => t(".x_anonymous_notes", :count => @anonymous_notes_count),
+ :contribute_by_yourself => link_to(t(".counter_warning_guide_link.text"), t(".counter_warning_guide_link.url")),
+ :community_can_help => link_to(t(".counter_warning_forum_link.text"), t(".counter_warning_forum_link.url")) %></p>
+ <% end %>
+ </div>
<% end %>
<p class="alert alert-warning" id="new-note-zoom-warning" hidden><%= t "javascripts.site.createnote_disabled_tooltip" %></p>
<form action="#">
new:
title: "New Note"
intro: "Spotted a mistake or something missing? Let other mappers know so we can fix it. Move the marker to the correct position and type a note to explain the problem."
- anonymous_warning_html: "You are not logged in. Please %{log_in} or %{sign_up} if you want to receive updates for your note."
+ anonymous_warning_html: "You are not logged in. Please %{log_in} or %{sign_up} to receive updates for your note and help mappers resolve it."
anonymous_warning_log_in: "log in"
anonymous_warning_sign_up: "sign up"
+ counter_warning_html: "You have already posted at least %{x_anonymous_notes}, that's great for the community, thank you! Now we encourage you to %{contribute_by_yourself}, it is not that complicated, and %{community_can_help}."
+ x_anonymous_notes:
+ one: "%{count} anonymous note"
+ other: "%{count} anonymous notes"
+ counter_warning_guide_link:
+ text: "contribute by yourself"
+ url: https://wiki.openstreetmap.org/wiki/Beginners%27_guide
+ counter_warning_forum_link:
+ text: "the community can help you"
+ url: https://community.openstreetmap.org/
advice: "Your note is public and may be used to update the map, so don't enter personal information, or information from copyrighted maps or directory listings."
add: Add Note
new_readonly: