def processHTML(src, depth): src = os.path.normpath(src) prefix = os.path.splitext(src)[0] suffix = os.path.splitext(src)[1][1:] if suffix != DEFAULTLANG: return dst = prefix + '.html' #.' + suffix dst_abs = os.path.normpath(os.path.join(TRGROOT, dst)) src_abs = os.path.normpath(os.path.join(SRCROOT, src)) dst_dir = os.path.dirname(dst_abs) utility.makedir(dst_dir) if utility.newer([src_abs], dst_abs): utility.reportBuilding(src) arguments = [ '--no-generator', '--language=' + suffix, '--no-source-link', '--no-datestamp', '--output-encoding=iso-8859-15', '--target-suffix=html', '--stylesheet=' + '../' * depth + 'aros.css?v=1.3', '--link-stylesheet', src_abs, dst_abs ] publisher = Publisher() publisher.set_reader('standalone', None, 'restructuredtext') publisher.set_writer('html') publisher.publish(argv=arguments) else: utility.reportSkipping(dst)
def processPicture(src, depth): FORMATS = ['jpg', 'jpeg', 'png'] extension = os.path.splitext(src)[1][1:] if extension not in FORMATS: return src = os.path.normpath(src) dst_abs = os.path.normpath(os.path.join(TRGROOT, src)) src_abs = os.path.normpath(os.path.join(SRCROOT, src)) dst_dir = os.path.dirname(dst_abs) tn_dst = thumbnail.makeThumbnailPath(src) tn_dst_abs = os.path.normpath(os.path.join(TRGROOT, tn_dst)) tn_dst_dir = os.path.dirname(tn_dst_abs) # Make sure the destination directories exist. utility.makedir(dst_dir) utility.makedir(tn_dst_dir) # Copy the original image over. utility.copy(src_abs, dst_abs) # Create the thumbnail. if utility.newer([src_abs], tn_dst_abs): print 'ยป Thumbnailing', src thumbnail.makeThumbnail(src_abs, tn_dst_abs, (200, 200))
def processWWW(src, depth): src = os.path.normpath(src) prefix = os.path.splitext(src)[0] suffix = os.path.splitext(src)[1][1:] if suffix != DEFAULTLANG: return for lang in languages: if lang == DEFAULTLANG: dst = prefix + '.php' dst_depth = depth else: dst = lang + '/' + prefix + '.php' dst_depth = depth + 1 src = altLang(prefix, lang) dst_abs = os.path.normpath(os.path.join(TRGROOT, dst)) src_abs = os.path.normpath(os.path.join(SRCROOT, src)) dst_dir = os.path.dirname(dst_abs) utility.makedir(dst_dir) if utility.newer([TEMPLATE + lang, src_abs], dst_abs): utility.reportBuilding(dst) strings = { 'ROOT': '../' * dst_depth, 'BASE': '../' * dst_depth, 'CONTENT': convertWWW(src_abs, lang) } file(dst_abs, 'w').write(TEMPLATE_DATA[lang] % strings) else: utility.reportSkipping(dst)
def makeStatus(extension='.php'): tasks = db.tasks.parse.parse(file('db/status', 'r')) for lang in languages: dstdir = 'introduction/status' if lang == DEFAULTLANG: dstdir = os.path.join(TRGROOT, dstdir) else: dstdir = os.path.join(TRGROOT, lang, dstdir) utility.makedir(dstdir) db.tasks.format.html.format(tasks, dstdir, TEMPLATE_DATA[lang], lang, extension)
def copyImages(): # developer/ui imagepath = 'documentation/developers/ui/images' dstpath = os.path.join(TRGROOT, imagepath) srcpath = imagepath utility.makedir(dstpath) utility.pathscopy( ['windows-prefs-titlebar.png', 'windows-prefs-buttons.png'], srcpath, dstpath) # developer/zune-dev imagepath = 'documentation/developers/zune-dev/images' dstpath = os.path.join(TRGROOT, imagepath) srcpath = imagepath utility.makedir(dstpath) utility.pathscopy('hello.png', srcpath, dstpath) # users imagepath = 'documentation/users/images' dstpath = os.path.join(TRGROOT, imagepath) srcpath = imagepath utility.makedir(dstpath) utility.pathscopy([ 'installer1.png', 'installer2.png', 'installer3.png', 'installer4.png', 'installer5.png', 'installer6.png', 'installer7.png', 'installer8.png', 'installer9.png', 'shell.png' ], srcpath, dstpath) # generic imagepath = 'images' dstpath = os.path.join(TRGROOT, imagepath) srcpath = imagepath utility.makedir(dstpath) utility.pathscopy([ 'AROS_logo_paypal.png', 'paypal-logo.png', 'aros-banner.gif', 'aros-banner2.png', 'aros-banner-blue.png', 'aros-banner-pb2.png', 'aros-banner-peta.png', 'aros-sigbar-user.png', 'aros-sigbar-coder.png', 'download-arrow.png' ], srcpath, dstpath) utility.pathscopy([ 'genesi.gif', 'trustec.png', 'sourceforge.png', 'phoenix.jpeg', 'bttr.jpeg', 'icaroslive_logo.png', 'aspireos_logo.png', 'kcachegrind.jpg', 'tinyaros_logo.png', 'arosone_logo.jpeg' ], srcpath, dstpath)
def buildWWW(): global TRGROOT TRGROOT = os.path.join(DSTROOT, 'www') # Hack to get around dependency problems for lang in languages: if lang == DEFAULTLANG: dstpath = TRGROOT else: dstpath = os.path.join(TRGROOT, lang) utility.remove(os.path.join(dstpath, 'index.php')) utility.remove(os.path.join(dstpath, 'introduction/index.php')) utility.remove(os.path.join(dstpath, 'download.php')) makeNews() makeCredits() makeTemplates() for lang in languages: TEMPLATE_DATA[lang] = file(TEMPLATE + lang, 'r').read() makePictures() makeStatus() recurse(processWWW) utility.copy('license.html', TRGROOT) imagepath = os.path.join(TRGROOT, 'images') utility.makedir(imagepath) srcpath = 'targets/www/images' utility.pathscopy([ 'trustec-small.png', 'genesi-small.gif', 'noeupatents-small.png', 'bullet.gif', 'toplogomenu.png', 'toplogomenu.gif', 'kittymascot.png', 'kittymascot.gif', 'backgroundtop.png', 'disk.png', 'arosthumbmain.png', 'bgcolormain.png', 'mainpagespacer.png', 'rsfeed.gif', 'sidespacer.png', 'textdocu.gif', 'archivedownloadicon.gif', 'archivedownloadicon.png', 'bgcolorright.png', 'bountyicon1.gif', 'bountyicon1.png', 'bountyicon2.gif', 'bountyicon2.png', 'communityicon.gif', 'communityicon.png', 'directdownloadicon.gif', 'directdownloadicon.png', 'czechlogo.png', 'englishlogo.png', 'finlandlogo.png', 'francelogo.png', 'germanylogo.png', 'greecelogo.png', 'italylogo.png', 'netherlandslogo.png', 'polandlogo.png', 'portugallogo.png', 'rssicon1.gif', 'rssicon1.png', 'russialogo.png', 'swedenlogo.png', 'spanishlogo.png', 'pointer.png' ], srcpath, imagepath) copyImages() copySamples() copyHeaders() srcpath = 'targets/www' utility.pathscopy( ['docutils.css', 'aros.css', 'print.css', 'donations.css'], srcpath, TRGROOT) utility.copy(os.path.join('targets/www', 'htaccess'), os.path.join(TRGROOT, '.htaccess')) dbpath = os.path.join(TRGROOT, 'db') utility.makedir(dbpath) utility.makedir(os.path.join(dbpath, 'download-descriptions')) for lang in languages: desc_file = os.path.join('db/download-descriptions', lang) if os.path.exists(desc_file): utility.copy(desc_file, os.path.join(dbpath, 'download-descriptions')) cgi_dest = os.path.join(TRGROOT, 'cgi-bin') if os.path.exists(cgi_dest): shutil.rmtree(cgi_dest) utility.copytree('targets/www/cgi-bin', cgi_dest) thumb_dest = os.path.join(TRGROOT, 'images/thumbs') if os.path.exists(thumb_dest): shutil.rmtree(thumb_dest) utility.copytree('targets/www/images/thumbs', thumb_dest) rsfeed_dest = os.path.join(TRGROOT, 'rsfeed') if os.path.exists(rsfeed_dest): shutil.rmtree(rsfeed_dest) utility.copytree('targets/www/rsfeed', rsfeed_dest) # Remove index-offline.php utility.remove(os.path.join(TRGROOT, 'index-offline.php')) os.system('chmod -R go+r %s' % TRGROOT)
def makePictures(): DIRECTORIES = ['pictures/developers', 'pictures/screenshots'] options = ['--report=none'] # First, copy the pictures and generate thumbnails for root in DIRECTORIES: recurse(processPicture, root) # Second, create the galleries for root in DIRECTORIES: for lang in languages: output = convertWWW(pathAltLang('index', lang, root), lang, options) names = os.listdir(root) names.sort() if root == 'pictures/screenshots': names.reverse() for name in names: path = os.path.join(root, name) if name == '.svn' or not os.path.isdir(path): continue output += '\n<div class="gallerygroup">\n<a name=%s>\n' % name output += convertWWW(pathAltLang('overview', lang, path), lang, options) pictureNames = os.listdir(path) pictureNames.sort() for pictureName in pictureNames: picturePath = os.path.join(path, pictureName) pictureFormat = os.path.splitext(pictureName)[1][1:] if pictureName == '.svn' or os.path.isdir(picturePath): continue if pictureFormat not in ['jpg', 'jpeg', 'png']: continue output += gallery.makePicture( picturePath, convertWWW( pathAltLang( os.path.splitext(picturePath)[0], lang), lang, options), lang) output += '</a>\n</div>\n' if lang == DEFAULTLANG: strings = { 'ROOT': '../../', 'BASE': '../../', 'CONTENT': output } else: strings = { 'ROOT': '../../../', 'BASE': '../../../', 'CONTENT': output } filename = 'index.php' if lang == DEFAULTLANG: dst = os.path.join(TRGROOT, root) else: dst = os.path.join(TRGROOT, lang, root) if not os.path.exists(dst): utility.makedir(dst) file(os.path.join(dst, filename), 'w').write(TEMPLATE_DATA[lang] % strings)