Command-line.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <!DOCTYPE html>
  2. <html dir="ltr">
  3. <head>
  4. <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  5. <title>Dev/Command-line - XOWA</title>
  6. <link rel="shortcut icon" href="https://gnosygnu.github.io/xowa/xowa_logo.png" />
  7. <link rel="stylesheet" href="https://gnosygnu.github.io/xowa/xowa_common.css" type="text/css">
  8. <style data-source="xowa" type="text/css">
  9. .console {font-family: monospace; color: #EEEEEE ; background-color: black ; border: medium solid black;}
  10. .code
  11. ,.path
  12. ,.url {font-family: monospace; color: black ; background-color: #f9f9f9 ; border: medium solid #f9f9f9;}
  13. .bold {font-weight: 900;}
  14. </style>
  15. </head>
  16. <body class="mediawiki ltr sitedir-ltr ns-0 ns-subject skin-vector action-submit vector-animateLayout" spellcheck="false">
  17. <div id="mw-page-base" class="noprint"></div>
  18. <div id="mw-head-base" class="noprint"></div>
  19. <div id="content" class="mw-body">
  20. <h1 id="firstHeading" class="firstHeading"><span>Dev/Command-line</span></h1>
  21. <div id="bodyContent" class="mw-body-content">
  22. <div id="siteSub">From XOWA: the free, open-source, offline wiki application</div>
  23. <div id="contentSub"></div>
  24. <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr">
  25. <p>
  26. XOWA can import a wiki using a plain text file and a command-line.
  27. </p>
  28. <div id="toc" class="toc">
  29. <div id="toctitle" class="toctitle">
  30. <h2>
  31. Contents
  32. </h2>
  33. </div>
  34. <ul>
  35. <li class="toclevel-1 tocsection-1">
  36. <a href="#Import_simple.wikipedia.org_through_the_command-line"><span class="tocnumber">1</span> <span class="toctext">Import simple.wikipedia.org through the command-line</span></a>
  37. </li>
  38. <li class="toclevel-1 tocsection-2">
  39. <a href="#Import_a_different_wiki_by_editing_the_build_script"><span class="tocnumber">2</span> <span class="toctext">Import a different wiki by editing the build script</span></a>
  40. </li>
  41. <li class="toclevel-1 tocsection-3">
  42. <a href="#Import_a_wiki_with_a_manual_download"><span class="tocnumber">3</span> <span class="toctext">Import a wiki with a manual download</span></a>
  43. <ul>
  44. <li class="toclevel-2 tocsection-4">
  45. <a href="#Download_the_wiki_dump"><span class="tocnumber">3.1</span> <span class="toctext">Download the wiki dump</span></a>
  46. </li>
  47. <li class="toclevel-2 tocsection-5">
  48. <a href="#Specify_location_of_the_wiki_dump"><span class="tocnumber">3.2</span> <span class="toctext">Specify location of the wiki dump</span></a>
  49. </li>
  50. </ul>
  51. </li>
  52. <li class="toclevel-1 tocsection-6">
  53. <a href="#Script"><span class="tocnumber">4</span> <span class="toctext">Script</span></a>
  54. </li>
  55. </ul>
  56. </div>
  57. <h2>
  58. <span class="mw-headline" id="Import_simple.wikipedia.org_through_the_command-line">Import simple.wikipedia.org through the command-line</span>
  59. </h2>
  60. <ul>
  61. <li>
  62. Open up a command-line. For example, on Windows, run <span class='bold'>cmd</span>
  63. </li>
  64. <li>
  65. Run the following: <span class='console'>java -jar C:\000\200_dev\110_java\100_core\out\production\400_xowa\ --cmd_file C:\xowa_release\xowa_build.gfs --app_mode cmd</span>
  66. </li>
  67. <li>
  68. Wait about 10 minutes for the script to complete
  69. </li>
  70. <li>
  71. Launch XOWA and enter <span class='url'>simple.wikipedia.org</span> in the URL bar
  72. </li>
  73. </ul>
  74. <h2>
  75. <span class="mw-headline" id="Import_a_different_wiki_by_editing_the_build_script">Import a different wiki by editing the build script</span>
  76. </h2>
  77. <ul>
  78. <li>
  79. Open the following file in a <a href="/wiki/Dev/Environment/Text_editor" id="xolnki_2" title="Dev/Environment/Text editor">text editor</a>: <span class='path'>C:\xowa_release\xowa_build.gfs</span>. See Script below for the full text.
  80. </li>
  81. <li>
  82. Replace all instances of <span class='bold'>simple.wikipedia.org</span> with the domain name. For example, for English Wikipedia, use <span class='bold'>en.wikipedia.org</span>
  83. </li>
  84. <li>
  85. Run the command-line import again.
  86. </li>
  87. <li>
  88. Launch XOWA and enter in the domain name in the the URL bar.
  89. </li>
  90. </ul>
  91. <h2>
  92. <span class="mw-headline" id="Import_a_wiki_with_a_manual_download">Import a wiki with a manual download</span>
  93. </h2>
  94. <h3>
  95. <span class="mw-headline" id="Download_the_wiki_dump">Download the wiki dump</span>
  96. </h3>
  97. <ul>
  98. <li>
  99. Navigate to <a href="https://dumps.wikimedia.org/enwiki" rel="nofollow" class="external free">https://dumps.wikimedia.org/enwiki</a>
  100. </li>
  101. <li>
  102. Click on the <b>latest</b> directory
  103. </li>
  104. <li>
  105. Download the file just under "<b>Articles, templates, media/file descriptions, and primary meta-pages.</b>". It should read <b>enwiki-latest-pages-articles.xml.bz2</b>
  106. </li>
  107. </ul>
  108. <dl>
  109. <dd>
  110. The download is 11+ GB and may take anywhere between 2 and 5 hours to complete.
  111. </dd>
  112. <dd>
  113. If you also want talk pages, you should download the "<b>Recombine all pages, current versions only.</b>" version. It should read <b>enwiki-latest-pages-meta-current.xml.bz2</b>. Note that this dump is twice the size of the regular dump.
  114. </dd>
  115. </dl>
  116. <h3>
  117. <span class="mw-headline" id="Specify_location_of_the_wiki_dump">Specify location of the wiki dump</span>
  118. </h3>
  119. <ul>
  120. <li>
  121. In the build script, replace the following line:
  122. </li>
  123. </ul>
  124. <dl>
  125. <dd>
  126. <span class='code'>add ('simple.wikipedia.org', 'text.init') {src_bz2_fil = '/your_directory/simplewiki-20130103-pages-articles.xml.bz2';}</span>
  127. </dd>
  128. </dl>
  129. <h2>
  130. <span class="mw-headline" id="Script">Script</span>
  131. </h2>
  132. <pre class='code'>
  133. // do not show a "Press enter to continue" at the end of the script
  134. app.bldr.pause_at_end = 'n';
  135. // run xowa.gfs
  136. app.scripts.run_file_by_type('xowa_cfg_app');
  137. // import wiki; for more info see [[Dev/Command-line]]
  138. app.bldr.cmds {
  139. // delete all files in directory; note that subdirectories and file databases ("-file.xowa") will not be deleted
  140. add ('simple.wikipedia.org' , 'util.cleanup') {delete_all = 'y';}
  141. // download main dump file; contains all articles
  142. add ('simple.wikipedia.org' , 'util.download') {dump_type = 'pages-articles';}
  143. // download categorylinks file; contains links from category to pages
  144. add ('simple.wikipedia.org' , 'util.download') {dump_type = 'categorylinks';}
  145. // download page_props file; contains information on hidden categories
  146. add ('simple.wikipedia.org' , 'util.download') {dump_type = 'page_props';}
  147. // start wiki import
  148. add ('simple.wikipedia.org' , 'text.init');
  149. // import articles
  150. add ('simple.wikipedia.org' , 'text.page');
  151. // generate search data
  152. add ('simple.wikipedia.org' , 'text.search');
  153. // end import
  154. add ('simple.wikipedia.org' , 'text.term');
  155. // import css into wiki
  156. add ('simple.wikipedia.org' , 'text.css');
  157. // create main category table (also mark hidden categories)
  158. add ('simple.wikipedia.org' , 'wiki.page_props');
  159. // create category links
  160. add ('simple.wikipedia.org' , 'wiki.categorylinks');
  161. // cleanup temp files; delete xml and bz2
  162. add ('simple.wikipedia.org' , 'util.cleanup') {delete_tmp = 'y'; delete_by_match('*.xml|*.sql|*.bz2|*.gz');}
  163. }
  164. // run cmds
  165. app.bldr.run;
  166. </pre>
  167. </div>
  168. </div>
  169. </div>
  170. <div id="mw-head" class="noprint">
  171. <div id="left-navigation">
  172. <div id="p-namespaces" class="vectorTabs">
  173. <h3>Namespaces</h3>
  174. <ul>
  175. <li id="ca-nstab-main" class="selected"><span><a id="ca-nstab-main-href" href="index.html">Page</a></span></li>
  176. </ul>
  177. </div>
  178. </div>
  179. </div>
  180. <div id='mw-panel' class='noprint'>
  181. <div id='p-logo'>
  182. <a style="background-image: url(https://gnosygnu.github.io/xowa/xowa_logo.png);" href="http://xowa.org/" title="Visit the main page"></a>
  183. </div>
  184. <div class="portal" id='xowa-portal-home'>
  185. <h3>XOWA</h3>
  186. <div class="body">
  187. <ul>
  188. <li><a href="http://xowa.org/index.html" title='Visit the main page'>Main page</a></li>
  189. <li><a href="http://xowa.org/screenshots.html" title='See screenshots of XOWA'>Screenshots</a></li>
  190. <li><a href="https://www.youtube.com/watch?v=q0qbXYXEH6M" title="See a video of XOWA Desktop in action">Video</a></li>
  191. <li><a href="http://xowa.org/home/wiki/Help/Download_XOWA.html" title='Download the XOWA application'>Download XOWA</a></li>
  192. <li><a href="http://xowa.org/home/wiki/Dashboard/Image_databases.html" title='Download offline wikis and image databases'>Download wikis</a></li>
  193. </ul>
  194. </div>
  195. </div>
  196. <div class="portal" id='xowa-portal-started'>
  197. <h3>Getting started</h3>
  198. <div class="body">
  199. <ul>
  200. <li><a href="http://xowa.org/home/wiki/App/Setup/System_requirements.html" title='Get XOWA&apos;s system requirements'>Requirements</a></li>
  201. <li><a href="http://xowa.org/home/wiki/App/Setup/Installation.html" title='Get instructions for installing XOWA'>Installation</a></li>
  202. <li><a href="http://xowa.org/home/wiki/App/Import/Simple_Wikipedia.html" title='Learn how to set up Simple Wikipedia'>Simple Wikipedia</a></li>
  203. <li><a href="http://xowa.org/home/wiki/App/Import/English_Wikipedia.html" title='Learn how to set up English Wikipedia'>English Wikipedia</a></li>
  204. <li><a href="http://xowa.org/home/wiki/App/Import/Other_wikis.html" title='Learn how to set up other Wikipedias'>Other Wikipedias</a></li>
  205. </ul>
  206. </div>
  207. </div>
  208. <div class="portal" id='xowa-portal-android'>
  209. <h3>Android</h3>
  210. <div class="body">
  211. <ul>
  212. <li><a href="http://xowa.org/home/wiki/Android/Setup.html" title='Setup XOWA on your Android device'>Setup</a></li>
  213. <li><a href="https://www.youtube.com/watch?v=jsMTBxGweUw" title="See a video of XOWA Android in action">Video</a></li>
  214. </ul>
  215. </div>
  216. </div>
  217. <div class="portal" id='xowa-portal-help'>
  218. <h3>Help</h3>
  219. <div class="body">
  220. <ul>
  221. <li><a href="http://xowa.org/home/wiki/Help/About.html" title='Get more information about XOWA'>About</a></li>
  222. <li><a href="http://xowa.org/home/wiki/Help/Contents.html" title='View a list of help topics'>Contents</a></li>
  223. <li><a href="http://xowa.org/home/wiki/Help/Media.html" title='Read what others have written about XOWA'>Media</a></li>
  224. <li><a href="http://xowa.org/home/wiki/Help/Feedback.html" title='Questions? Comments? Leave feedback for XOWA'>Feedback</a></li>
  225. </ul>
  226. </div>
  227. </div>
  228. <div class="portal" id='xowa-portal-blog'>
  229. <h3>Blog</h3>
  230. <div class="body">
  231. <ul>
  232. <li><a href="http://xowa.org/home/wiki/Blog.html" title='Follow XOWA''s development process'>Current</a></li>
  233. </ul>
  234. </div>
  235. </div>
  236. <div class="portal" id='xowa-portal-links'>
  237. <h3>Links</h3>
  238. <div class="body">
  239. <ul>
  240. <li><a href="http://dumps.wikimedia.org/backup-index.html" title="Get wiki datababase dumps directly from Wikimedia">Wikimedia dumps</a></li>
  241. <li><a href="https://archive.org/search.php?query=xowa" title="Search archive.org for XOWA files">XOWA @ archive.org</a></li>
  242. <li><a href="http://en.wikipedia.org" title="Visit Wikipedia (and compare to XOWA!)">English Wikipedia</a></li>
  243. </ul>
  244. </div>
  245. </div>
  246. <div class="portal" id='xowa-portal-donate'>
  247. <h3>Donate</h3>
  248. <div class="body">
  249. <ul>
  250. <li><a href="https://archive.org/donate/index.php" title="Support archive.org!">archive.org</a></li><!-- listed first due to recent fire damages: http://blog.archive.org/2013/11/06/scanning-center-fire-please-help-rebuild/ -->
  251. <li><a href="https://donate.wikimedia.org/wiki/Special:FundraiserRedirector" title="Support Wikipedia!">Wikipedia</a></li>
  252. <li><a href="http://xowa.org/home/wiki/Help/Donate.html" title="Support XOWA!">XOWA</a></li>
  253. </ul>
  254. </div>
  255. </div>
  256. </div>
  257. </body>
  258. </html>