Exemple #1
0
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)
Exemple #2
0
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 makeTemplates():
    # Deduce important paths
    HERE_DIR   = os.path.split( __file__ )[0]
    LANG_DIR   = 'targets/www/template/languages'
    DST_DIR    = 'targets/www'
    
    def makeTemplate( language, dst ):
        # Setup translation dictionaries
        config = ConfigParser()
        config.read( os.path.join( LANG_DIR, language ) )

        charset = config.get( 'meta', 'charset' )

        _T = {}
        for option in config.options( 'titles' ):
            _T[option] = config.get( 'titles', option )

        _N = {}
        for option in config.options( 'navigation' ):
            _N[option] = config.get( 'navigation', option )

        _M = {}
        for option in config.options( 'misc' ):
            _M[option] = config.get( 'misc', option )
        
        file( dst, 'w' ).write( makePage( _T, _N, _M, '', language, charset ) )

    for language in os.listdir( LANG_DIR ):
        if utility.ignore( language ): continue

        dst = os.path.join( DST_DIR, 'template.html.' + language )
       
        if utility.newer \
        ( 
            [ 
                __file__, 
                os.path.join( HERE_DIR, 'page.py' ),
                os.path.join( HERE_DIR, 'components.py' ), 
                os.path.join( LANG_DIR, language ) 
            ], 
            dst 
        ):
            utility.reportBuilding( dst )
            makeTemplate( language, dst )
        else:
            utility.reportSkipping( dst )