Skip to content

Instantly share code, notes, and snippets.

@tanelj
Last active May 10, 2022 10:16
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanelj/d1f48f4c713cfee21c29 to your computer and use it in GitHub Desktop.
Save tanelj/d1f48f4c713cfee21c29 to your computer and use it in GitHub Desktop.
Small script to migrate content and/or elements between Voog CMS (www.voog.com) pages. Read more about Voog API www.voog.com/developers/api. Depends on https://gist.github.com/tanelj/a64d58185551976874d5
#!/usr/bin/env ruby
# Script to copy Voog (www.voog.com) page content areas and/or elements between pages.
# It uses functions from Voog migrator script https://gist.github.com/tanelj/a64d58185551976874d5, that should be in same folder.
require_relative 'voog_migrator'
def copy_articles!(mappings)
mappings.each do |k, v|
source_page = @migrator.source.page_by_path(k)
target_page = @migrator.target.page_by_path(v)
if source_page && target_page
puts "Coping articles from #{source_page.path} to #{target_page.path}"
@migrator.migrate_articles!(source_page, target_page)
end
end
end
def copy_elements!(mappings)
mappings.each do |k, v|
source_page = @migrator.source.page_by_path(k)
target_page = @migrator.target.page_by_path(v)
if source_page && target_page
puts "Coping elements from #{source_page.path} to #{target_page.path}"
@migrator.migrate_elements!(source_page, target_page)
end
end
end
def copy_contents!(mappings)
mappings.each do |k, v|
source_page = @migrator.source.page_by_path(k)
target_page = @migrator.target.page_by_path(v)
if source_page && target_page
puts "Coping content from #{source_page.path} to #{target_page.path}"
@migrator.migrate_content!(source_page, target_page, parent_kind: Voog::API::Contents::ParentKind::Page)
end
end
end
@conf = {
source_host: 'source-host.voog.com', source_api_token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
target_host: 'target-host.voog.com', target_api_token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
}
@migrator = VoogSiteMigrator.new(@conf)
@migrator.ensure_cache!
@migrator.target.print_site_tree;nil
mapping = {
# 'tooted/majad' => 'products/houses'
}
mapping_page_content = {
# 'meist' => 'about'
}
# Copy articles from one page to another
# copy_articles!(mapping)
# Copy elements from one page to another
# copy_elements!(mapping)
# Copy page contents from one page to another
# copy_contents!(mapping_page_content)
@joniahola
Copy link

How this would work? It is only print site tree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment