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.8KB

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