The documentation for Plume. https://docs.joinplu.me/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

87 lines
2.2 KiB

  1. require "pathname"
  2. BUILD_DIR = Pathname("build")
  3. LOCALE_DIR = Pathname("trans")
  4. TRANS_DIR = Pathname("translate")
  5. PSEUDO_LANG = "ach"
  6. CROWDIN_SNIPPET = <<EOS
  7. <script type="text/javascript">
  8. var _jipt = [];
  9. _jipt.push(['project', 'plume-docs']);
  10. _jipt.push(['escape', function() {
  11. window.location.href = 'https://joinplu.me';
  12. }]);
  13. </script>
  14. <script type="text/javascript" src="//cdn.crowdin.com/jipt/jipt.js"></script>
  15. EOS
  16. class Pathname
  17. alias to_str to_s
  18. end
  19. desc "Run all tasks"
  20. task :all => ["crowdin:upload", :wait_trans_updated, :deploy, :deploy_trans]
  21. task :wait_trans_updated do
  22. sleep 30
  23. end
  24. desc "Build site"
  25. task :build_site => [:build_base, "crowdin:download"] do
  26. LOCALE_DIR.glob("**/*.html").each do |html|
  27. dest = Pathname(html.to_path.sub(%r|#{LOCALE_DIR}/([^/]+)/trans|, "#{BUILD_DIR}/\\1"))
  28. next if dest.file?
  29. dest.parent.mkpath
  30. copy html, dest
  31. end
  32. end
  33. task :build_base do
  34. sh "bundle", "exec", "middleman", "build"
  35. end
  36. desc "Build site for translate.docs.joinplu.me"
  37. task :build_trans => "crowdin:download" do
  38. sh "bundle", "exec", "middleman", "build", "--build-dir", TRANS_DIR
  39. (LOCALE_DIR/PSEUDO_LANG/"trans").glob("**/*.html").each do |html|
  40. doc = html.read
  41. doc.sub! "<head>", "<head>" + CROWDIN_SNIPPET
  42. dest = Pathname(html.to_path.sub(LOCALE_DIR/PSEUDO_LANG/"trans", TRANS_DIR))
  43. $stderr.puts "#{html} -> #{dest}"
  44. dest.write doc
  45. end
  46. end
  47. task :build_trans_src do
  48. sh "bundle", "exec", "middleman", "build", "--build-dir", LOCALE_DIR
  49. end
  50. desc "Deploy docs.joinplue.me"
  51. task :deploy => :build_site do
  52. sh "netlify", "deploy", "--site", "40419055-f669-42be-8d07-0c1dcc0dc24b", "--dir", BUILD_DIR, "--prod"
  53. end
  54. desc "Deploy translate.docs.joinplue.me"
  55. task :deploy_trans => :build_trans do
  56. sh "netlify", "deploy", "--site", "2b1e232b-ac98-4680-9ab4-6d4eee0d84cb", "--dir", TRANS_DIR, "--prod"
  57. end
  58. namespace :crowdin do
  59. desc "Download translations"
  60. task :download => :build_trans_src do
  61. sh "crowdin", "download"
  62. end
  63. desc "Upload translation sources"
  64. task :upload => :build_trans_src do
  65. sh "crowdin", "upload", "sources"
  66. end
  67. task :download_pseudo do
  68. sh "crowdin", "download", "--pseudo"
  69. end
  70. end