enju_question 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +36 -0
  4. data/app/controllers/answers_controller.rb +140 -0
  5. data/app/controllers/questions_controller.rb +171 -0
  6. data/app/models/answer.rb +59 -0
  7. data/app/models/answer_has_item.rb +20 -0
  8. data/app/models/question.rb +87 -0
  9. data/app/models/question_sweeper.rb +17 -0
  10. data/app/views/answers/_form.html.erb +33 -0
  11. data/app/views/answers/edit.html.erb +13 -0
  12. data/app/views/answers/index.atom.builder +16 -0
  13. data/app/views/answers/index.html.erb +44 -0
  14. data/app/views/answers/index.rss.builder +31 -0
  15. data/app/views/answers/new.html.erb +14 -0
  16. data/app/views/answers/new.mobile.erb +35 -0
  17. data/app/views/answers/show.html.erb +54 -0
  18. data/app/views/questions/_crd.html.erb +24 -0
  19. data/app/views/questions/_index.html.erb +22 -0
  20. data/app/views/questions/_index_user.html.erb +18 -0
  21. data/app/views/questions/_list.html.erb +69 -0
  22. data/app/views/questions/_solved_facet.html.erb +21 -0
  23. data/app/views/questions/edit.html.erb +44 -0
  24. data/app/views/questions/index.atom.builder +16 -0
  25. data/app/views/questions/index.html.erb +5 -0
  26. data/app/views/questions/index.js.erb +2 -0
  27. data/app/views/questions/index.mobile.erb +21 -0
  28. data/app/views/questions/index.rss.builder +41 -0
  29. data/app/views/questions/index_crd.xml.builder +36 -0
  30. data/app/views/questions/new.html.erb +35 -0
  31. data/app/views/questions/show.html.erb +62 -0
  32. data/app/views/questions/show.mobile.erb +46 -0
  33. data/app/views/questions/show_crd.xml.builder +34 -0
  34. data/config/routes.rb +10 -0
  35. data/db/migrate/098_create_questions.rb +21 -0
  36. data/db/migrate/099_create_answers.rb +21 -0
  37. data/db/migrate/20100217054028_create_answer_has_items.rb +17 -0
  38. data/lib/enju_question/engine.rb +4 -0
  39. data/lib/enju_question/version.rb +3 -0
  40. data/lib/enju_question.rb +4 -0
  41. data/lib/tasks/enju_question_tasks.rake +4 -0
  42. data/spec/cassette_library/enju_ndl/crd.yml +440 -0
  43. data/spec/controllers/answers_controller_spec.rb +486 -0
  44. data/spec/controllers/questions_controller_spec.rb +559 -0
  45. data/spec/dummy/Rakefile +7 -0
  46. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  47. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  48. data/spec/dummy/app/controllers/application_controller.rb +106 -0
  49. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  50. data/spec/dummy/app/models/ability.rb +42 -0
  51. data/spec/dummy/app/models/item.rb +5 -0
  52. data/spec/dummy/app/models/role.rb +8 -0
  53. data/spec/dummy/app/models/user.rb +29 -0
  54. data/spec/dummy/app/models/user_group.rb +2 -0
  55. data/spec/dummy/app/models/user_has_role.rb +4 -0
  56. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  57. data/spec/dummy/app/views/page/403.html.erb +9 -0
  58. data/spec/dummy/app/views/page/403.mobile.erb +5 -0
  59. data/spec/dummy/app/views/page/403.xml.erb +4 -0
  60. data/spec/dummy/app/views/page/404.html.erb +9 -0
  61. data/spec/dummy/app/views/page/404.mobile.erb +5 -0
  62. data/spec/dummy/app/views/page/404.xml.erb +4 -0
  63. data/spec/dummy/config/application.rb +46 -0
  64. data/spec/dummy/config/boot.rb +10 -0
  65. data/spec/dummy/config/database.yml +25 -0
  66. data/spec/dummy/config/environment.rb +5 -0
  67. data/spec/dummy/config/environments/development.rb +30 -0
  68. data/spec/dummy/config/environments/production.rb +60 -0
  69. data/spec/dummy/config/environments/test.rb +39 -0
  70. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  71. data/spec/dummy/config/initializers/devise.rb +209 -0
  72. data/spec/dummy/config/initializers/inflections.rb +10 -0
  73. data/spec/dummy/config/initializers/mime_types.rb +6 -0
  74. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  75. data/spec/dummy/config/initializers/session_store.rb +8 -0
  76. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  77. data/spec/dummy/config/locales/en.yml +5 -0
  78. data/spec/dummy/config/routes.rb +60 -0
  79. data/spec/dummy/config.ru +4 -0
  80. data/spec/dummy/db/development.sqlite3 +0 -0
  81. data/spec/dummy/db/migrate/006_create_items.rb +36 -0
  82. data/spec/dummy/db/migrate/20100525171356_acts_as_taggable_on_migration.rb +30 -0
  83. data/spec/dummy/db/migrate/20111201121636_create_languages.rb +16 -0
  84. data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
  85. data/spec/dummy/db/migrate/20111201155456_create_users.rb +13 -0
  86. data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +31 -0
  87. data/spec/dummy/db/migrate/20111201163342_create_user_groups.rb +12 -0
  88. data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
  89. data/spec/dummy/db/schema.rb +168 -0
  90. data/spec/dummy/db/test.sqlite3 +0 -0
  91. data/spec/dummy/lib/expire_editable_fragment.rb +62 -0
  92. data/spec/dummy/log/development.log +2 -0
  93. data/spec/dummy/log/sunspot-solr-test.log +222 -0
  94. data/spec/dummy/log/test.log +77918 -0
  95. data/spec/dummy/public/404.html +26 -0
  96. data/spec/dummy/public/422.html +26 -0
  97. data/spec/dummy/public/500.html +26 -0
  98. data/spec/dummy/public/favicon.ico +0 -0
  99. data/spec/dummy/script/rails +6 -0
  100. data/spec/dummy/solr/conf/admin-extra.html +31 -0
  101. data/spec/dummy/solr/conf/elevate.xml +36 -0
  102. data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
  103. data/spec/dummy/solr/conf/protwords.txt +21 -0
  104. data/spec/dummy/solr/conf/schema.xml +238 -0
  105. data/spec/dummy/solr/conf/scripts.conf +24 -0
  106. data/spec/dummy/solr/conf/solrconfig.xml +934 -0
  107. data/spec/dummy/solr/conf/spellings.txt +2 -0
  108. data/spec/dummy/solr/conf/stopwords.txt +58 -0
  109. data/spec/dummy/solr/conf/synonyms.txt +31 -0
  110. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  111. data/spec/dummy/solr/data/test/index/segments_1 +0 -0
  112. data/spec/dummy/solr/data/test/spellchecker/segments.gen +0 -0
  113. data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
  114. data/spec/factories/answer.rb +7 -0
  115. data/spec/factories/question.rb +6 -0
  116. data/spec/factories/user.rb +34 -0
  117. data/spec/fixtures/answer_has_items.yml +26 -0
  118. data/spec/fixtures/answers.yml +61 -0
  119. data/spec/fixtures/questions.yml +61 -0
  120. data/spec/fixtures/roles.yml +21 -0
  121. data/spec/fixtures/user_groups.yml +25 -0
  122. data/spec/fixtures/user_has_roles.yml +41 -0
  123. data/spec/fixtures/users.yml +69 -0
  124. data/spec/models/answer_has_item_spec.rb +20 -0
  125. data/spec/models/answer_spec.rb +25 -0
  126. data/spec/spec_helper.rb +48 -0
  127. data/spec/support/controller_macros.rb +48 -0
  128. data/spec/support/devise.rb +4 -0
  129. data/spec/support/vcr.rb +6 -0
  130. metadata +306 -0
@@ -0,0 +1,31 @@
1
+ xml.instruct! :xml, :version=>"1.0"
2
+ xml.rss('version' => "2.0",
3
+ 'xmlns:opensearch' => "http://a9.com/-/spec/opensearch/1.1/",
4
+ 'xmlns:atom' => "http://www.w3.org/2005/Atom"){
5
+ xml.channel{
6
+ xml.title t('answer.user_answer', :login_name => @user.username)
7
+ xml.link "#{request.protocol}#{request.host_with_port}" + user_answers_path(@user)
8
+ xml.description "Next-L Enju, an open source integrated library system developed by Project Next-L"
9
+ xml.language @locale.to_s
10
+ xml.ttl "60"
11
+ xml.tag! "atom:link", :rel => 'self', :href => "#{request.protocol}#{request.host_with_port}#{url_for(params.merge(:format => :rss))}"
12
+ xml.tag! "atom:link", :rel => 'alternate', :href => "#{request.protocol}#{request.host_with_port}"
13
+ #xml.tag! "atom:link", :rel => 'search', :type => 'application/opensearchdescription+xml', :href => "http://#{request.host_with_port}/page/opensearch"
14
+ unless params[:query].blank?
15
+ xml.tag! "opensearch:totalResults", @count[:query_result]
16
+ xml.tag! "opensearch:startIndex", @answers.offset + 1
17
+ xml.tag! "opensearch:itemsPerPage", @answers.per_page
18
+ #xml.tag! "opensearch:Query", :role => 'request', :searchTerms => params[:query], :startPage => (params[:page] || 1)
19
+ end
20
+ @answers.each do |answer|
21
+ xml.item do
22
+ xml.title answer.body
23
+ #xml.description(answer.title)
24
+ # rfc822
25
+ xml.pubDate answer.created_at.utc.rfc822
26
+ xml.link "#{request.protocol}#{request.host_with_port}" + answer_path(answer)
27
+ xml.guid "#{request.protocol}#{request.host_with_port}" + answer_path(answer), :isPermaLink => "true"
28
+ end
29
+ end
30
+ }
31
+ }
@@ -0,0 +1,14 @@
1
+ <div id="content_detail" class="ui-corner-all">
2
+ <h1 class="title"><%= t('page.new', :model => t('activerecord.models.answer')) -%></h1>
3
+ <div id="content_list">
4
+ <%= render 'form' %>
5
+ </div>
6
+ </div>
7
+
8
+ <div id="submenu" class="ui-corner-all">
9
+ <ul>
10
+ <%- if @answer.question -%>
11
+ <li><%= link_to t('page.back'), question_answers_path(@answer.question) -%></li>
12
+ <%- end -%>
13
+ </ul>
14
+ </div>
@@ -0,0 +1,35 @@
1
+ <div data-role="header">
2
+ <h1 class="title"><%= t('page.showing', :model => t('activerecord.models.answer')) -%></h1>
3
+ </div>
4
+ <div data-role="content">
5
+ <div id="detail">
6
+
7
+ <%= form_for(@answer, :url => question_answers_path(@answer.question)) do |f| -%>
8
+ <%= f.error_messages -%>
9
+ <div class="field">
10
+ <%= f.label t('activerecord.models.question') -%><br />
11
+ <%= @answer.question.body -%>
12
+ <%= f.hidden_field :question_id, :value => @answer.question.id -%>
13
+ </div>
14
+
15
+ <div class="field">
16
+ <%= f.label :body -%><br />
17
+ <%= f.text_area :body, :class => 'resource_textarea' -%>
18
+ </div>
19
+
20
+ <div class="field">
21
+ <%= f.label :item_identifier_list -%><br />
22
+ <%= f.text_area :item_identifier_list, :class => 'resource_textarea' -%>
23
+ </div>
24
+
25
+ <div class="field">
26
+ <%= f.label :url_list -%><br />
27
+ <%= f.text_area :url_list, :class => 'resource_textarea' -%>
28
+ </div>
29
+
30
+ <div class="actions">
31
+ <%= f.submit %>
32
+ </div>
33
+ <%- end -%>
34
+ </div>
35
+ </div>
@@ -0,0 +1,54 @@
1
+ <div id="content_detail" class="ui-corner-all">
2
+ <h1 class="title"><%= t('page.showing', :model => t('activerecord.models.answer')) -%></h1>
3
+ <div id="content_list">
4
+ <p id="notice"><%= notice %></p>
5
+
6
+ <p>
7
+ <strong><%= t('activerecord.models.user') -%>:</strong>
8
+ <%= link_to @answer.user.username, @answer.user -%>
9
+ </p>
10
+
11
+ <p>
12
+ <strong><%= t('activerecord.models.question') -%>:</strong>
13
+ <%= link_to @answer.question.user.username, @answer.question.user -%>: <%= link_to @answer.question.body, @answer.question -%>
14
+ </p>
15
+
16
+ <p>
17
+ <strong><%= t('activerecord.attributes.answer.body') -%>:</strong>
18
+ <%= raw auto_link(textilize(h(@answer.body))) -%>
19
+ </p>
20
+
21
+ <p>
22
+ <ul>
23
+ <%- @answer.items.each do |item| -%>
24
+ <li>
25
+ <%= link_to item.manifestation.original_title, item.manifestation -%>
26
+ <% if item.item_identifier? %>
27
+ (<%= link_to item.item_identifier, item -%>)
28
+ <% end %>
29
+ </li>
30
+ <%- end -%>
31
+ </ul>
32
+ </p>
33
+
34
+ <p>
35
+ <strong><%= t('page.created_at') -%>:</strong>
36
+ <%= l(@answer.created_at) -%>
37
+ </p>
38
+
39
+ <p>
40
+ <strong><%= t('page.updated_at') -%>:</strong>
41
+ <%= l(@answer.updated_at) -%>
42
+ </p>
43
+
44
+ </div>
45
+ </div>
46
+
47
+ <div id="submenu" class="ui-corner-all">
48
+ <ul>
49
+ <%- if can? :update, @answer -%>
50
+ <li><%= link_to t('page.edit'), edit_answer_path(@answer) -%></li>
51
+ <%- end -%>
52
+ <li><%= link_to t('page.back'), question_answers_path(@answer.question) -%></li>
53
+ </ul>
54
+ </div>
@@ -0,0 +1,24 @@
1
+ <%- if user_signed_in? -%>
2
+ <ul>
3
+ <%- if current_user.has_role?('Librarian') -%>
4
+ <li><%= link_to t('question.all'), questions_path -%></li>
5
+ <%- end -%>
6
+ <%- if can? :create, Question -%>
7
+ <li><%= link_to t('question.my'), user_questions_path(current_user) -%></li>
8
+ <li><%= link_to t('page.new', :model => t('activerecord.models.question')), new_question_path -%></li>
9
+ <%- end -%>
10
+ </ul>
11
+ <%- end -%>
12
+
13
+ <%- if @crd_results -%>
14
+ <h4><%= link_to t('question.crd'), "http://crd.ndl.go.jp/" -%></h4>
15
+ <p><%= t('question.number_of_search_results', :count => @crd_results.total_entries) -%><br />
16
+ <ul>
17
+ <%- @crd_results.each do |result| -%>
18
+ <li><%= link_to h(truncate(result[:question])), result[:url] -%></li>
19
+ <%- end -%>
20
+ </ul>
21
+ <%= will_paginate(@crd_results, :param_name => :crd_page, :class => 'sidebar_pagination') -%>
22
+ <%- else -%>
23
+ <p><%= link_to t('question.you_can_search_crd'), "http://crd.ndl.go.jp/" -%></p>
24
+ <%- end -%>
@@ -0,0 +1,22 @@
1
+ <div id="content_detail" class="ui-corner-all">
2
+ <h1 class="title"><%= t('page.listing', :model => t('activerecord.models.question')) -%></h1>
3
+
4
+ <div id="content_list">
5
+ <%= form_for :questions, :url => questions_path, :html => {:method => 'get'} do -%>
6
+ <p>
7
+ <%= t('page.search_term') -%>: <%= search_field_tag 'query', h(@query), {:id => 'search_form_top', :class => 'search_form', :placeholder => t('page.search_term')} -%>
8
+ <%= submit_tag t('page.search') -%>
9
+ </p>
10
+ <%- end -%>
11
+
12
+ <%= render 'list' -%>
13
+ </div>
14
+ </div>
15
+
16
+ <div id="submenu" class="ui-corner-all">
17
+ <%= render 'solved_facet' -%>
18
+ <ul>
19
+ <li><%= link_to t('question.all'), questions_path %></li>
20
+ </ul>
21
+ <%= render 'crd' -%>
22
+ </div>
@@ -0,0 +1,18 @@
1
+ <div id="content_detail" class="ui-corner-all">
2
+ <h1 class="title"><%= t('page.listing', :model => t('activerecord.models.question')) -%></h1>
3
+ <div id="content_list">
4
+ <%= form_for :questions, :url => user_questions_path(@user), :html => {:method => 'get'} do -%>
5
+ <p>
6
+ <%= t('page.search_term') -%>: <%= search_field_tag 'query', h(@query), {:id => 'search_form_top', :class => 'search_form', :placeholder => t('page.search_term')} -%>
7
+ <%= submit_tag t('page.search') -%>
8
+ </p>
9
+ <%- end -%>
10
+
11
+ <%= render 'list' -%>
12
+ </div>
13
+ </div>
14
+
15
+ <div id="submenu" class="ui-corner-all">
16
+ <%= render 'solved_facet' -%>
17
+ <%= render 'crd' -%>
18
+ </div>
@@ -0,0 +1,69 @@
1
+ <div id="result_index">
2
+ <p>
3
+ <%= t('page.sort_by') -%>:
4
+ <%- if params[:sort_by].blank? -%>
5
+ <strong><%= t('question.last_answered_at') -%></strong>
6
+ <%- else -%>
7
+ <%= link_to t('question.last_answered_at'), params.merge(:sort_by => nil) -%>
8
+ <%- end -%>
9
+ <%- if params[:sort_by] == 'created_at' -%>
10
+ <strong><%= t('question.created_at') -%></strong>
11
+ <%- else -%>
12
+ <%= link_to t('question.created_at'), params.merge(:sort_by => 'created_at') -%>
13
+ <%- end -%>
14
+ <%- if params[:sort_by] == 'answers_count' -%>
15
+ <strong><%= t('activerecord.attributes.question.answers_count') -%></strong>
16
+ <%- else -%>
17
+ <%= link_to t('activerecord.attributes.question.answers_count'), params.merge(:sort_by => 'answers_count') -%>
18
+ <%- end -%>
19
+ </p>
20
+
21
+ <%- if @count[:query_result] > 0 -%>
22
+ <table class="index">
23
+ <tr>
24
+ <th><%= 'Id' -%></th>
25
+ <th><%= t('activerecord.models.question') -%></th>
26
+ <th></th>
27
+ <th id="edit_icons"></th>
28
+ </tr>
29
+
30
+ <%- @questions.each_with_index do |question, i| -%>
31
+ <tr class="line<%= cycle("0", "1") -%>">
32
+ <td style="width: 30px"><%= question.id -%></td>
33
+ <td>
34
+ <%= link_to truncate(question.body, :length => 60), question -%>
35
+ (<%= link_to question.user.username, question.user -%>)
36
+ <br />
37
+ <!--
38
+ <%= t('question.updated_at') %>: <%= l(question.updated_at) -%>
39
+ <br />
40
+ -->
41
+ <%= t('question.last_answered_at') %>: <%= l(question.answers.last.updated_at) if question.answers.last -%>
42
+ </td>
43
+ <td>
44
+ <%= link_to image_tag('icons/comments.png', :alt => t('answer.count'), :size => '16x16'), question %>
45
+ <%= link_to question.answers.size, question -%>
46
+ <%- if question.solved %>
47
+ <%= t('question.solved') %>
48
+ <% else %>
49
+ <%= t('question.not_solved') %>
50
+ <% end %>
51
+ </td>
52
+ <td>
53
+ <%- if can? :update, question -%>
54
+ <%= link_to image_tag('icons/page_white_edit.png', :alt => t('page.edit'), :size => '16x16'), edit_question_path(question), :confirm => t('page.are_you_sure'), :method => :delete -%>
55
+ <% end %>
56
+ <%- if can? :destroy, question -%>
57
+ <%= link_to image_tag('icons/delete.png', :alt => t('page.destroy'), :size => '16x16'), question, :confirm => t('page.are_you_sure'), :method => :delete -%>
58
+ <%- end -%>
59
+ </td>
60
+ </tr>
61
+ <%- end -%>
62
+ </table>
63
+ <%- else -%>
64
+ <p><%= t('question.no_record_found') -%></p>
65
+ <%- end -%>
66
+
67
+ <%= will_paginate(@questions, :class => 'content_pagination digg_pagination') -%>
68
+
69
+ </div>
@@ -0,0 +1,21 @@
1
+ <h4><%= t('activerecord.attributes.question.solved') -%></h4>
2
+ <ul>
3
+ <%- @question_facet.each do |facet| -%>
4
+ <li>
5
+ <%- if facet.value -%>
6
+ <%- if @solved == 'true' -%><strong><%- end -%>
7
+ <%= link_to localized_boolean(facet.value), url_for(params.merge(:page => nil, :solved => true, :view => nil)) -%>
8
+ (<%= facet.count -%>)
9
+ <%- if @solved == 'true' -%></strong><%- end -%>
10
+ <%- else -%>
11
+ <%- if @solved == 'false' -%><strong><%- end -%>
12
+ <%= link_to localized_boolean(facet.value), url_for(params.merge(:page => nil, :solved => 'false', :view => nil)) -%>
13
+ (<%= facet.count -%>)
14
+ <%- if @solved == 'false' -%></strong><%- end -%>
15
+ <%- end -%>
16
+ </li>
17
+ <%- end -%>
18
+ <%- if @solved -%>
19
+ <li><%= link_to t('page.remove_this_facet'), params.merge(:solved => nil, :page => nil, :view => nil) -%></li>
20
+ <%- end -%>
21
+ </ul>
@@ -0,0 +1,44 @@
1
+ <div id="content_detail" class="ui-corner-all">
2
+ <h1 class="title"><%= t('page.editing', :model => t('activerecord.models.question')) -%></h1>
3
+ <div id="content_list">
4
+
5
+ <%= simple_form_for(@question, :validate => true) do |f| -%>
6
+ <%= f.error_notification -%>
7
+
8
+ <div class="field">
9
+ <%= f.label t('activerecord.models.user') -%><br />
10
+ <%= link_to @question.user.username, @question.user -%>
11
+ </div>
12
+
13
+ <div class="field">
14
+ <%= f.label :body -%><br />
15
+ <%= f.text_area :body, :class => 'resource_textarea' -%>
16
+ </div>
17
+
18
+ <div class="field">
19
+ <%= f.label :shared -%>
20
+ <%= f.check_box :shared -%>
21
+ </div>
22
+
23
+ <div class="field">
24
+ <%= f.label :solved -%>
25
+ <%- if @question.user == current_user -%>
26
+ <%= f.check_box :solved -%>
27
+ <%- else -%>
28
+ <%= f.check_box :solved, :disabled => 'disabled' -%>
29
+ <%- end -%>
30
+ </div>
31
+
32
+ <div class="actions">
33
+ <%= f.submit %>
34
+ </div>
35
+ <%- end -%>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="submenu" class="ui-corner-all">
40
+ <ul>
41
+ <li><%= link_to t('page.show'), @question -%></li>
42
+ <li><%= link_to t('page.back'), user_questions_path(@question.user) -%></li>
43
+ </ul>
44
+ </div>
@@ -0,0 +1,16 @@
1
+ atom_feed(:url => questions_url(:format => :atom)) do |feed|
2
+ if @user
3
+ feed.title t('question.user_question', :login_name => @user.username)
4
+ else
5
+ feed.title t('question.library_group_question', :library_group_name => @library_group.display_name.localize)
6
+ end
7
+ feed.updated(@questions.first ? @questions.first.created_at : Time.zone.now)
8
+
9
+ @questions.each do |question|
10
+ feed.entry(question) do |entry|
11
+ entry.title(truncate(question.body))
12
+ entry.author(question.user.username)
13
+ entry.content(question.body)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ <%- if @user -%>
2
+ <%= render 'index_user' -%>
3
+ <%- else -%>
4
+ <%= render 'index' -%>
5
+ <%- end -%>
@@ -0,0 +1,2 @@
1
+ $("#result_index").html("<%= escape_javascript(render("list")) %>");
2
+ $("#submenu").html("<%= escape_javascript(render("crd")) %>");
@@ -0,0 +1,21 @@
1
+ <div data-role="header">
2
+ <h1 class="title"><%= t('page.listing', :model => t('activerecord.models.question')) -%></h1>
3
+ </div>
4
+
5
+ <div data-role="content">
6
+ <div data-role="fieldcontain">
7
+ <%= form_for :questions, :html => {:method => 'get'} do -%>
8
+ <label for="search_form_top"><%= t('page.search_term') -%>:</label>
9
+ <%= search_field_tag 'query', h(@query), {:id => 'search_form_top', :class => 'search_form', :placeholder => t('page.search_term')} -%>
10
+ <%= submit_tag t('page.search') -%>
11
+ <% end %>
12
+ </div>
13
+ </div>
14
+
15
+ <ul data-role="listview">
16
+ <% @questions.each do |question| %>
17
+ <li><%= link_to truncate(question.body, :length => 60), question -%></li>
18
+ <% end %>
19
+ </ul>
20
+
21
+ <%= will_paginate(@questions, :renderer => WillPaginateJqueryMobileRenderer) %>
@@ -0,0 +1,41 @@
1
+ xml.instruct! :xml, :version=>"1.0"
2
+ xml.rss('version' => "2.0",
3
+ 'xmlns:opensearch' => "http://a9.com/-/spec/opensearch/1.1/",
4
+ 'xmlns:atom' => "http://www.w3.org/2005/Atom"){
5
+ xml.channel{
6
+ if @user
7
+ xml.title t('question.user_question', :login_name => @user.username)
8
+ xml.link user_questions_url(@user)
9
+ else
10
+ xml.title t('question.library_group_question', :library_group_name => @library_group.display_name.localize)
11
+ xml.link questions_url
12
+ end
13
+ xml.description "Next-L Enju, an open source integrated library system developed by Project Next-L"
14
+ xml.language @locale.to_s
15
+ xml.ttl "60"
16
+ if @user
17
+ xml.tag! "atom:link", :rel => 'self', :href => user_questions_url(@user, :format => :rss)
18
+ xml.tag! "atom:link", :rel => 'alternate', :href => user_questions_url(@user)
19
+ else
20
+ xml.tag! "atom:link", :rel => 'self', :href => questions_url(:format => :rss)
21
+ xml.tag! "atom:link", :rel => 'alternate', :href => questions_url
22
+ end
23
+ #xml.tag! "atom:link", :rel => 'search', :type => 'application/opensearchdescription+xml', :href => "http://#{request.host_with_port}/page/opensearch"
24
+ unless params[:query].blank?
25
+ xml.tag! "opensearch:totalResults", @count[:query_result]
26
+ xml.tag! "opensearch:startIndex", @questions.offset + 1
27
+ xml.tag! "opensearch:itemsPerPage", @questions.per_page
28
+ #xml.tag! "opensearch:Query", :role => 'request', :searchTerms => params[:query], :startPage => (params[:page] || 1)
29
+ end
30
+ @questions.each do |question|
31
+ xml.item do
32
+ xml.title question.body
33
+ #xml.description(question.title)
34
+ # rfc822
35
+ xml.pubDate question.created_at.utc.rfc822
36
+ xml.link question_url(question)
37
+ xml.guid question_url(question), :isPermaLink => "true"
38
+ end
39
+ end
40
+ }
41
+ }
@@ -0,0 +1,36 @@
1
+ xml.instruct! :xml, :version=>"1.0" , :encoding => 'Shift_JIS'
2
+ xml.CRD('version' => "1.0"){
3
+ @questions.each do |question|
4
+ xml.REFERENCE{
5
+ xml.QUESTION question.body
6
+ xml.tag! 'ACC-LEVEL', '1'
7
+ xml.tag! 'REG-ID', "#{LibraryGroup.site_config.name}_#{question.id}"
8
+ xml.ANSWER question.answers.first.try(:body)
9
+ xml.tag! 'CRT-DATE', question.created_at.strftime('%Y%m%d')
10
+ if question.solved?
11
+ xml.SOLUTION 1
12
+ else
13
+ xml.SOLUTION 0
14
+ end
15
+ # xml.KEYWORD question.tags.collect(&:name).join(' ')
16
+ xml.KEYWORD question.tags.join(' ')
17
+ xml.CLASS :type => 'NDC'
18
+ xml.tag! 'RES-TYPE'
19
+ xml.tag! 'CON-TYPE'
20
+ question.answers.each do
21
+ xml.BIBL{
22
+ xml.tag! 'BIBL-DESC'
23
+ xml.tag! 'BIBL-NOTE'
24
+ }
25
+ end
26
+ xml.tag! 'ANS-PROC', question.answers.first.try(:body)
27
+ xml.REFERRAL
28
+ xml.tag! 'PRE-RES'
29
+ xml.NOTE question.note
30
+ xml.tag! 'PTN-TYPE'
31
+ if question.answers.exists?
32
+ xml.CONTRI question.answers.collect(&:user).collect(&:username).uniq.join(' ')
33
+ end
34
+ }
35
+ end
36
+ }
@@ -0,0 +1,35 @@
1
+ <div id="content_detail" class="ui-corner-all">
2
+ <h1 class="title"><%= t('page.new', :model => t('activerecord.models.question')) -%></h1>
3
+ <div id="content_list">
4
+
5
+ <%= simple_form_for(@question, :validate => true) do |f| -%>
6
+ <%= f.error_notification -%>
7
+
8
+ <div class="field">
9
+ <%= f.label t('activerecord.models.user') -%><br />
10
+ <%= link_to @question.user.username, @question.user -%>
11
+ </div>
12
+
13
+ <div class="field">
14
+ <%= f.label :body -%><br />
15
+ <%= f.text_area :body, :class => 'resource_textarea' -%>
16
+ </div>
17
+
18
+ <div class="field">
19
+ <%= f.label :shared -%>
20
+ <%= f.check_box :shared -%>
21
+ </div>
22
+
23
+ <div class="actions">
24
+ <%= f.submit %>
25
+ </div>
26
+ <%- end -%>
27
+
28
+ </div>
29
+ </div>
30
+
31
+ <div id="submenu" class="ui-corner-all">
32
+ <ul>
33
+ <li><%= link_to t('page.back'), user_questions_path(@question.user) -%></li>
34
+ </ul>
35
+ </div>
@@ -0,0 +1,62 @@
1
+ <div id="content_detail" class="ui-corner-all">
2
+ <h1 class="title"><%= t('page.showing', :model => t('activerecord.models.question')) -%></h1>
3
+ <div id="content_list">
4
+ <p id="notice"><%= notice %></p>
5
+
6
+ <p>
7
+ <strong><%= t('activerecord.models.user') -%>:</strong>
8
+ <%= link_to @question.user.username, @question.user -%>
9
+ </p>
10
+
11
+ <p>
12
+ <strong><%= t('activerecord.attributes.question.body') -%>:</strong>
13
+ <%= raw auto_link(textilize(h(@question.body))) -%>
14
+ </p>
15
+
16
+ <p>
17
+ <strong><%= t('activerecord.attributes.question.shared') -%>:</strong>
18
+ <%= localized_boolean(@question.shared) -%>
19
+ <strong><%= t('activerecord.attributes.question.solved') -%>:</strong>
20
+ <%= localized_boolean(@question.solved) -%>
21
+ </p>
22
+
23
+ <p>
24
+ <strong><%= t('page.created_at') -%>:</strong>
25
+ <%= l(@question.created_at) -%>
26
+ <strong><%= t('page.updated_at') -%>:</strong>
27
+ <%= l(@question.updated_at) -%>
28
+ </p>
29
+
30
+ <p>
31
+ <strong><%= link_to t('activerecord.models.answer'), question_answers_path(@question) -%>:</strong>
32
+ </p>
33
+
34
+ <ul>
35
+ <%- @question.answers.each do |answer| -%>
36
+ <li><%= link_to answer.user.username, answer.user -%>
37
+ (<%=l answer.updated_at %>)<br />
38
+ <%= raw auto_link(textilize(h(answer.body))) -%><br />
39
+ <% unless answer.items.empty? %>
40
+ <ul>
41
+ <% answer.items.each do |item| %>
42
+ <li><%= link_to item.manifestation.original_title, item.manifestation %><br /></li>
43
+ <% end %>
44
+ </ul>
45
+ <% end %>
46
+ </li>
47
+ <%- end -%>
48
+ </ul>
49
+
50
+ </div>
51
+ </div>
52
+
53
+ <div id="submenu" class="ui-corner-all">
54
+ <ul>
55
+ <li><%= link_to t('question.answer_question'), new_question_answer_path(@question) -%></li>
56
+ <%- if can? :update, @question -%>
57
+ <li><%= link_to t('page.edit'), edit_question_path(@question) -%></li>
58
+ <%- end -%>
59
+ <li><%= back_to_index(flash[:page_info]) -%></li>
60
+ <li><%= link_to 'レファレンス協同データベース用XMLファイル', question_path(@question, :mode => 'crd', :format => 'xml') -%></li>
61
+ </ul>
62
+ </div>
@@ -0,0 +1,46 @@
1
+ <div data-role="header">
2
+ <h1 class="title"><%= t('page.showing', :model => t('activerecord.models.question')) -%></h1>
3
+ </div>
4
+ <div data-role="content">
5
+ <div id="detail">
6
+
7
+ <p>
8
+ <strong><%= t('activerecord.attributes.question.body') -%>:</strong>
9
+ <%= raw auto_link(textilize(h(@question.body))) -%><br />
10
+ </p>
11
+
12
+ <p>
13
+ <strong><%= t('activerecord.models.user') -%>:</strong>
14
+ <%= link_to @question.user.username, @question.user -%>
15
+ <strong><%= t('activerecord.attributes.question.shared') -%>:</strong>
16
+ <%= localized_boolean(@question.shared) -%>
17
+ <strong><%= t('activerecord.attributes.question.solved') -%>:</strong>
18
+ <%= localized_boolean(@question.solved) -%>
19
+ </p>
20
+
21
+ <p>
22
+ <strong><%= t('page.created_at') -%>:</strong>
23
+ <%= l(@question.created_at) -%>
24
+ <strong><%= t('page.updated_at') -%>:</strong>
25
+ <%= l(@question.updated_at) -%>
26
+ </p>
27
+
28
+ <ul>
29
+ <%- @question.answers.each do |answer| -%>
30
+ <li><%= link_to answer.user.username, answer.user -%>
31
+ (<%=l answer.updated_at %>)<br />
32
+ <%= raw auto_link(textilize(h(answer.body))) -%><br />
33
+ <% unless answer.items.empty? %>
34
+ <ul>
35
+ <% answer.items.each do |item| %>
36
+ <li><%= link_to item.manifestation.original_title, item.manifestation %><br /></li>
37
+ <% end %>
38
+ </ul>
39
+ <% end %>
40
+ </li>
41
+ <%- end -%>
42
+ </ul>
43
+
44
+ <h3><%= link_to t('question.answer_question'), new_question_answer_path(@question) -%></h3>
45
+ </div>
46
+ </div>
@@ -0,0 +1,34 @@
1
+ xml.instruct! :xml, :version=>"1.0" , :encoding => 'Shift_JIS'
2
+ xml.CRD('version' => "1.0"){
3
+ xml.REFERENCE{
4
+ xml.QUESTION @question.body
5
+ xml.tag! 'ACC-LEVEL', '1'
6
+ xml.tag! 'REG-ID', "#{LibraryGroup.site_config.name}_#{@question.id}"
7
+ xml.ANSWER @question.answers.first.try(:body)
8
+ xml.tag! 'CRT-DATE', @question.created_at.strftime('%Y%m%d')
9
+ if @question.solved?
10
+ xml.SOLUTION 1
11
+ else
12
+ xml.SOLUTION 0
13
+ end
14
+ # xml.KEYWORD @question.tags.collect(&:name).join(' ')
15
+ xml.KEYWORD @question.tags.join(' ')
16
+ xml.CLASS :type => 'NDC'
17
+ xml.tag! 'RES-TYPE'
18
+ xml.tag! 'CON-TYPE'
19
+ @question.answers.each do
20
+ xml.BIBL{
21
+ xml.tag! 'BIBL-DESC'
22
+ xml.tag! 'BIBL-NOTE'
23
+ }
24
+ end
25
+ xml.tag! 'ANS-PROC', @question.answers.first.try(:body)
26
+ xml.REFERRAL
27
+ xml.tag! 'PRE-RES'
28
+ xml.NOTE @question.note
29
+ xml.tag! 'PTN-TYPE'
30
+ if @question.answers.exists?
31
+ xml.CONTRI @question.answers.collect(&:user).collect(&:username).uniq.join(' ')
32
+ end
33
+ }
34
+ }