schoolie 0.1.2 → 0.1.3

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: a242116cac43cc3deaebac1e2baa11548e77ee7b53840832abc011fd76242b81
4
- data.tar.gz: 235885b2b5945c48dabfaeb2806cd268fae3ecdf4b7c46f16e4ad8b19f9dcbb2
3
+ metadata.gz: be154513ab375404085cb27f1f613f981806d363310ab9a338ddbdf23ebd2c6e
4
+ data.tar.gz: 6b367c4bfb76739d28a0d20fbc1685db68977d04aa14710230ae8958a18d4dc0
5
5
  SHA512:
6
- metadata.gz: 6b00b1c4d8788b169279b2a85867762b05c3d45b38a2f79313adf35758ea72244660471e2be379b9cb299a0141f67804313d4eb76eb900f442b91e9cf68bf654
7
- data.tar.gz: 23a9e2060c67fd8056d1a5a3c7738ddd47ea763143bb1c2235981ab898f08a2cf3fd27d675c940b55bef29dd53d45c5c19eea20e3c1e76200d99dc237620f29c
6
+ metadata.gz: 7cd533267eca777564624d01462e8c9ff2df2416cccd83e6fff289f9a30d7cda9e19b03ec5be39fea0c48d9ec391730c805f85f3abb706a7299eef1ccf487e9f
7
+ data.tar.gz: 5c49117108e7f738809ef74394ccc0c8b37c805e295fd78dbddc62b516899c9a1349f700211931fdca7eb2c3b3a0e9e7239ae9dffab54f06bc9af70abb0fe5d1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- schoolie (0.1.2)
4
+ schoolie (0.1.3)
5
5
  actionview (~> 5)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <a href="https://codeclimate.com/github/curationexperts/schoolie/maintainability"><img src="https://api.codeclimate.com/v1/badges/bc6ef5bc9e76c6c3dcc9/maintainability" /></a>
4
4
  [![Coverage Status](https://coveralls.io/repos/github/curationexperts/schoolie/badge.svg?branch=main)](https://coveralls.io/github/curationexperts/schoolie?branch=main)
5
5
 
6
- The gem that generates a site map and meta tags for google scholar
6
+ A gem that generates a site map and meta tags for google scholar (or any other tags you might want)
7
7
 
8
8
  ## Installation
9
9
 
@@ -23,21 +23,20 @@ Or install it yourself as:
23
23
 
24
24
  ## Usage
25
25
 
26
- In order to map your particular metadata into the google scholar fields, create a file in Rails.root/config named schoolie.yml.
27
-
26
+ Install your schoolie configuration file in ```config/schoolie.yml```
28
27
 
29
28
  This file should contain contents similar to this:
30
29
 
31
30
  ```
32
31
  ---
33
- :static:
34
- Institution: Emory & University
35
- :attributes:
36
- Title: title
37
- Author: creator
38
- Abstract: abstract
39
- Type: submitting_type
40
- Date: degree_awarded
32
+ static:
33
+ citation_dissertation_institution: Your University
34
+ attributes:
35
+ citation_title: title
36
+ citation_author: creator
37
+ citation_date: publication_date
38
+ citation_keywords: keywords
39
+ citation_pdf_url: permanent_url
41
40
  ```
42
41
 
43
42
  The 'static' section will be written directly into the meta tags as is, attributes will be sent as method calls to the current curation
@@ -50,13 +49,55 @@ Missing methods will be ignored.
50
49
  bundle exec rails schoolie:sitemap
51
50
  ```
52
51
 
53
- This will generate a sitemap in public/sitemap.txt You should refer to this file in your robots.txt
52
+ The 'static' section maps a particular meta tag name to a static string
53
+
54
+ The attributes section maps meta tag names to _methods that will be
55
+ called on whatever you pass into the ```schoolie_tags``` helper_.
56
+
57
+ If the method does not exist, the tag will not be generated (though no
58
+ error will be thrown).
54
59
 
55
- NB. this task just uses curl to query solr currently, so make sure you have that installed first
56
60
 
57
- ## Development
61
+ Call the helper like any other helper in your view:
62
+
63
+
64
+ ```erb
65
+ <%= schoolie_tags my_object %>
66
+ ```
67
+ That's all there is to it!
68
+
69
+ ## SiteMaps
70
+
71
+ If you'd like to generate a sitemap for your Hyrax-based application, a simple rake task can be used (not included in schoolie):
72
+
73
+ ```ruby
74
+ task sitemap: :environment do
75
+ date_field = 'system_modified_dtsi'
76
+ result = ActiveFedora::SolrService.query("has_model_ssim:MyModel",
77
+ fq: "selectin_criteria:here",
78
+ fl: "id,#{date_field}",
79
+ sort: "sort_field,sortfield ASC",
80
+ rows: 20_000)
81
+ ids = result.map do |x|
82
+ ["https://etd.example.com/concern/theses/#{x['id']}", x[date_field].to_s]
83
+ end
84
+ builder = Nokogiri::XML::Builder.new do |sitemap|
85
+ sitemap.urlset("xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
86
+ xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9",
87
+ "xsi:schemaLocation": "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd") {
88
+ ids.each { |url, date|
89
+ sitemap.url {
90
+ sitemap.loc url
91
+ sitemap.lastmod date
92
+ }
93
+ }
94
+ }
95
+ end
96
+ File.open(Rails.root.join("public", "sitemap.xml"), "w") { |f| f.write(builder.to_xml) }
97
+ end
98
+ ```
58
99
 
59
- Check out the repo, and bundle install as per normal.
100
+ Don't forget to add your sitemap url to robots.txt too!
60
101
 
61
102
  ## Contributing
62
103
 
@@ -10,11 +10,16 @@ module SchoolieHelper
10
10
  tags = m["static"].map do |k, v|
11
11
  tag.meta(name: k, value: v)
12
12
  end
13
- tags << m["attributes"].map do |k, v|
14
- tag.meta(name: k, value: concern.send(v))
15
- rescue StandardError
16
- warn("Undefined attribute mapping: #{k} -> #{v}")
17
- end
13
+ tags = m["attributes"].inject(tags) do |m, (k, v)|
14
+ begin
15
+ [concern.send(v)].flatten.each do |z|
16
+ m << tag.meta(name: k, value: z)
17
+ end
18
+ rescue StandardError
19
+ warn("Undefined attribute mapping: #{k} -> #{v}")
20
+ end
21
+ m
22
+ end
18
23
  tags.join("\n")
19
24
  end
20
25
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Schoolie
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schoolie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - McClain Looney
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-02 00:00:00.000000000 Z
11
+ date: 2022-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.3.4
126
+ rubygems_version: 3.2.28
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: A gem to generate sitemaps & meta tags for Samvera repositories