KXStudio Website https://kx.studio/
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.

create-manual-pages.py 5.6KB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #!/usr/bin/env python3
  2. import os
  3. manualPages = (
  4. "kxstudio_introduction",
  5. "kxstudio_and_free_software",
  6. "installing_kxstudio",
  7. "package_management",
  8. "video_drivers",
  9. "included_and_recommended_apps",
  10. "linux_audio_overview",
  11. "alsa_and_kxstudio",
  12. "cadence_introduction",
  13. "jack_configuration",
  14. "simple_claudia_studio",
  15. "latency",
  16. "wineasio_and_reaper",
  17. "useful_links_and_getting_help"
  18. )
  19. for page in manualPages:
  20. print(page)
  21. tmppage = "tmp_%s" % page
  22. webpage = "http://wiki.linuxaudio.org/wiki/%s" % page
  23. os.system("wget %s -O %s" % (webpage, tmppage))
  24. tmppageFd = open(tmppage, "r")
  25. tmppageRead = tmppageFd.read().strip()
  26. tmppageFd.close()
  27. # remove initial html code
  28. readPart1 = tmppageRead.split("<!-- wikipage start -->", 1)[1].strip()
  29. # remove TOC, if any
  30. readPart2 = readPart1.split("<!-- TOC END -->", 1)[-1].strip()
  31. # remove final html code
  32. readPart3 = readPart2.split("<!-- wikipage stop -->", 1)[0].strip()
  33. # remove first part of the page, we want the title
  34. readPart4 = readPart3.split("<h1 class=\"sectionedit1\"><a name=", 1)[1].strip()
  35. # get the title
  36. kxPageTitle = readPart4.split(">", 1)[1].split("</a>", 1)[0].strip()
  37. # remove initial bits of html code (title)
  38. readPart5 = readPart4.split("</h1>", 1)[1].strip()
  39. # custom mods
  40. readPart5 = readPart5.replace("/_detail/wiki/cadence.png?id=wiki%3Acadence_introduction",
  41. "<?php echo $ROOT; ?>/screenshots/cadence1.png")
  42. readPart5 = readPart5.replace("/_media/wiki/cadence.png",
  43. "<?php echo $ROOT; ?>/screenshots/cadence1.png")
  44. readPart5 = readPart5.replace("/_detail/wiki/cadence-wineasio.png?id=wiki%3Awineasio_and_reaper",
  45. "<?php echo $ROOT; ?>/screenshots/cadence3.png")
  46. readPart5 = readPart5.replace("/_media/wiki/cadence-wineasio.png",
  47. "<?php echo $ROOT; ?>/screenshots/cadence3.png")
  48. readPart5 = readPart5.replace("/_detail/wiki/cadence-jack-settings.png?id=wiki%3Ajack_configuration",
  49. "<?php echo $ROOT; ?>/screenshots/cadence-jacksettings2.png")
  50. readPart5 = readPart5.replace("/_media/wiki/cadence-jack-settings.png",
  51. "<?php echo $ROOT; ?>/screenshots/cadence-jacksettings2.png")
  52. readPart5 = readPart5.replace("/_detail/wiki/claudia2.png?id=wiki%3Asimple_claudia_studio",
  53. "<?php echo $ROOT; ?>/screenshots/claudia-qtractor.png")
  54. readPart5 = readPart5.replace("/_media/wiki/claudia2.png",
  55. "<?php echo $ROOT; ?>/screenshots/claudia-qtractor.png")
  56. readPart5 = readPart5.replace("/_detail/wiki/kmixer.png?id=wiki%3Aalsa_and_kxstudio",
  57. "<?php echo $ROOT; ?>/screenshots/kmix.png")
  58. readPart5 = readPart5.replace("/_media/wiki/kmixer.png",
  59. "<?php echo $ROOT; ?>/screenshots/kmix.png")
  60. k1 = '<a href="/_detail/wiki/kmix-tray.png?id=wiki%3Aalsa_and_kxstudio" class="media" title="wiki:kmix-tray.png">'
  61. k2 = '<img src="/_media/wiki/kmix-tray.png" class="media" title="The kmix icon" alt="The kmix icon" />'
  62. k3 = '</a>'
  63. readPart5 = readPart5.replace(k1+k2+k3, k2)
  64. readPart5 = readPart5.replace('?w=500" class="mediacenter" alt="" width="500"', '" class="media" alt=""')
  65. # html cleanup
  66. for i in range(2, 10):
  67. readPart5 = readPart5.replace(" class=\"sectionedit%i\"" % i, "")
  68. readPart5 = readPart5.replace("<h2><a name=", "<h2><span name=").replace("</a></h2>", "</span></h2>")
  69. readPart5 = readPart5.replace("<h3><a name=", "<h3><span name=").replace("</a></h3>", "</span></h3>")
  70. readPart5 = readPart5.replace("/_detail/wiki/", "http://wiki.linuxaudio.org/_detail/wiki/")
  71. readPart5 = readPart5.replace("/_media/wiki/", "http://wiki.linuxaudio.org/_media/wiki/")
  72. readPart5 = readPart5.replace('href="/wiki/', 'target="_blank" href="http://wiki.linuxaudio.org/wiki/')
  73. readPart5 = readPart5.replace('title="wiki:', 'title="')
  74. # FIXME: this should happen on the wiki
  75. readPart5 = readPart5.replace("kxstudio.sourceforge.net", "kxstudio.linuxaudio.org")
  76. # final adjustment
  77. readPart5 = readPart5.replace(" The &#039;UAC3553B&#039; tab displays controls for a USB audio device whilst &#039;Playback Streams&#039; can be ignored unless you are using PulseAudio.",
  78. "")
  79. readPart5 = readPart5.replace("as &#039;Mic&#039; and &#039;Mic Boost&#039; do", "as &#039;Beep&#039; does")
  80. readPart5 = readPart5.replace('href="http://kxstudio.linuxaudio.org/', 'href="<?php echo $ROOT; ?>/')
  81. readPart5 = readPart5.replace('title="http://kxstudio.linuxaudio.org/', 'title="')
  82. kxPageContent = '<?php\n'
  83. kxPageContent += '$PAGE_TITLE = "KXStudio";\n'
  84. kxPageContent += '$PAGE_TYPE = "NONKXSTUDIO";\n'
  85. kxPageContent += '$PAGE_SOURCE_1 = ARRAY("/Documentation", "/Documentation", "/Documentation:Manual:%s");\n' % page
  86. kxPageContent += '$PAGE_SOURCE_2 = ARRAY("Documentation", "Manual", "%s");\n' % kxPageTitle
  87. kxPageContent += 'include_once("includes/header.php");\n'
  88. kxPageContent += '?>\n'
  89. kxPageContent += '\n'
  90. kxPageContent += readPart5
  91. kxPageContent += '\n'
  92. kxPageContent += '\n'
  93. kxPageContent += '<p><br/></p>\n'
  94. kxPageContent += '\n'
  95. kxPageContent += '<?php\n'
  96. kxPageContent += 'include_once("includes/footer.php");\n'
  97. kxPageContent += '?>\n'
  98. pageFd = open("Documentation:Manual:%s.php" % page, "w")
  99. pageFd.write(kxPageContent)
  100. pageFd.close()
  101. # removing temporary file
  102. os.remove(tmppage)