|
26 | 26 | os.system('mkdir output') |
27 | 27 | os.system('cp -rt output reference/*') |
28 | 28 |
|
| 29 | +# rearrange the archive |
| 30 | + |
| 31 | +# before |
| 32 | +# output/en.cppreference.com/w/ : html |
| 33 | +# output/en.cppreference.com/mwiki/ : data |
| 34 | +# output/en.cppreference.com/ : data |
| 35 | +# ... (other languages) |
| 36 | +# output/upload.cppreference.com/mwiki/ : data |
| 37 | + |
| 38 | +# after |
| 39 | +# output/common/ : all data |
| 40 | +# output/en/ : html for en |
| 41 | +# ... (other languages) |
| 42 | + |
| 43 | +data_path = "output/common" |
| 44 | +os.system('mkdir ' + data_path) |
| 45 | +os.system('mv output/upload.cppreference.com/mwiki/* ' + data_path) |
| 46 | +os.system('rm -r output/upload.cppreference.com/') |
| 47 | + |
| 48 | +for lang in ["en"]: |
| 49 | + path = "output/" + lang + ".cppreference.com/" |
| 50 | + src_html_path = path + "w/" |
| 51 | + src_data_path = path + "mwiki/" |
| 52 | + html_path = "output/" + lang |
| 53 | + |
| 54 | + if (os.path.isdir(src_html_path)): |
| 55 | + os.system('mv ' + src_html_path + ' ' + html_path) |
| 56 | + |
| 57 | + if (os.path.isdir(src_data_path)): |
| 58 | + # the skin files should be the same for all languages thus we |
| 59 | + # can merge everything |
| 60 | + os.system('cp -rl ' + src_data_path + '/* ' + data_path) |
| 61 | + os.system('rm -r ' + src_data_path) |
| 62 | + |
| 63 | + # also copy the custom fonts |
| 64 | + os.system('cp ' + path + 'DejaVuSansMonoCondensed60.ttf ' + |
| 65 | + path + 'DejaVuSansMonoCondensed75.ttf ' + data_path) |
| 66 | + # remove what's left |
| 67 | + os.system('rm -r '+ path) |
| 68 | + |
29 | 69 | # find all html and css files |
30 | 70 | html_files = [] |
31 | 71 | css_files = [] |
|
56 | 96 | os.system('xsltproc --novalid --html preprocess.xsl "' + fn + '" > "' + tmpfile + '"') |
57 | 97 | os.system('mv "' + tmpfile + '" "' + fn + '"') |
58 | 98 |
|
| 99 | +# append css modifications to the css files |
| 100 | +for fn in css_files: |
| 101 | + f = open(fn, "r") |
| 102 | + text = f.read() |
| 103 | + f.close() |
59 | 104 |
|
60 | | -os.system('cat preprocess-css.css >> "output/en.cppreference.com/mwiki/load7fe1.css"') |
| 105 | + r = re.compile('DejaVuSansMonoCondensed60') |
| 106 | + if (r.search(text)): |
| 107 | + # assume this is minified MediaWiki:Common.css |
| 108 | + # append the modifications |
| 109 | + os.system('cat preprocess-css.css >> "'+fn+'"') |
0 commit comments