Exemple #1
0
 def __init__(self):
     Publication.__init__(self)
     self.pagebotRoot = pagebot.getRootPath()
     self.pagebotBase = 'Lib/pagebot'
     self.pagebotDocs = self.pagebotRoot.replace('Lib', DOCS)
     self.packages = {}
     self.classes = {}
     self.folders = None
    def initialize(self, **kwargs):
        u"""Initialize the generic base website templates. """

        # For now, just supply the full head code here.
        headCode = """       
        <meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>%(title)s</title>
        <meta name="description" content="%(description)s">
        <meta name="keywords" content="%(keywords)s">
        <!-- Mobile viewport -->
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
        <link rel="shortcut icon" href="images/favicon.ico"  type="image/x-icon">
        <!-- CSS-->
        <link media="all" href="fonts/webfonts.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="css/normalize.css">
        <!--link rel="stylesheet" href="js/flexslider/flexslider.css"> -->
        <link rel="stylesheet" href="css/style.css">
        <!-- end CSS-->            
        """

        # For now, just supply the full JS links as code.
        jsCode = """
        <!-- JS-->
        <script src="js/libs/modernizr-2.6.2.min.js"></script>
        <!-- end JS-->
        <!-- jQuery -->
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <script defer src="js/flexslider/jquery.flexslider-min.js"></script>
        <!-- fire ups - read this file!  -->   
        <script src="js/main.js"></script>
        """
        #<script>window.jQuery || document.write('<script src="js/libs/jquery-1.9.0.min.js"></script>')</script>

        rp = getRootPath()

        padding = self.padding
        w, h = self.w, self.h
        self.gw = self.gh = px(8)
        gridX = (fr(1), fr(1))
        gridY = [None] # Default is full height of columns, no horizontal division.

        # Default page template
        t = Template(w=w, h=h, name='home', padding=padding, gridX=gridX, gridY=gridY)
        self.addTemplate(t.name, t)
        # Set template <head> building parameters. # Page element definition in pbpage.py
        t.headCode = headCode % dict(title=self.title, description='', keywords='')
        t.favIconUrl = 'images/favicon.gif'
        t.jsCode = jsCode
        t.cssCode = simpleCssCode % simpleTheme
        t.resourcePaths = (rp+'js', rp+'images', rp+'fonts', rp+'css') # Directorie to be copied to Mamp.
        # Add page template elements.
        Navigation(parent=t, name='Navigation')
        #Introduction(parent=t, name='Introduction')
        Featured(parent=t, name='Featured')
        WideContent(parent=t, name='WideContent')
        Hero(parent=t, name='Hero')
        Footer(parent=t, name='Footer')
Exemple #3
0
def hyphenatedWords(language=DEFAULT_LANGUAGE):
    u"""Answer the dictionary of hyphenated words for this language (default is English)."""
    if not language in languages:
        # Not initialized yet, try to read.
        path = '%s/Lib/pagebot/toolbox/hyphenation/languages/%s.txt' % (
            getRootPath(), language)
        if os.path.exists(path):
            languages[language] = words = {}
            f = codecs.open(path, mode="r", encoding="utf-8")
            hyphenatedLines = f.read().split('\n')
            f.close()
            for line in hyphenatedLines:
                if line.startswith('#'):
                    continue
                words[line.replace('-', '')] = line
    return languages.get(language)
Exemple #4
0
    def clearPyc(self, path=None):
        u"""Recursively removes all .pyc files."""
        if path is None:
            path = pagebot.getRootPath()

        for fileName in os.listdir(path):
            filePath = path + '/' + fileName

            if fileName.startswith('.') or fileName in SKIP:
                continue

            if os.path.isdir(filePath):
                self.clearPyc(filePath)
            elif fileName.endswith('.pyc'):
                os.remove(filePath)
                print ' * Removed', filePath
                continue
Exemple #5
0
    def __init__(self,
                 resourcePaths=None,
                 cssCode=None,
                 cssPaths=None,
                 useScss=True,
                 cssUrls=None,
                 jsCode=None,
                 jsPaths=None,
                 jsUrls=None,
                 webFontUrls=None,
                 **kwargs):
        """Abstract class for views that build websites."""
        HtmlView.__init__(self, **kwargs)

        # Url's and paths
        self.siteRootPath = self.SITE_ROOT_PATH

        if resourcePaths is None:
            rp = getRootPath() + '/elements/web/simplesite/'
            resourcePaths = (rp + 'js', rp + 'images', rp + 'fonts', rp + 'css'
                             )  # Directories to be copied to Mamp.
        self.resourcePaths = resourcePaths

        # Default WebFonts urls to include:
        self.webFontUrls = webFontUrls

        # Default CSS urls to inclide
        self.useScss = useScss  # If True, then try to compile to SCSS.
        self.cssCode = cssCode  # Optional CSS code to be added to all pages.
        self.cssUrls = cssUrls or [self.SCSS_CSS_PATH
                                   ]  # Added as links in the page <head>
        self.cssPaths = cssPaths  # File content added as <style>...</style> in the page <head>

        # Default JS Urls to include
        self.jsCode = jsCode  # Optional JS code to be added to all pages at end of <body>.
        self.jsUrls = jsUrls or (
            URL_JQUERY, URL_MEDIA
        )  # Added as <script src="..."> at end of <body>
        self.jsPaths = jsPaths  # File content added as <script>...</script> at end of <body>
Exemple #6
0
    def __init__(self,
                 resourcePaths=None,
                 cssCode=None,
                 cssPath=None,
                 cssUrls=None,
                 jsUrls=None,
                 webFontUrls=None,
                 **kwargs):
        u"""Abstract class for views that build websites."""
        HtmlView.__init__(self, **kwargs)

        # Url's and paths
        self.siteRootPath = self.SITE_ROOT_PATH

        if resourcePaths is None:
            rp = getRootPath() + '/elements/web/simplesite/resources/'
            resourcePaths = (rp + 'js', rp + 'images', rp + 'fonts', rp + 'css'
                             )  # Directories to be copied to Mamp.
        self.resourcePaths = resourcePaths

        # Default WebFonts urls to include:
        self.webFontUrls = webFontUrls

        # Default CSS urls to inclide
        self.cssCode = cssCode  # Optional CSS code to be added to all pages.
        self.cssPath = cssPath or self.CSS_PATH
        self.cssUrls = cssUrls or [self.CSS_PATH]

        # Default JS Urls to include
        self.jsUrls = jsUrls or dict(
            jquery=
            'https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js',
            #jquery='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js',
            mediaqueries='http://code.google.com/p/css3-mediaqueries-js',
            d3='https://d3js.org/d3.v5.min.js',
        )
#     fitVariableHeadline.py
#
#     Demo version of
#       pagebot.fonttoolbox.variablefontbuilder.fitVariableWidth
#     to show usage and format of the answered dictionary.
#
#     For real use, import the function as:
#     from pagebot.fonttoolbox.variablefontbuilder import fitVariableWidth
#
import copy
from pagebot.contexts import defaultContext as context
from pagebot import getRootPath
from pagebot.fonttoolbox.objects.font import Font
from pagebot.fonttoolbox.variablefontbuilder import getVariableFont

ROOT_PATH = getRootPath()
FONT_PATH = ROOT_PATH + '/Fonts/fontbureau/AmstelvarAlpha-VF.ttf'
f = Font(FONT_PATH,
         install=True)  # Get PageBot Font instance of Variable font.


def fitVariableWidth(varFont,
                     s,
                     w,
                     fontSize,
                     condensedLocation,
                     wideLocation,
                     fixedSize=False,
                     tracking=None,
                     rTracking=None):
    u"""
#     DrawVariableFontManyWeightsAnimation.py
#
#     Note: the type of animation used in this example is self-contained:
#     all code for for FontIcon class and KeyFrame class is here.
#     In the future these classes will be part of the main PageBot library,
#     which may make them incompatible with this particular example.
#
import pagebot
from pagebot.contexts import defaultContext as context
from pagebot.fonttoolbox.objects.font import Font, getFontByName
from pagebot.fonttoolbox.variablefontbuilder import getVariableFont
from pagebot.style import CENTER

W = H = 500

ROOT_PATH = pagebot.getRootPath()
FONT_PATH = ROOT_PATH + '/Fonts/fontbureau/AmstelvarAlpha-VF.ttf'
f = Font(FONT_PATH,
         install=True)  # Get PageBot Font instance of Variable font.

ULTRALIGHT_CONDENSED = getVariableFont(FONT_PATH,
                                       dict(wght=0.9, wdth=0.7),
                                       styleName='Utrla Light Condensed')
ULTRALIGHT = getVariableFont(FONT_PATH,
                             dict(wght=1, wdth=0),
                             styleName='Ultra Light')
LIGHT_CONDENSED = getVariableFont(FONT_PATH,
                                  dict(wght=0.9, wdth=0.7),
                                  styleName='Light Condensed')
LIGHT = getVariableFont(FONT_PATH, dict(wght=0.9, wdth=0), styleName='Light')
THIN_CONDENSED = getVariableFont(FONT_PATH,
Exemple #9
0
 def build(self):
     # Collect data from all folders.
     rootPath = pagebot.getRootPath()
     rootNode = self.testDocs(rootPath)
     self.buildNode(rootNode)