1. Welcome to Smogon! Check out the Smogon Starters Hangout for everything you need to know about starting out in the community. Don't forget to introduce yourself in the Introduction and Hangout Thread, too!
  2. Welcome to Smogon Forums! Please take a minute to read the rules.

Programming Translating Mako -> Genshi

Discussion in 'Technical Projects' started by chaos, Jan 29, 2009.

  1. chaos

    chaos
    is a member of the Site Staffis a Battle Server Administratoris a Programmeris a Smogon IRC SOPis a Contributor to Smogonis an Administratoris a Tournament Director Alumnusis a Researcher Alumnus
    Owner

    Joined:
    Dec 18, 2004
    Messages:
    10,019
    Volunteers needed! Code is in /branches/genshi.

    www.makotemplates.org
    http://genshi.edgewall.org/

    Here's a template for regular pages in a section:

    Code:
    <html xmlns:py="http://genshi.edgewall.org/"
          xmlns:xi="http://www.w3.org/2001/XInclude"
          py:strip="True">
          
          <py:match path="title" once="True">
              <title>Big Misty</title>
          </py:match>
          
          <py:match path="breadcrumbs" once="True">
              <breadcrumbs><a>This Page</a></breadcrumb>
          </py:match>
          
          <py:match path="content" once="True">
          <content>
              <p>The girth of the Misty is de big Misty</p>
              ...
          </content>
          </py:match>
          
          <xi:include href="base.html" />
    </html>
    
    Note: Not every page needs breadcrumbs. For instance, the index page should not have a breadcrumb.

    ----------

    "Base" files in a section (like scms/base.html) need some special attention. They extend the main base template (in /base.html, which extends /raw.html). Here is an example:

    Code:
    <html xmlns:py="http://genshi.edgewall.org/"
          xmlns:xi="http://www.w3.org/2001/XInclude"
          py:strip="True">
                
          <py:match path="title" once="True">
              <title>${select("text()"}} - SCMS</title>
          </py:match>
          
          <py:match path="head" once="True">
              <head>
                  ... any css you need here ...
                  ${select("*")}
              </head>
          </py:match>
          
          <py:match path="breadcrumbs" once="True">
              <breadcrumbs><a href="/scms/">SCMS</a> ${select("*")}</breadcrumbs>
          </py:match>
          
          <py:match path="content" once="True">
          <nav>
          <navbody section="SCMS">
              <a href="/scms/link1">Link1</a>
              <a href="/scms/link2">Link2</a>
              <a href="/scms/link3">Link3</a>
          </navbody>
          <content />
          </nav>
          </py:match>
          
          <xi:include href="base.html" />
    </html>
    
    (Note: I have a Genshi transformation filter that will remove the <a> on the current link and replace it with <strong>, and everything in the navbody will be listified. Don't worry about any of that! The whole purpose of switching template systems is to make our lives easier.)

    (Note2: Not every base adds "- Section" to the output. If it doesn't currently, don't add the code)
  2. chaos

    chaos
    is a member of the Site Staffis a Battle Server Administratoris a Programmeris a Smogon IRC SOPis a Contributor to Smogonis an Administratoris a Tournament Director Alumnusis a Researcher Alumnus
    Owner

    Joined:
    Dec 18, 2004
    Messages:
    10,019
    If there are any questions, please post them here
  3. chaos

    chaos
    is a member of the Site Staffis a Battle Server Administratoris a Programmeris a Smogon IRC SOPis a Contributor to Smogonis an Administratoris a Tournament Director Alumnusis a Researcher Alumnus
    Owner

    Joined:
    Dec 18, 2004
    Messages:
    10,019
    It'd be nice to get some volunteers. Shiv and ryu told me they'd be up for it but neither have posted in this thread.
  4. Mekkah

    Mekkah
    is a Super Moderatoris a Tutor Alumnusis a Site Staff Alumnusis a Smogon IRC SOp Alumnusis a CAP Contributor Alumnusis a Contributor Alumnusis a Smogon Media Contributor Alumnusis an Administrator Alumnus
    Super Moderator

    Joined:
    Feb 8, 2005
    Messages:
    14,060
    ryu is leaving for another month or so due to exams
  5. ryubahamut

    ryubahamut
    is a Site Staff Alumnusis a Programmer Alumnusis a Forum Moderator Alumnusis a Contributor Alumnus

    Joined:
    Jan 18, 2007
    Messages:
    999
    sorry :< i did try looking up on IRC you were afk apparenrtly. i will see if i can do something atm
  6. Shiv

    Shiv mostly harmless
    is a Site Staff Alumnusis a Smogon IRC AOp Alumnusis a Forum Moderator Alumnusis a Battle Server Moderator Alumnusis a Past WCoP Winner

    Joined:
    Apr 7, 2005
    Messages:
    5,870
    I hadn't noticed this thread (or forum for that matter). I'm up for doing this :)
  7. Polis4rule

    Polis4rule

    Joined:
    Jun 21, 2008
    Messages:
    1,101
    If you don't mind me asking, is this just simply taking the old coding and turning it into Genshi new coding?
  8. GAK

    GAK

    Joined:
    Oct 12, 2008
    Messages:
    1,361
    I can assist in this project if you still need it done.

Users Viewing Thread (Users: 0, Guests: 0)