%
# This renders the bookmark form based on whatever kind of object we are bookmarking
# we need bookmarkable, action (create or update), and bookmark if it exists
# if in_page is true then we assume that this is embedded within another page (eg the work page)
# if dynamic is true then this has been rendered via ajax
%>
<%= ts("Bookmark") %>
<% bookmark ||= Bookmark.new %>
<% bookmarkable ||= bookmark.bookmarkable %>
<% in_page ||= false %>
<% dynamic ||= false %>
<% bookmark_form_id = (bookmarkable.blank? ? "#{bookmark.id}" : "#{bookmarkable.id}") %>
<% notes_id = "bookmark_notes" + (dynamic ? "_#{bookmark_form_id}" : "") %>
<% # Note telling users about our bookmarklet for external links %>
<% if !dynamic && bookmarkable.class == ExternalWork %><%= render "bookmarks/bookmarklet" %><% end %>
<%= form_for(:bookmark, :url => bookmark_form_path(bookmark, bookmarkable), :html => {:method => bookmark.new_record? ? :post : :put}) do |f| %>
<% if bookmarkable.class == ExternalWork && bookmarkable.new_record? %>
* <%= ts('Required information') %>
<% end %>
<%= ts("Bookmark") %>
<% if in_page %>
<% if dynamic %>
×
<% else %>
×
<% end %>
<% end %>
<% if current_user.pseuds.count > 1 %>
<%= select_tag "bookmark[pseud_id]",
options_for_select(current_user.pseuds.map{|pseud| [pseud.name, pseud.id]},
bookmark.pseud ? bookmark.pseud.id : current_user.default_pseud.id), title: ts("choose pseud") %>
<% else %>
<%= current_user.default_pseud.name %>,
<%= f.hidden_field :pseud_id, value: "#{current_user.default_pseud.id}" %>
<% end %>
<%= ts(" save a bookmark!") %>
<% # What we're bookmarking %>
<% if bookmarkable.class == ExternalWork && bookmarkable.new_record? %>
<%= fields_for :external_work, bookmarkable do |ew_form| %>
<%= render "bookmarks/external_work_fields", ew: ew_form %>
<% end %>
<% end %>
<%= ts("Write Comments") %>
<%= f.label :bookmarker_notes, ts("Notes"), for: notes_id %>
<%= f.text_area :bookmarker_notes, rows: 4, id: notes_id, class: "observe_textlength",
"aria-describedby" => "notes-field-description" %>
<%= generate_countdown_html(notes_id, ArchiveConfig.NOTES_MAX) %>
<%= f.label :tag_string, ts("Your tags") %>
<% if bookmarkable.class != ExternalWork %>
<% end %>
<%= f.text_field :tag_string, autocomplete_options('tag?type=all', size: (in_page ? 60 : 80), "aria-describedby" => "tag-string-description") %>
<%= ts("Comma separated, %{max} characters per tag", max: ArchiveConfig.TAG_MAX) %>
<%= f.label :collection_names, ts("Add to collections") %>
<%= f.text_field :collection_names, autocomplete_options('open_collection_names', size: (in_page ? 60 : 80)) %>
<%= ts("Choose Type and Post") %>
<%= f.check_box :private %> <%= f.label :private, ts("Private bookmark") %>
<%= f.check_box :rec %> <%= f.label :rec, ts("Rec") %>
<%= f.submit(button_name) %>
<% unless in_page %>
<%= link_to ts("My Bookmarks"), user_bookmarks_path(current_user) %>
<% end %>
<% end %>