Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replace old loci/unattached with parsable

Improve etymology display
Closes #73.
Closes #105.
  • Loading branch information...
commit f8a2fbef665e684f28c417f27c0fdea47e893777 1 parent ecea79a
@kohath kohath authored
View
11 app/controllers/loci_controller.rb
@@ -140,12 +140,15 @@ def destroy
end
end
+ # TODO: Replace references to this with direct references to parsable/index
def unattached
- lexeme = Lexeme.where(:id => params[:id]).includes(:headwords)
-
- @loci = Locus.unattached(lexeme).paginate(:page => params[:page], :include => {:source => {:authorship => [:author, :title]}})
+ lexeme = Lexeme.where(:id => params[:id]).includes(:headwords).first
+ forms = lexeme.headword_forms
+
+ @parsables = Parse.unattached_to(forms).paginate(:page => params[:page], :per_page => 5)
+ @page_title = "Unattached to %s" % forms.to_sentence
- render "index"
+ render "parsable/index"
end
def show_by_author
View
9 app/helpers/parsable_helper.rb
@@ -3,8 +3,17 @@ def display_obj_of parse
case parse.parsable_type
when "Attestation"
parse.parsable.locus || parse.parsable
+ when "Etymology"
+ parse.parsable.subentries.first.try(:lexeme) || parse.parsable
else
parse.parsable
end
end
+
+ def display_form_for parse
+ kind = parse.parsable_type.underscore
+ lookup_context.exists?("parsable/" + kind, [], :partial) ?
+ "parsable/" + kind :
+ "shared/" + kind
+ end
end
View
0  app/views/shared/_attestation.rhtml → app/views/parsable/_attestation.rhtml
File renamed without changes
View
2  app/views/parsable/_etymology.rhtml
@@ -0,0 +1,2 @@
+<p>Etymon of <%= etymology.subentries.first.try(:lexeme).try(:language).try(:name) || '' %> <b><%= etymology.subentries.first.try(:lexeme).try(:headword_forms).try(:to_sentence) || '(Lexeme not found)' %></b> in:</p>
+<%= render :partial => "shared/subentry", :collection => etymology.subentries %>
View
9 app/views/parsable/index.html.erb
@@ -1,22 +1,19 @@
-<h1>Listing parsables</h1>
-
<% if @parsables %>
<table width="100%">
<% @parsables.each_with_index do |pable, i| %>
<% if pable.parsable %>
<tr>
- <td colspan="3">
- <%= render(:partial => "shared/%s" % [pable.parsable_type.underscore], :object => pable.parsable, :locals => { :locus_counter => display_obj_of(pable).id - 1 })%>
+ <td colspan="2">
+ <%= render(:partial => display_form_for(pable), :object => pable.parsable, :locals => { :locus_counter => display_obj_of(pable).id - 1 })%>
</td>
</tr>
<tr>
<td><%= link_to 'Show', display_obj_of(pable) %></td>
<td><%= link_to 'Edit', edit_polymorphic_path(display_obj_of(pable)) %></td>
- <td><%= link_to 'Destroy', display_obj_of(pable), :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% else %>
<tr>
- <td colspan="3">
+ <td colspan="2">
Parse <%= pable.id %> with parsed form <%= pable.parsed_form %> does not have a parsable. <%= link_to 'Destroy it', pable, :confirm => 'Are you sure?', :method => :delete %>
</td>
</tr>
Please sign in to comment.
Something went wrong with that request. Please try again.