示例#1
0
    def initialize(self, **kwargs):
        """Initialize the generic website templates."""

        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
        view = self.view
        view.favIconUrl = 'images/favicon.gif'
        view.mediaQueriesUrl = None
        # Add page elements.
        MobileNavigation(parent=t, name='MobileNavigation')
        Introduction(parent=t, name='Introduction')
        Navigation(parent=t, name='Navigation')
        Featured(parent=t, name='Featured')
        Main(parent=t, name='Main')
        Section(parent=t, name='Section')
        Main(parent=t, name='OtherMain')
        Footer(parent=t, name='Footer')
        JS(parent=t, name='JS')
示例#2
0
    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')
示例#3
0
def makeDocument():
    """Make a new document."""

    W = H = PageSize

    # Create a new document, default to the defined page size.
    doc = Document(w=W, h=H, originTop=False, title='Text Flow', autoPages=2)

    rs = doc.getRootStyle()
    rs['fill'] = (1, 1, 0)  # Yellow background for debugging
    rs['font'] = 'Verdana'
    rs['fontSize'] = 14
    rs['textFill'] = 1

    #textBoxStyle = doc.addStyle('textbox', dict(fill=color(0, 0, 0, 0.7),
    #                                            padding=40))
    pStyle = doc.addStyle('p', dict(textFill=blackColor))
    h1Style = doc.addStyle('h1', dict(fontSize=24, textFill=(0, 0, 1)))
    #h2Style = doc.addStyle('h2', dict(fontSize=18, textFill=(0, 1, 0)))

    view = doc.getView()
    view.padding = 0  # Aboid showing of crop marks, etc.
    view.showCropMarks = True
    view.showRegistrationMarks = True
    view.showFrame = True
    view.showPadding = True
    view.showOrigin = True
    view.showDimensions = False

    # Get list of pages with equal y, then equal x.
    #page = doc[1][0] # Get the single page from the document.
    page0 = doc.getPage(1)  # Get page on pageNumber,
    # first in row (this is only one now).
    page0.name = 'Page 1'
    page0.padding = PagePadding

    s = doc.context.newString('Headline\n', style=h1Style)
    for n in range(10):
        s += doc.context.newString(('(Line %d) Volume of text defines'
                                    ' the box height.'
                                    ' Volume of text defines'
                                    ' the box height. \n') % (n + 1),
                                   style=pStyle)
        h1 = None

    e1 = newTextBox(
        s,
        name='CSSTextBox1',
        parent=page0,
        padding=4,
        x=100,
        font='Verdana',
        h=h1,
        mb=20,
        mr=10,  # Conditions make the element
        # move to top-left of the page.
        gridX=((fr(3), px(8)), (fr(2), px(8))),
        # And the condition that there should be no overflow,
        # otherwise the text box will try to solve it.
        conditions=[Left2Left(), Fit2Width(),
                    Float2Top()],
        # Position of the origin of the element.
        # Just to show where it is.
        # Has no effect on the position conditions.
        yAlign=BOTTOM,
        xAlign=LEFT,
        leading=5,
        fontSize=9,
        textFill=blackColor,
        strokeWidth=pt(0.5),
        fill=color(0.9),
        stroke=noColor)
    print(e1.style)

    newTextBox(
        s,  # Empty box, will get the overflow
        # from e1, if there is any.
        name='CSSTextBox2',  # Flow reference by element.name
        parent=page0,
        padding=4,
        x=100,
        h=200,
        conditions=[Left2Left(), Fit2Width(),
                    Float2Top()],
        yAlign=TOP,
        fill=whiteColor,
        stroke=noColor)

    score = doc.solve()  # Try to solve all pages.
    if score.fails:
        print(score.fails)

    return doc  # Answer the doc for further doing.