|
12 | 12 | <div class="bg-<%= term.dictionary.color %>-600 text-white p-2"><%= term.dictionary.name %></div>
|
13 | 13 | <% if term.descriptions.present? %>
|
14 | 14 | <div>
|
15 |
| - <span class="text-gray-500"> |
16 |
| - <% stem = term.stem %> |
17 |
| - <% if stem.present? %> |
| 15 | + <% if term.repetition.present? %> |
| 16 | + <span class="bg-rose-600 text-white p-0.5"> |
| 17 | + [疊 <%= term.repetition %>] |
| 18 | + </span> |
| 19 | + <% end %> |
| 20 | + |
| 21 | + <% stem = term.stem %> |
| 22 | + <% if stem.present? %> |
| 23 | + <span class="text-gray-500"> |
18 | 24 | (詞幹: <%= link_to(stem.name, term_path(stem.name)) %>)
|
19 |
| - <% end %> |
20 |
| - </span> |
| 25 | + </span> |
| 26 | + <% end %> |
| 27 | + |
21 | 28 | <% if term.audio.present? %>
|
22 | 29 | <button>
|
23 | 30 | <i class="fas fa-volume-up" onclick="document.getElementById('audio-<%= term.audio_id %>').play()"></i>
|
|
36 | 43 | <ul class="list-disc list-inside space-y-1">
|
37 | 44 | <% description.examples.each do |example| %>
|
38 | 45 | <li>
|
39 |
| - <% content = example.content.gsub("\xEF\xBF\xB9", "") %> |
40 |
| - <% parts = content.split(/[`~]/).reject(&:empty?) %> |
41 |
| - <%== parts.each_with_index.map do |part, i| |
42 |
| - if part.match(/^[\p{Alnum}]+$/) && part != params[:id] |
43 |
| - term_path = if i == 0 |
44 |
| - "/terms/#{part.downcase}" |
45 |
| - else |
46 |
| - "/terms/#{part}" |
47 |
| - end |
| 46 | + <% |
| 47 | + term_html = '' |
| 48 | + parts = example.content.split(/[`~]/).reject(&:empty?) |
| 49 | + parts.each_with_index do |part, i| |
| 50 | + if part.match(/^[\p{Alnum}]+$/) && part != params[:id] |
| 51 | + term_path = if i == 0 |
| 52 | + "/terms/#{part.downcase}" |
| 53 | + else |
| 54 | + "/terms/#{part}" |
| 55 | + end |
48 | 56 |
|
49 |
| - "<a href=\"#{term_path}\" class=\"border-b border-gray-300 text-gray-800 hover:bg-gray-300 focus:bg-gray-300 hover:text-[#0070a3] focus:text-[#0070a3] focus:outline focus:outline-1 focus:outline-[#69d2fc]\">#{part}</a>" |
50 |
| - else |
51 |
| - part |
52 |
| - end |
53 |
| - end.join %> |
| 57 | + term_html += "<a href=\"#{term_path}\" class=\"border-b border-gray-300 text-gray-800 hover:bg-gray-300 focus:bg-gray-300 hover:text-[#0070a3] focus:text-[#0070a3] focus:outline focus:outline-1 focus:outline-[#69d2fc]\">#{part}</a>" |
| 58 | + else |
| 59 | + term_html += part |
| 60 | + end |
| 61 | + end |
| 62 | + %> |
| 63 | + <%= term_html.html_safe %> |
54 | 64 | </li>
|
55 | 65 | <% end %>
|
56 | 66 | </ul>
|
57 | 67 | <% end %>
|
| 68 | + |
| 69 | + <% if description.synonyms.alts.present? %> |
| 70 | + <p> |
| 71 | + <span class="bg-stone-500 text-white text-sm p-0.5 ml-5 mr-2"> |
| 72 | + 同 |
| 73 | + </span> |
| 74 | + <% alt_array = [] %> |
| 75 | + <% description.synonyms.alts.each do |synonym_alt| %> |
| 76 | + <% |
| 77 | + alt_html = '' |
| 78 | + parts = synonym_alt.content.split(/[`~]/).reject(&:empty?) |
| 79 | + parts.each_with_index do |part, i| |
| 80 | + if part.match(/^[\p{Alnum}]+$/) && part != params[:id] |
| 81 | + term_path = if i == 0 |
| 82 | + "/terms/#{part.downcase}" |
| 83 | + else |
| 84 | + "/terms/#{part}" |
| 85 | + end |
| 86 | + |
| 87 | + alt_html += "<a href=\"#{term_path}\" class=\"border-b border-gray-300 text-gray-800 hover:bg-gray-300 focus:bg-gray-300 hover:text-[#0070a3] focus:text-[#0070a3] focus:outline focus:outline-1 focus:outline-[#69d2fc]\">#{part}</a>" |
| 88 | + else |
| 89 | + alt_html += part |
| 90 | + end |
| 91 | + end |
| 92 | + |
| 93 | + alt_array << alt_html |
| 94 | + %> |
| 95 | + <% end %> |
| 96 | + <%= alt_array.join("、").html_safe %> |
| 97 | + </p> |
| 98 | + <% end %> |
| 99 | + |
| 100 | + <% if description.synonyms.refs.present? %> |
| 101 | + <p> |
| 102 | + <span class="bg-stone-500 text-white text-sm p-0.5 ml-5 mr-2"> |
| 103 | + 參見 |
| 104 | + </span> |
| 105 | + <% ref_array = [] %> |
| 106 | + <% description.synonyms.refs.each do |synonym_ref| %> |
| 107 | + <% |
| 108 | + ref_html = '' |
| 109 | + parts = synonym_ref.content.split(/[`~]/).reject(&:empty?) |
| 110 | + parts.each_with_index do |part, i| |
| 111 | + if part.match(/^[\p{Alnum}]+$/) && part != params[:id] |
| 112 | + term_path = if i == 0 |
| 113 | + "/terms/#{part.downcase}" |
| 114 | + else |
| 115 | + "/terms/#{part}" |
| 116 | + end |
| 117 | + |
| 118 | + ref_html += "<a href=\"#{term_path}\" class=\"border-b border-gray-300 text-gray-800 hover:bg-gray-300 focus:bg-gray-300 hover:text-[#0070a3] focus:text-[#0070a3] focus:outline focus:outline-1 focus:outline-[#69d2fc]\">#{part}</a>" |
| 119 | + else |
| 120 | + ref_html += part |
| 121 | + end |
| 122 | + end |
| 123 | + |
| 124 | + ref_array << ref_html |
| 125 | + %> |
| 126 | + <% end %> |
| 127 | + <%= ref_array.join("、").html_safe %> |
| 128 | + </p> |
| 129 | + <% end %> |
58 | 130 | </li>
|
59 | 131 | <% end %>
|
60 | 132 | <!-- <li>捉獵物,獵獲的(獵物)。
|
|
0 commit comments