enju_leaf 1.1.0.rc9 → 1.1.0.rc10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/user_import_file.rb +39 -32
  3. data/app/models/user_import_file_state_machine.rb +19 -0
  4. data/app/models/user_import_file_transition.rb +7 -0
  5. data/app/views/page/_menu.html.erb +1 -3
  6. data/app/views/page/configuration.html.erb +13 -7
  7. data/app/views/page/export.html.erb +5 -0
  8. data/app/views/user_groups/index.html.erb +2 -0
  9. data/app/views/user_import_results/index.html.erb +2 -2
  10. data/app/views/users/_form.html.erb +1 -10
  11. data/app/views/users/new.html.erb +1 -1
  12. data/config/initializers/statesman.rb +3 -0
  13. data/config/locales/translation_en.yml +1 -1
  14. data/config/locales/translation_ja.yml +2 -2
  15. data/db/migrate/20140524074813_create_user_import_file_transitions.rb +14 -0
  16. data/db/migrate/20140610123439_drop_email_unique_constraint_enju_leaf_rc10.rb +11 -0
  17. data/lib/enju_leaf.rb +9 -0
  18. data/lib/enju_leaf/bookmark_url.rb +45 -0
  19. data/lib/enju_leaf/calculate_stat.rb +30 -0
  20. data/lib/enju_leaf/engine.rb +1 -0
  21. data/lib/enju_leaf/expire_editable_fragment.rb +30 -0
  22. data/lib/enju_leaf/expire_fragment_cache.rb +17 -0
  23. data/lib/enju_leaf/import_file.rb +13 -0
  24. data/lib/enju_leaf/localized_name.rb +15 -0
  25. data/lib/enju_leaf/master_model.rb +21 -0
  26. data/lib/enju_leaf/url_validator.rb +10 -0
  27. data/lib/enju_leaf/user.rb +1 -1
  28. data/lib/enju_leaf/version.rb +1 -1
  29. data/spec/dummy/config/initializers/statesman.rb +3 -0
  30. data/spec/dummy/db/migrate/20130421093852_add_periodical_to_manifestation.rb +5 -0
  31. data/spec/dummy/db/migrate/20130429020822_add_root_manifestation_id_to_series_statement.rb +6 -0
  32. data/spec/dummy/db/migrate/20130506175303_create_identifier_types.rb +12 -0
  33. data/spec/dummy/db/migrate/20130506175834_create_identifiers.rb +15 -0
  34. data/spec/dummy/db/schema.rb +57 -2
  35. data/spec/dummy/db/test.sqlite3 +0 -0
  36. data/spec/dummy/private/system/user_import_files/user_imports/980/190/963/original/user_import_file_sample.tsv +7 -5
  37. data/spec/dummy/solr/default/data/index/_2h.fdt +0 -0
  38. data/spec/dummy/solr/default/data/index/{_ug.fdx → _2h.fdx} +0 -0
  39. data/spec/dummy/solr/default/data/index/{_ug.fnm → _2h.fnm} +0 -0
  40. data/spec/dummy/solr/default/data/index/{_ug.nvd → _2h.nvd} +0 -0
  41. data/spec/dummy/solr/default/data/index/{_ug.nvm → _2h.nvm} +0 -0
  42. data/spec/dummy/solr/default/data/index/{_ug.si → _2h.si} +0 -0
  43. data/spec/dummy/solr/default/data/index/{_ug_Lucene41_0.doc → _2h_Lucene41_0.doc} +0 -0
  44. data/spec/dummy/solr/default/data/index/{_ug_Lucene41_0.pos → _2h_Lucene41_0.pos} +0 -0
  45. data/spec/dummy/solr/default/data/index/{_ug_Lucene41_0.tim → _2h_Lucene41_0.tim} +0 -0
  46. data/spec/dummy/solr/default/data/index/{_ug_Lucene41_0.tip → _2h_Lucene41_0.tip} +0 -0
  47. data/spec/dummy/solr/default/data/index/segments.gen +0 -0
  48. data/spec/dummy/solr/default/data/index/segments_57 +0 -0
  49. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000176 +0 -0
  50. data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000002343 → tlog.0000000000000000177} +0 -0
  51. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000178 +0 -0
  52. data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000002345 → tlog.0000000000000000179} +0 -0
  53. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000180 +0 -0
  54. data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000002347 → tlog.0000000000000000181} +0 -0
  55. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000182 +0 -0
  56. data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000002349 → tlog.0000000000000000183} +0 -0
  57. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000184 +0 -0
  58. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000185 +0 -0
  59. data/spec/models/user_import_file_spec.rb +34 -7
  60. data/spec/routing/resource_import_files_routing_spec.rb +35 -0
  61. metadata +107 -55
  62. data/app/assets/stylesheets/scaffold.css +0 -56
  63. data/spec/dummy/solr/default/data/index/_ug.fdt +0 -0
  64. data/spec/dummy/solr/default/data/index/segments_1td +0 -0
  65. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002342 +0 -0
  66. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002344 +0 -0
  67. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002346 +0 -0
  68. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002348 +0 -0
  69. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002350 +0 -0
  70. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002351 +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8dd72d60431ce017b6e0338731f59395a3bd0e6d
4
- data.tar.gz: 44a890255ac3e0d19eddd9ecea9e11ece3c94482
3
+ metadata.gz: abf8301bf438bd48a00db3b8c08ed8892bb827cb
4
+ data.tar.gz: ece67d49714be04367a3fbf8e5ed8c7e41686d0c
5
5
  SHA512:
6
- metadata.gz: 337ff6f9b61732c1ab2154bb8710dd4cc3e48c303d8ab0291e5011a7519c35150e78609d42dbcf4ae30e903fff0f80f9275d243952232d4901994a44aaa94a18
7
- data.tar.gz: 9698e2603a8815bd5e47ff35343776990c7125e6f18882a781acad7f2bfdd3a5d094ded545c54586f00c1ff9ded54f489e71c1d96bd81579dd85bacf7022b60d
6
+ metadata.gz: 5c854e5b0ee69714f5023aab0359aacf57ebb2fe2554ef61fc5d85209ff2aa9622859927b16c7cdb395912bfef36ae7f2f137c254a9c9fa59d5058e8f45660c4
7
+ data.tar.gz: ab3ed970a465ce237c9047752757589fb45fa9cd36bc45e77cf6874c7b9f6849e531397421196cd70f2ddcd4f6219919646f7ee580a6b7c2935ae886574d242b
@@ -1,9 +1,10 @@
1
1
  class UserImportFile < ActiveRecord::Base
2
2
  attr_accessible :user_import, :edit_mode
3
+ include Statesman::Adapters::ActiveRecordModel
3
4
  include ImportFile
4
5
  default_scope {order('user_import_files.id DESC')}
5
- scope :not_imported, -> {where(:state => 'pending')}
6
- scope :stucked, -> {where('created_at < ? AND state = ?', 1.hour.ago, 'pending')}
6
+ scope :not_imported, -> {in_state(:pending)}
7
+ scope :stucked, -> {in_state(:pending).where('created_at < ? AND state = ?', 1.hour.ago)}
7
8
 
8
9
  if Setting.uploaded_file.storage == :s3
9
10
  has_attached_file :user_import, :storage => :s3,
@@ -24,28 +25,15 @@ class UserImportFile < ActiveRecord::Base
24
25
  belongs_to :user, :validate => true
25
26
  has_many :user_import_results
26
27
 
27
- state_machine :initial => :pending do
28
- event :sm_start do
29
- transition [:pending, :started] => :started
30
- end
31
-
32
- event :sm_complete do
33
- transition :started => :completed
34
- end
28
+ has_many :user_import_file_transitions
35
29
 
36
- event :sm_fail do
37
- transition :started => :failed
38
- end
39
-
40
- before_transition any => :started do |user_import_file|
41
- user_import_file.executed_at = Time.zone.now
42
- end
43
-
44
- before_transition any => :completed do |user_import_file|
45
- user_import_file.error_message = nil
46
- end
30
+ def state_machine
31
+ @state_machine ||= UserImportFileStateMachine.new(self, transition_class: UserImportFileTransition)
47
32
  end
48
33
 
34
+ delegate :can_transition_to?, :transition_to!, :transition_to, :current_state,
35
+ to: :state_machine
36
+
49
37
  def import_start
50
38
  case edit_mode
51
39
  when 'create'
@@ -60,14 +48,13 @@ class UserImportFile < ActiveRecord::Base
60
48
  end
61
49
 
62
50
  def import
63
- sm_start!
64
- reload
51
+ transition_to!(:started)
65
52
  num = {:user_imported => 0, :user_found => 0, :failed => 0}
66
53
  rows = open_import_file
67
54
  row_num = 2
68
55
 
69
56
  field = rows.first
70
- if [field['username']].reject{|field| field.to_s.strip == ""}.empty?
57
+ if [field['username']].reject{|f| f.to_s.strip == ""}.empty?
71
58
  raise "username column is not found"
72
59
  end
73
60
 
@@ -85,10 +72,18 @@ class UserImportFile < ActiveRecord::Base
85
72
  num[:user_found] += 1
86
73
  else
87
74
  new_user = User.new
75
+ new_user.role = Role.where(:name => row['role']).first
76
+ if new_user.role
77
+ unless user.has_role?(new_user.role.name)
78
+ num[:failed] += 1
79
+ next
80
+ end
81
+ else
82
+ new_user.role = Role.find(2) # User
83
+ end
88
84
  new_user.operator = user
89
85
  new_user.username = username
90
86
  new_user.email = row['email'] if row['email'].present?
91
- new_user.role = Role.where(:name => row['role']).first
92
87
  if row['user_group'].present?
93
88
  new_user.user_group = UserGroup.where(:name => row['user_group']).first
94
89
  end
@@ -97,13 +92,21 @@ class UserImportFile < ActiveRecord::Base
97
92
  new_user.expired_at = Time.zone.parse(row['expired_at']).end_of_day
98
93
  end
99
94
  new_user.note = row['note']
95
+
96
+ if I18n.available_locales.include?(row['locale'].to_s.to_sym)
97
+ new_user.locale = row['locale']
98
+ end
99
+
100
+ library = Library.where(:name => row['library'].to_s.strip).first || Library.web
101
+ new_user.library = library
102
+
100
103
  if row['password'].present?
101
104
  new_user.password = row['password']
102
105
  else
103
106
  new_user.set_auto_generated_password
104
107
  end
105
108
 
106
- if new_user.save!
109
+ if new_user.save
107
110
  num[:user_imported] += 1
108
111
  import_result.user = new_user
109
112
  import_result.save!
@@ -114,22 +117,22 @@ class UserImportFile < ActiveRecord::Base
114
117
  end
115
118
 
116
119
  rows.close
117
- sm_complete!
120
+ transition_to!(:completed)
118
121
  Sunspot.commit
119
122
  num
120
123
  rescue => e
121
124
  self.error_message = "line #{row_num}: #{e.message}"
122
- sm_fail!
125
+ transition_to!(:failed)
123
126
  raise e
124
127
  end
125
128
 
126
129
  def modify
127
- sm_start!
128
- sm_complete!
130
+ transition_to!(:started)
131
+ transition_to!(:completed)
129
132
  end
130
133
 
131
134
  def remove
132
- sm_start!
135
+ transition_to!(:started)
133
136
  reload
134
137
  rows = open_import_file
135
138
 
@@ -143,10 +146,14 @@ class UserImportFile < ActiveRecord::Base
143
146
  user = User.where(:username => username).first
144
147
  user.destroy if user
145
148
  end
146
- sm_complete!
149
+ transition_to!(:completed)
147
150
  end
148
151
 
149
152
  private
153
+ def self.transition_class
154
+ UserImportFileTransition
155
+ end
156
+
150
157
  def open_import_file
151
158
  tempfile = Tempfile.new('user_import_file')
152
159
  if Setting.uploaded_file.storage == :s3
@@ -0,0 +1,19 @@
1
+ class UserImportFileStateMachine
2
+ include Statesman::Machine
3
+
4
+ state :pending, initial: true
5
+ state :started
6
+ state :completed
7
+ state :failed
8
+
9
+ transition from: :pending, to: :started
10
+ transition from: :started, to: [:completed, :failed]
11
+
12
+ before_transition(from: :pending, to: :started) do |user_import_file|
13
+ user_import_file.executed_at = Time.zone.now
14
+ end
15
+
16
+ before_transition(from: :started, to: :completed) do |user_import_file|
17
+ user_import_file.error_message = nil
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ class UserImportFileTransition < ActiveRecord::Base
2
+ include Statesman::Adapters::ActiveRecordTransition
3
+
4
+
5
+ belongs_to :user_import_file, inverse_of: :user_import_file_transitions
6
+ attr_accessible :to_state, :sort_key, :metadata
7
+ end
@@ -108,9 +108,7 @@
108
108
  <li><%= link_to t('user.management'), users_path -%></li>
109
109
  <li><%= link_to t('page.agent_management'), agents_path -%></li>
110
110
  <li><%= link_to t('page.import'), page_import_path -%></li>
111
- <!--
112
- <li><%= link_to t('page.export'), 'page/export' -%></li>
113
- -->
111
+ <li><%= link_to t('page.export'), page_export_path -%></li>
114
112
  <% if defined?(EnjuPurchaseRequest) %>
115
113
  <li><%= link_to t('activerecord.models.order_list'), order_lists_path -%></li>
116
114
  <% end %>
@@ -11,8 +11,11 @@
11
11
  </ul>
12
12
  </li>
13
13
  <li><%= link_to t('activerecord.models.user_group'), user_groups_path -%></li>
14
- <li><%= link_to t('activerecord.models.user'), users_path -%></li>
15
- <li><%= link_to t('activerecord.models.user_import_file'), user_import_files_path -%></li>
14
+ <li><%= link_to t('activerecord.models.user'), users_path -%>
15
+ <ul>
16
+ <li><%= link_to t('activerecord.models.user_import_file'), user_import_files_path -%></li>
17
+ </ul>
18
+ </li>
16
19
  <% if defined?(EnjuCirculation) %>
17
20
  <li><%= link_to t('activerecord.models.checkout_type'), checkout_types_path -%>
18
21
  <ul>
@@ -45,9 +48,10 @@
45
48
  <div class="config_box">
46
49
  <ul>
47
50
  <li><%= link_to t('activerecord.models.manifestation'), manifestations_path -%>
48
- <ul>
49
- <li><%= link_to t('item.all_item'), items_path %></li>
50
- </ul>
51
+ <ul>
52
+ <li><%= link_to t('item.all_item'), items_path %></li>
53
+ <li><%= link_to t('activerecord.models.resource_import_file'), resource_import_files_path -%></li>
54
+ </ul>
51
55
  </li>
52
56
  <li><%= link_to t('activerecord.models.identifier_type'), identifier_types_path -%>
53
57
  <% if defined?(EnjuBookmark) %>
@@ -60,8 +64,10 @@
60
64
  <li><%= link_to t('activerecord.models.purchase_request'), purchase_requests_path -%></li>
61
65
  <li><%= link_to t('activerecord.models.order_list'), order_lists_path -%></li>
62
66
  <% end %>
67
+ <!--
63
68
  <li><%= link_to t('activerecord.models.subscription'), subscriptions_path -%></li>
64
- <!-- <li><%= link_to t('activerecord.models.donate'), donates_path -%></li> -->
69
+ <li><%= link_to t('activerecord.models.donate'), donates_path -%></li>
70
+ -->
65
71
  <% if defined?(EnjuInventory) %>
66
72
  <li><%= link_to t('activerecord.models.inventory'), inventory_files_path -%></li>
67
73
  <% end %>
@@ -104,10 +110,10 @@
104
110
  <li><%= link_to t('activerecord.models.language'), languages_path -%></li>
105
111
  <li><%= link_to t('activerecord.models.country'), countries_path -%></li>
106
112
  <li><%= link_to t('activerecord.models.frequency'), frequencies_path -%></li>
113
+ <!--
107
114
  <li><%= link_to t('activerecord.models.agent_relationship_type'), agent_relationship_types_path -%></li>
108
115
  <li><%= link_to t('activerecord.models.manifestation_relationship_type'), manifestation_relationship_types_path -%></li>
109
116
  <li><%= link_to t('activerecord.models.license'), licenses_path -%></li>
110
- <!--
111
117
  <li><%= link_to t('activerecord.models.create_type'), create_types_path -%></li>
112
118
  <li><%= link_to t('activerecord.models.realize_type'), realize_types_path -%></li>
113
119
  <li><%= link_to t('activerecord.models.produce_type'), produce_types_path -%></li>
@@ -3,6 +3,7 @@
3
3
  <div id="content_list">
4
4
 
5
5
  <ul>
6
+ <!--
6
7
  <li>
7
8
  <%= t('activerecord.models.agent') -%>
8
9
  (<%= link_to 'CSV', agents_path(:format => :csv) -%>)
@@ -21,6 +22,10 @@
21
22
  <%= t('activerecord.models.item') -%>
22
23
  (<%= link_to 'CSV', items_path(:format => :csv) -%>)
23
24
  </li>
25
+ -->
26
+ <li>
27
+ <%= link_to t('activerecord.models.resource_export_file'), new_resource_export_file_path -%>
28
+ </li>
24
29
  </ul>
25
30
  </div>
26
31
  </div>
@@ -5,6 +5,7 @@
5
5
  <table class="table table-striped index">
6
6
  <tr>
7
7
  <th id="position"></th>
8
+ <th><%= t('activerecord.attributes.user_group.name') -%></th>
8
9
  <th><%= t('activerecord.attributes.user_group.display_name') -%></th>
9
10
  <th><%= t('activerecord.attributes.user_group.note') -%></th>
10
11
  <th></th>
@@ -17,6 +18,7 @@
17
18
  <%= move_position(user_group) -%>
18
19
  <%- end -%>
19
20
  </td>
21
+ <td><%= link_to user_group.name, user_group -%></td>
20
22
  <td><%= link_to user_group.display_name.localize, user_group -%></td>
21
23
  <td><%= user_group.note -%></td>
22
24
  <td>
@@ -40,10 +40,10 @@
40
40
  <li>
41
41
  <% if @user_import_file %>
42
42
  <%= link_to((image_tag 'icons/page_white_excel.png', :size => '16x16', :alt => 'TSV', :class => 'icon'), user_import_file_user_import_results_path(@user_import_file, :format => :csv, :locale => @locale.to_s)) -%>
43
- (<%= link_to 'CSV', user_import_file_user_import_results_path(:format => :csv, :locale => @locale.to_s) -%>)
43
+ (<%= link_to 'TSV', user_import_file_user_import_results_path(:format => :csv, :locale => @locale.to_s) -%>)
44
44
  <% else %>
45
45
  <%= link_to((image_tag 'icons/page_white_excel.png', :size => '16x16', :alt => 'CSV', :class => 'icon'), user_import_results_path(:format => :csv, :locale => @locale.to_s)) -%>
46
- (<%= link_to 'CSV', user_import_results_path(:format => :csv, :locale => @locale.to_s) -%>)
46
+ (<%= link_to 'TSV', user_import_results_path(:format => :csv, :locale => @locale.to_s) -%>)
47
47
  <% end %>
48
48
  </li>
49
49
  </ul>
@@ -1,14 +1,5 @@
1
1
  <%= form_for(@user) do |f| %>
2
- <% if @user.errors.any? %>
3
- <div id="errorExplanation">
4
- <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
5
- <ul>
6
- <% @user.errors.full_messages.each do |msg| %>
7
- <li><%= msg %></li>
8
- <% end %>
9
- </ul>
10
- </div>
11
- <% end %>
2
+ <%= f.error_notification -%>
12
3
 
13
4
  <div class="field">
14
5
  <%= f.label :username %><br />
@@ -28,7 +28,7 @@
28
28
 
29
29
  <div class="field">
30
30
  <%= f.label :user_group_id -%>
31
- <%= f.select(:user_group_id, @user_groups.collect{|u| [u.name, u.id]}) -%>
31
+ <%= f.select(:user_group_id, @user_groups.collect{|u| [u.display_name.localize, u.id]}) -%>
32
32
  </div>
33
33
 
34
34
  <%- if current_user.has_role?('Librarian') -%>
@@ -0,0 +1,3 @@
1
+ Statesman.configure do
2
+ storage_adapter(Statesman::Adapters::ActiveRecord)
3
+ end
@@ -37,7 +37,7 @@ en:
37
37
  state: State
38
38
  agent: Agent
39
39
  library: Library
40
- user_group: User group
40
+ user_group_id: User group
41
41
  full_name: Full name
42
42
  password: Password
43
43
  current_password: Current password
@@ -37,7 +37,7 @@ ja:
37
37
  state: 状態
38
38
  agent: 人物・団体
39
39
  library: 所属館
40
- user_group: ユーザグループ
40
+ user_group_id: 利用者グループ
41
41
  full_name: 氏名
42
42
  password: パスワード
43
43
  current_password: 現在のパスワード
@@ -318,7 +318,7 @@ ja:
318
318
  no_number: "番号なし"
319
319
  add_lending_policy: "貸出規則の追加"
320
320
  edit_exemplification: "書誌の付け替え"
321
- accepted_at: "受入時刻"
321
+ accepted_at: "検収時刻"
322
322
  agent:
323
323
  library_group_agent: "%{library_group_name} の人物・団体"
324
324
  work_agent: "%{work_title} の著作者"
@@ -0,0 +1,14 @@
1
+ class CreateUserImportFileTransitions < ActiveRecord::Migration
2
+ def change
3
+ create_table :user_import_file_transitions do |t|
4
+ t.string :to_state
5
+ t.text :metadata, default: "{}"
6
+ t.integer :sort_key
7
+ t.integer :user_import_file_id
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :user_import_file_transitions, :user_import_file_id
12
+ add_index :user_import_file_transitions, [:sort_key, :user_import_file_id], unique: true, name: "index_user_import_file_transitions_on_sort_key_and_file_id"
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ class DropEmailUniqueConstraintEnjuLeafRc10 < ActiveRecord::Migration
2
+ def up
3
+ remove_index :users, :email
4
+ add_index :users, :email
5
+ end
6
+
7
+ def down
8
+ remove_index :users, :email
9
+ add_index :users, :email, unique: true
10
+ end
11
+ end
data/lib/enju_leaf.rb CHANGED
@@ -3,6 +3,15 @@ require "enju_leaf/version"
3
3
  require "enju_leaf/controller"
4
4
  require "enju_leaf/user"
5
5
  require "enju_leaf/helper"
6
+ require "enju_leaf/calculate_stat"
7
+ require "enju_leaf/bookmark_url"
8
+ require "enju_leaf/calculate_stat"
9
+ require "enju_leaf/expire_editable_fragment"
10
+ require "enju_leaf/expire_fragment_cache"
11
+ require "enju_leaf/import_file"
12
+ require "enju_leaf/localized_name"
13
+ require "enju_leaf/master_model"
14
+ require "enju_leaf/url_validator"
6
15
 
7
16
  require 'csv'
8
17
  #require 'mathn'
@@ -0,0 +1,45 @@
1
+ module BookmarkUrl
2
+ def my_host?
3
+ url = ::Addressable::URI.parse(self)
4
+ unless url.host
5
+ raise ::Addressable::URI::InvalidURIError
6
+ end
7
+ config_url = ::Addressable::URI.parse(LibraryGroup.site_config.url)
8
+ if url.host == config_url.host and url.port == config_url.port and ['http', 'https'].include?(url.scheme)
9
+ true
10
+ else
11
+ false
12
+ end
13
+ end
14
+
15
+ def bookmarkable?
16
+ if self.my_host?
17
+ url = ::Addressable::URI.parse(self)
18
+ path = url.path.split("/").reverse
19
+ if path[1] == "manifestations" and Manifestation.where(:id => path[0]).first
20
+ true
21
+ else
22
+ false
23
+ end
24
+ else
25
+ true
26
+ end
27
+ rescue ::Addressable::URI::InvalidURIError
28
+ false
29
+ end
30
+
31
+ def bookmarkable_id
32
+ if self.my_host?
33
+ path = ::Addressable::URI.parse(self).path.split("/").reverse
34
+ unless path[1] == "manifestations"
35
+ nil
36
+ else
37
+ path[0]
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ class String
44
+ include BookmarkUrl
45
+ end