openstax_content 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed22f20143aaa95ef57af3f123e218992d12320a2f3fc11181312aae26fc7372
4
- data.tar.gz: 717b1f2bdce0faa6282fb3cbfef02845a590f2dab6be6cca515e4cb3e113c0dc
3
+ metadata.gz: b17dd5822cd85c27b9d83850a0324d3633ef05bfd11793b9ac05bb734a0b8de3
4
+ data.tar.gz: 36be3946382c3f472ca4cc200ad2e7899505d4abc4101f0d94caebe287fc8d19
5
5
  SHA512:
6
- metadata.gz: 31c7272f68a28f24aeb69b1a6f04bb8323976e484392e835d828b68c58838fe9a164ce54b2be073400c15485525d40359d7ea279fe3b8c64caeeb9d59476437b
7
- data.tar.gz: 1eae72c6d0e78d02ae0152a741e90be6363ddac96b6670fe44080fe207b082e9fe54615ec9b316d1de8ce3394f7c0ed6aea79767c26b951486f5d793cb995c4f
6
+ metadata.gz: d32296abfb1ff02ea5781b62caf6616516459bb66f7a6615fdee3dc66481749f09c42e89df7ff28846b0a5fb97677b8d683150c0e60fa3c8eb4f0c7e870659b9
7
+ data.tar.gz: fab8643c3358e3cf02be92f59da7a3fc73338dbf679b1e38eeb4fc1364dc8d117c87913de960643e74c649806509694ebf56e68c38c1863e523191fa3d31f8e5
@@ -105,4 +105,29 @@ class OpenStax::Content::Archive
105
105
  slug
106
106
  end
107
107
  end
108
+
109
+ def webview_uri_for(page)
110
+ uri = if page.is_a?(Addressable::URI)
111
+ page
112
+ else
113
+ begin
114
+ Addressable::URI.parse page
115
+ rescue Addressable::URI::InvalidURIError
116
+ begin
117
+ Addressable::URI.parse "/#{page}"
118
+ rescue Addressable::URI::InvalidURIError
119
+ OpenStax::Content.logger.warn { "Invalid page url: \"#{page}\"" }
120
+
121
+ return page
122
+ end
123
+ end
124
+ end
125
+ object = uri.path.split('/').last
126
+ book_id, page_id = object.split(':', 2)
127
+ page_uuid = page_id.split('@', 2).first
128
+ book_slug = slug book_id
129
+ page_slug = slug object
130
+ uri.path = "books/#{book_slug}/pages/#{page_slug}"
131
+ Addressable::URI.join "https://#{OpenStax::Content.domain}", uri
132
+ end
108
133
  end
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Content
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_content
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dante Soares
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-28 00:00:00.000000000 Z
11
+ date: 2021-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3