Skip to content

Commit

Permalink
move sitemap static storage to data directory
Browse files Browse the repository at this point in the history
  • Loading branch information
jdshaw committed Feb 25, 2020
1 parent 2520a0e commit d0d10a6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ For users with access to `Background Jobs`, there is a new entry in the `Create
3. What types of objects to include in the sitemap. At least one is required.
4. The update frequency. For most institutions, yearly is probably fine.
5. Use human readable slugs. Slugs generated by the user or the application will be used in the `<loc>` field if they are available. (v2.6.0+)
6. Write to local filesystem. Sitemaps will be written to a static space and to the root of the PUI webspace. The generated sitemaps are stored in `plugins/aspace_sitemap/frontend/assets/sitemaps/`
6. Write to local filesystem. Sitemaps will be written to a static space and to the root of the PUI webspace. The generated sitemaps are stored in `AppConfig[:data_directory]/pui_sitemaps`
and at the root of the site ie: `{pui_host}/sitemap-index.xml` It also updates the robots.txt file in the PUI to include the sitemap entry. Any existing sitemaps are copied to the
PUI webroot on startup and the robots.txt file is updated on startup if there are existing sitemap files.

Expand Down
2 changes: 1 addition & 1 deletion backend/job_runners/aspace_sitemap_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run
# muck about with paths and filenames depending on if we are writing to the filesystem
@index_filename = "sitemap-index"
@sitemap_index_loc = @json.job['sitemap_use_filesys'] ? "#{@pui_base_url}" : sitemap_index_base_url
@static_page_loc = File.join("#{ASUtils.find_local_directories(nil, 'aspace_sitemap').shift}","frontend","assets","sitemaps")
@static_page_loc = File.join(AppConfig[:data_directory],"pui_sitemaps")
@sitemap_filename_prefix = "aspace_sitemap_part_"

# this should never happen
Expand Down
10 changes: 10 additions & 0 deletions backend/plugin_init.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'fileutils'

# this is ugly since we set these in both the frontend and backend
# better to have end user set in config or not?
AppConfig[:allowed_sitemap_types_hash] = {'resource' => 'resources',
Expand All @@ -14,3 +16,11 @@
AppConfig[:sitemap_agent_types] = ['people','families','corporate_entities','software']
AppConfig[:sitemap_frequencies] = ['yearly', 'monthly', 'daily', 'hourly', 'always', 'never']
AppConfig[:aspace_sitemap_default_limit] = 50000

# create the pui sitemaps directory if it does not already exist
ArchivesSpaceService.loaded_hook do
dirname = File.join(AppConfig[:data_directory], "pui_sitemaps")
unless File.directory?(dirname)
FileUtils.mkdir_p(dirname)
end
end
1 change: 0 additions & 1 deletion frontend/assets/sitemaps/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion public/plugin_init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
if Rails.root.basename.to_s == 'WEB-INF' # only need to do this when running out of unpacked .war
dest = Rails.root.dirname
if dest.directory? && dest.writable?
sitemap_files = File.join("#{ASUtils.find_local_directories(nil, 'aspace_sitemap').shift}","frontend","assets","sitemaps","*.xml")
sitemap_files = File.join(AppConfig[:data_directory], "pui_sitemaps","*.xml")
FileUtils.cp_r Dir.glob(sitemap_files), dest, :verbose => true
end

Expand Down

0 comments on commit d0d10a6

Please sign in to comment.