예제 #1
0
def getSingleTemplate():
    single_span = SPAN(dclass="songtitle",
                       content="${SINGLE_TITLE}") + BR() + SPAN(
                           dclass="subtitle", content="${SINGLE_SUBTITLE}")
    prev_link = A(href="${PREVID}.html",
                  content=IMG(src="/pix/left_arrow.gif",
                              border="0",
                              alt="previous single",
                              title="previous single"))
    next_link = A(href="${NEXTID}.html",
                  content=IMG(src="/pix/right_arrow.gif",
                              border="0",
                              alt="next single",
                              title="next single"))
    title_bar = DIV(dclass="single_title",
                    content=TABLE(
                        dclass="single_title",
                        content=TR(
                            TD(content=prev_link, dclass="left_arrow") +
                            TD(dclass="songtitle", content=single_span) +
                            TD(content=next_link, dclass="right_arrow"))))
    issues = DIV(content="${ISSUES}")

    return Template(
        getBaseTemplate("singles").substitute(
            EXTRA_HEADER="",
            PAGE_TITLE="Elton John Single: ${SINGLE_TITLE}",
            PAGE_CONTENT=title_bar + issues + title_bar,
        ))
예제 #2
0
def getSingleIndex():
    return Template(
        getBaseTemplate("singles").substitute(
            EXTRA_HEADER="",
            PAGE_TITLE="Elton John Singles",
            PAGE_CONTENT="${TITLE}" + "${DESCR}" + DIV("${NAVBAR}") +
            DIV("${ISSUES}") + DIV("${NAVBAR}"),
        ))
예제 #3
0
def getLyricsIndexTemplate(title):
    pageheader = DIV(dclass="songtitle", content=title)
    indexcontent = DIV(dclass="lyric_page",
                       content=getAlphaLinks() + getSearchBox() + pageheader +
                       "${LISTING}")

    return Template(
        getBaseTemplate("lyrics").substitute(
            EXTRA_HEADER="${EXTRA_HEADER}",
            PAGE_TITLE=title,
            PAGE_CONTENT=indexcontent,
        ))
예제 #4
0
def getBottomAdvert():
    ebaylink = "http://www.ebay.com/sch/captain_fantastic/m.html?_nkw=&_armrs=1&_ipg=&_from="
    ebaylogo = IMG(src="/pix/ebaylogo.png", width="120", height="48")
    ebaytext = "See my Elton John<br/>Auction Items on EBAY"
    ebaylayout = TABLE(TR(TD(ebaylogo) + TD(ebaytext)))
    ebaybox = TD(
        A(href=ebaylink, content=DIV(dclass="bubble", content=ebaylayout)))
    tictaillink = "http://eltonography.tictail.com"
    tictaillogo = IMG(src="/pix/shopping_cart.png", width="59", height="48")
    tictailtext = "Collectibles For Sale<br/>In Eltonography SHOP"
    tictaillayout = TABLE(TR(TD(tictaillogo) + TD(tictailtext)))
    tictailbox = TD(
        A(href=tictaillink,
          content=DIV(dclass="bubble", content=tictaillayout)))
    table = TABLE(dclass="center", content=TR(content=ebaybox + tictailbox))
    return table
예제 #5
0
def getTabs(fronttab=None):
    bevel = """<img class="menu_bevel", src="/pix/tab_bevel.gif"/>"""
    lyrics_tab = A(href="/songs/index.html",
                   content=getTabImg("lyrics",
                                     front=fronttab == "lyrics",
                                     alt="Elton John lyrics"))
    albums_tab = A(href="/albums/standard/index.html",
                   content=getTabImg("albums",
                                     front=fronttab == "albums",
                                     alt="Elton John Albums"))
    singles_tab = A(href="/singles/index.html",
                    content=getTabImg("singles",
                                      front=fronttab == "singles",
                                      alt="Elton John singles"))
    tours_tab = A(href="/tours/index.html",
                  content=getTabImg("tours",
                                    front=fronttab == "tours",
                                    alt="Elton John tours"))
    books_tab = A(href="/books/index.html",
                  content=getTabImg("books",
                                    front=fronttab == "books",
                                    alt="Elton John books"))
    shop_tab = A(href="/shop/index.html",
                 content=getTabImg("shop",
                                   front=fronttab == "shop",
                                   alt="Elton Items for Sale"))
    return DIV(content=bevel + lyrics_tab + albums_tab + singles_tab +
               tours_tab + books_tab + shop_tab,
               dclass="tabbed_menu")
예제 #6
0
def getBottomAdvertold():
    return DIV(
        dclass="bold darkblue margin20",
        content=
        A(href=
          "http://www.ebay.com/sch/captain_fantastic/m.html?_nkw=&_armrs=1&_ipg=&_from=",
          content="Elton John rarities for sale on Ebay"))
예제 #7
0
def getAlphaLinks():
    letterlinks = []
    for letter in '0' + uppercase:
        shown = letter
        if shown == '0': shown = '#'
        letterlinks.append(
            A(dclass="song_letter",
              href="/songs/" + letter + "_index.html",
              content=shown))
    return DIV(dclass="lyrics_letters", content="".join(letterlinks))
예제 #8
0
def generate_contact() :

  root = XML.parse(location.dbroot + 'contact.xml').getroot()
  text = XML.tostring(root)
  index_text = templates.getBaseTemplate(None).substitute(
    EXTRA_HEADER  = "",
    PAGE_TITLE   = "Eltonography Contact Me",
    PAGE_CONTENT = DIV(dclass="bubble", content=text),
  )
  with open(location.docroot + "contact/index.html", "w") as contactindex:
    contactindex.write(index_text)
예제 #9
0
def generate_404() :

  root = XML.parse(location.dbroot + 'file_not_found.xml').getroot()
  text = XML.tostring(root)
  index_text = templates.getBaseTemplate(None).substitute(
    EXTRA_HEADER  = "",
    PAGE_TITLE   = "Eltonography: file not found",
    PAGE_CONTENT = DIV(dclass="bubble", content=text),
  )
  with open(location.docroot + "404.html", "w") as index:
    index.write(index_text)
예제 #10
0
def getLyricPageTemplate():
    songcredits = DIV(dclass="credits", content="${SONG_CREDITS}")
    songtitle = DIV(dclass="songtitle", content="${SONG_TITLE}")
    songnotes = DIV(dclass="songnotes", content="${SONG_NOTES}")
    songlyrics = DIV(dclass="lyrics", content="${SONG_LYRICS}")
    songcopy = DIV(dclass="copy", content="${SONG_COPYRIGHT}")

    prev_link = A(href="${PREVID}.html",
                  content=IMG(dclass="arrow_link",
                              src="/pix/left_arrow.gif",
                              alt="previous song"))
    next_link = A(href="${NEXTID}.html",
                  content=IMG(dclass="arrow_link",
                              src="/pix/right_arrow.gif",
                              alt="next song"))
    title_table = TABLE(content=TR(
        TD(prev_link, dclass="left_arrow") +
        TD(dclass="songtitle", content=songtitle) +
        TD(next_link, dclass="right_arrow")),
                        dclass="song_title")

    pagecontent = DIV(dclass="lyric_page",
                      content=getAlphaLinks() + getSearchBox() + title_table +
                      songnotes + songcredits + songlyrics + songcopy +
                      "${AMAZON}" + "${ITUNES}")

    return Template(
        getBaseTemplate("lyrics").substitute(
            EXTRA_HEADER="",
            PAGE_TITLE="Elton John Lyrics: ${SONG_TITLE}",
            PAGE_CONTENT=pagecontent,
        ))
예제 #11
0
def getBaseTemplate(fronttab):
    header_image = DIV(dclass="header_image",
                       content=IMG(src="/pix/arms.gif",
                                   width="800",
                                   height="240"))
    header_image = ""
    #home_button     = """<a href="/index.html"><img class="home_button" src="/pix/home_button.png" alt="eltonography.com home page" onmouseover="this.src='/pix/home_button_over.png';" onmouseout="this.src='/pix/home_button.png';"></a>"""
    #email_button    = """<a href="/contact.html"><img style="position:absolute;left:185px;top:75px" class="email_button" src="/pix/email_button.png" alt="contact the author" onmouseover="this.src='/pix/email_button_over.png';" onmouseout="this.src='/pix/email_button.png';"></a>"""
    #sale_button    = """<a href="TBD.html"><img style="position:absolute;left:265px;top:75px" class="sale_button" src="/pix/sale_button.png" alt="Elton John items for sale" onmouseover="this.src='/pix/sale_button_over.png';" onmouseout="this.src='/pix/sale_button.png';"></a>"""
    subtitle = DIV(
        dclass="title_subtext",
        content=
        "The online illustrated Elton John Discography<br/>by David Bodoh")
    blanktext = """<a href="/index.html"><img src="/pix/blank.gif" style="position:absolute;left:10px;top:10px;width:780px;height:150px;z-index:3;" border="0"></a>"""
    header_template = DIV(dclass="header",
                          onclick="location.href='/index.html';",
                          style="cursor: pointer;",
                          content=blanktext + subtitle)
    contactLink = A(href="/contact/index.html", content="David Bodoh")
    copytext = "Copyright &copy; " + str(date.today().year) + " " + contactLink
    trailer_div = DIV(dclass="trailer", content=getBottomAdvert() + copytext)
    title = TITLE(content="${PAGE_TITLE}")
    css = """<link rel="stylesheet" type="text/css" href="/css/style3.css" />"""
    js = goHome()
    head = HEAD(content=title + css + js + "${EXTRA_HEADER}")
    mainbubble = DIV(dclass="center_800",
                     content=header_template + getTabs(fronttab) +
                     '${PAGE_CONTENT}' + trailer_div)
    adbubble = DIV(dclass="advert_800", content=getGoogleAd())
    body = BODY(content=mainbubble + adbubble)
    html = HTML(content=head + body)

    return Template(html)
예제 #12
0
def getInternationalAlbumTemplate(country):
    leftTD = TD(content="${PREVICON}", dclass="left_arrow")
    centerTD = TD(dclass="songtitle", content="${COUNTRY}")
    rightTD = TD(content="${NEXTICON}", dclass="right_arrow")
    row = TR(leftTD + centerTD + rightTD)
    table = TABLE(dclass="single_title", content=row)
    title_bar = DIV(dclass="single_title", content=table)
    return Template(
        getAlbumTemplate("International").substitute(
            EXTRA_HEADER="",
            PAGE_TITLE="Elton John Albums from " + country,
            PAGE_CONTENT=title_bar + "${ALBUMS}" + title_bar,
        ))
예제 #13
0
def getDotsDiv(myindex, total):
    navDots = []
    for link in range(total):
        suffix = str(link + 1)
        if link == 0: suffix = ""
        if link == myindex:
            navDots.append(IMG(dclass="navdots", src="/pix/white_dot.gif"))
        else:
            navDots.append(
                A(href="index" + suffix + ".html",
                  alt="page " + suffix,
                  content=IMG(dclass="noborder navdots",
                              src="/pix/green_dot.gif")))
    return DIV("".join(navDots))
예제 #14
0
def getStandardAlbumTemplate(title):
    title_bar = DIV(dclass="single_title",
                    content=TABLE(
                        dclass="single_title",
                        content=TR(
                            TD(content="${PREVICON}", dclass="left_arrow") +
                            TD(dclass="songtitle",
                               content="${ALBUM_TITLE}<br/>${ALBUM_NOTES}") +
                            TD(content="${NEXTICON}", dclass="right_arrow"))))
    return Template(
        getAlbumTemplate("Standard").substitute(
            EXTRA_HEADER="",  # no style needed
            PAGE_TITLE="Elton John Album: " + title,  # use album title here
            PAGE_CONTENT=title_bar + "${VERSIONS}",
        ))
예제 #15
0
def getAmazonWidget(asin, title):
    amazon_script = """
  <script type='text/javascript'>
  var amzn_wdgt={widget:'MP3Clips'};
  amzn_wdgt.tag='theillustrate-20';
  amzn_wdgt.widgetType='ASINList';
  amzn_wdgt.ASIN='${ASIN}';
  amzn_wdgt.title="${SONG_TITLE}";
  amzn_wdgt.width='234';
  amzn_wdgt.height='60';
  amzn_wdgt.shuffleTracks='False';
  amzn_wdgt.marketPlace='US';
   </script>
  <script type='text/javascript' src='http://ws-na.amazon-adsystem.com/20070822/US/js/swfobject_1_5.js'>
  </script>"""
    amazontemplate = Template(DIV(content=amazon_script))
    return amazontemplate.substitute(
        ASIN=asin,
        SONG_TITLE=title,
    )
예제 #16
0
def parse_import_cds(per_page):
    count = 0
    imports = ET.parse(location.dbroot + 'import_cds.xml').getroot()
    importpath = location.docroot + "albums/unauthorized/"
    picpath = importpath + "pix/"
    introduction = ""
    bubbles = []

    for cd in imports:
        if cd.tag == 'introduction':
            introduction = cd.text
            continue
        if cd.get('private'): continue

        count += 1
        # establish the left TD with a cover scan
        pic = cd.get('pic')
        if not pic: raise Exception("missing import pic for " + title)
        picfile = picpath + pic
        (type, width, height) = getImageInfo(picfile)
        img = IMG(dclass="sleeve",
                  src="pix/" + pic,
                  width=width,
                  height=height,
                  alt="scan of sleeve",
                  title="scan of sleeve")
        picTD = TD(dclass="single_sleeve", content=img)

        # establish the right TD with all the text (as separate table rows)
        textRows = []
        textRows.append(
            TR(TD(dclass="left important", content=U(cd.get('title')))))
        textRows.append(
            TR(
                TD(dclass="left",
                   content='label/catalog: ' + B(cd.get('catalog')))))
        if cd.get('year'):
            textRows.append(
                TR(TD(dclass="left", content='issued: ' + B(cd.get('year')))))
        if cd.get('venue'):
            textRows.append(
                TR(TD(dclass="left", content='venue: ' + B(cd.get('venue')))))
        if cd.get('date'):
            textRows.append(
                TR(
                    TD(dclass="left",
                       content='recorded live: ' +
                       B(textDate(cd.get('date'))))))
        if cd.get('country'):
            textRows.append(
                TR(
                    TD(dclass="left",
                       content='country: ' + B(cd.get('country')))))
        tracks = []
        for element in cd:
            if element.tag == 'track':
                tracks.append(LI(dclass="left", content=linkTrack(element)))
            elif element.tag == 'note':
                textRows.append(TR(TD(dclass="left", content=element.text)))
        textRows.append(TR(TD(OL("\n".join(tracks)))))
        textTD = TD(TABLE("\n".join(textRows)))

        bubbles.append(DIV(dclass="bubble", content=TABLE(TR(picTD + textTD))))

    # figure out how many index pages we need to create
    total_index_pages = len(bubbles) / per_page  # first pages are maxed out
    if len(bubbles) % per_page > 0:
        total_index_pages += 1  # last page is partial set

    # chop away at the index_rows list, moving them into the current index page
    for ipage in range(total_index_pages):
        my_rows = bubbles[:
                          per_page]  # grab the rows that go into this index page
        del bubbles[:per_page]  # clean up as we go
        index_text = templates.getImportIndex().substitute(
            TITLE=DIV(dclass="heading padded10",
                      content="Elton John Unauthorized CDs"),
            DESCR=DIV(dclass="description", content=introduction),
            ALBUMS=DIV(dclass="full_width", content="\n\n".join(my_rows)),
            NAVBAR=templates.getDotsDiv(ipage, total_index_pages),
        )
        suffix = str(ipage + 1)
        if ipage == 0: suffix = ""
        with open(importpath + "index" + suffix + ".html", "w") as indexfile:
            indexfile.write(index_text.encode('latin-1'))

    return count
예제 #17
0
def getItunesLink(code):
    ituneslink = """<a href="http://click.linksynergy.com/fs-bin/stat?id=ven*WJHIINE&offerid=146261&type=3&subid=0&tmpid=1826&RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Falbum%252F${ITUNES}%2526uo%253D4%2526partnerId%253D30" target="itunes_store"><img src="http://ax.phobos.apple.com.edgesuite.net/images/web/linkmaker/badge_itunes-lrg.gif" alt="Download from itunes" style="border: 0;" /></a>"""
    template = Template(DIV(dclass="itunes_link", content=ituneslink))
    return template.substitute(ITUNES=code, )
예제 #18
0
def generate_singles():

  singles_root = location.docroot + "singles/"

  # ----------------------------------------------------------------------------
  # Collect href information for albums, to verify album linking. Dictionary is
  # fileID -> title_string
  # ----------------------------------------------------------------------------
  #album_ids = {}
  #albums = ET.parse(location.dbroot+'category_albums.xml').getroot()
  #for album in albums:
  #  album_ids[album.get('id')] = album.get('title')
  #albums = ET.parse(location.dbroot+'other_albums.xml').getroot()
  #for album in albums:
  #  album_ids[album.get('id')] = album.get('title')


  xmldoc = ET.parse(location.dbroot+'singles.xml').getroot()     # load singles from file

  # ----------------------------------------------------------------------------
  # Set the id/prev/next links as XML attributes.
  # ----------------------------------------------------------------------------
  prevsingle = None
  for single in xmldoc:
    if single.get('artist') : continue           # some other artist single
    if single.get('private') : continue          # not for public website
    if single.tag == 'description':
      description = single.text
      continue
    if single.tag == 'break' : continue
    if single.tag == 'single' :                  # get the id from the title
      id = re.sub(' ', '_', single.get('title')).lower()
      id = re.sub('\(', '', id)
      id = re.sub('\)', '', id)
      id = re.sub('\/',' ', id)
      id = re.sub('\'', "", id)
      single.set('id', re.sub(' ', '_', id))
    if single.tag == 'miscellaneous' :
      single.set('id', re.sub(' ','_',single.get('country').lower()))
    if prevsingle != None:
      prevsingle.set('nextid',single.get('id'))  # forward link
      single.set('previd',prevsingle.get('id'))  # backward link
    else :
      firstsingle = single                       # save first for linnking with last
    prevsingle = single
  single.set('nextid', firstsingle.get('id'))    # fully cycled double linked-list
  firstsingle.set('previd', single.get('id'))    # fully cycled double linked-list
 

  # ----------------------------------------------------------------------------
  # Store each single as its own HTML file with listing of issues.  Also
  # generate index pages.
  # ----------------------------------------------------------------------------
  picpath = singles_root + "pix/"
  flagpath = location.docroot + "/pix/flags/"
  index_rows = []                                # prepare list for index page
  total_issues = 0                               # prepare info for index page
  total_pages = 0
  for single in xmldoc:
    if single.tag == 'description': continue     # already got this
    if single.get('artist'): continue            # ignore singles by non-Elton artists
    if single.get('private'): continue           # ignore singles not intended for public
    total_pages += 1
    icon=None                                    # should be populated later
    if single.tag == 'single':
      title = single.get('title')
      subtitle = '('+single.get('release')[0:4] + ')'
      (type,width,height) = getImageInfo(picpath+'icons/'+single.get('icon'))
      single_icon=IMG(src="pix/icons/"+single.get('icon'), width=width, height=height, alt=title, dclass="single_icon")
    elif single.tag == 'break':
      index_rows.append(DIV(dclass="bubble description", content=single.text))
      continue
    elif single.tag == 'miscellaneous' :
      title = single.get('country')+" unique singles"
      subtitle = "(miscellaneous releases)"
      flag = re.sub(' ','_',single.get('country').lower()) + ".gif"
      if not os.path.isfile(flagpath+flag): print "ERROR missing flag for",country
      (type,width,height) = getImageInfo(flagpath+flag)
      single_icon = IMG(src="/pix/flags/"+flag, width=width, height=height, alt=title, dclass="single_icon")

    #print "parsing",title
    # TBD...
    #if single.get('album') :
    #  album_href = "/albums/"+single.get('album')+".html"
    #  album_title = album_ids.get(single.get('album'))
    #  albumlink = "From the album " + A(href=album_href, content=album_title)
    #  #subtitle += '<br/>('+albumlink+')'

    issues = []
    for issue in single:
      if issue.get('private'): continue          # not for website
      if issue.get('format') == "CS": continue   # not for website yet
      total_issues += 1                          # info for index page
      country = issue.get('country')
      if country == None: print "ERROR missing country"
      count = single.get('count')
      if count: count = int(count)+1
      else: count = 1
      single.set('count',str(count))

      # detect flag GIF based on country
      flag = re.sub(' ','_',country.lower()) + ".gif"
      if not os.path.isfile(flagpath+flag): print "ERROR missing flag for",country
      (type,width,height) = getImageInfo(flagpath+flag)
      flagpic = IMG(src="/pix/flags/"+flag, width=width, height=height, alt=country, title=country)
      if single.tag == 'miscellaneous': flagpic="" # flag for misc issues is redundant

      format = issue.get('format')
      if format == None: print "ERROR missing format"
      if format == 'postcard': continue  # ignore Polish cards for now
      year = issue.get('year')
      if year == 'unknown': year = ""
      if year == None: print "ERROR missing year"
      catalog = issue.get('catalog')
      if catalog == None: print "ERROR missing catalog"
      promo = ""
      if issue.get('promo'): promo = '[promo]'
      discs = ""
      if issue.get('discs'): discs = '[' + issue.get('discs') + ' discs]'
      note = ""
      if issue.get('note') : note = '[' + issue.get('note') + ']'
      if not issue.get('ps'):
        sleeve = ""
        picTD = TD(dclass="missing_sleeve", content="(no sleeve)")
      else:
        if issue.get('ps') == 'true' : sleeve = "[picture sleeve]"
        else : sleeve = '[' + issue.get('ps') + ']'
        pic = re.sub('/','',catalog).upper()
        pic = '/'.join([format,country,pic])
        if issue.get('pic'): pic = "/".join([format,issue.get('pic')])
        pic = re.sub(' ','_',pic)
        pic = re.sub('-','',pic)
        pic = re.sub('\.','',pic)
        if issue.get('pic') : pic = '/'.join([format,issue.get('pic')])
        picfile = None
        if os.path.isfile(picpath+pic+".jpg"): picfile = "pix/"+pic+".jpg"
        elif os.path.isfile(picpath+pic+".gif"): picfile = "pix/"+pic+".gif"

        if picfile:
          (type,width,height) = getImageInfo(singles_root + picfile)
          picTD = TD(dclass="single_sleeve",
              content=IMG(dclass="sleeve", src=picfile, width=width, height=height) + BR() + sleeve)
        else:
          picTD = TD(dclass="missing_sleeve", content="[sleeve photo not available]")
          if issue.get('pic') != "NA":
            print "ERROR: can't find picture:",issue.get('pic'), title, format, country, year, catalog

      if os.path.isfile(singles_root + "pix/"+format+".gif"):
        icon = IMG(src="pix/"+format+".gif")  # use graphical icon
      else: icon = format                     # use text name

      country = "("+country+")"
      if single.tag == 'miscellaneous': country = ""
      issueheader = TR(TD(dclass="single_details", colspan=2, content=" ".join([icon,year,catalog,country,discs,promo,note])))
      trackrows = []
      trackrows.append(issueheader)
      for track in issue:
        tracktime = TD(dclass="time", content=track.get('length'))
        tracktext = TD(dclass="track", content=linkTrack(track))
        trackrows.append(TR(tracktime + tracktext))
      tracktable = TABLE("\n".join(trackrows))
      detailsTD = TD(tracktable)
      issues.append(DIV(dclass="bubble", content=TABLE(dclass="single_issue", content=TR(picTD + detailsTD))))

    page_template = templates.getSingleTemplate()
    single_text = page_template.substitute(
      NEXTID          = single.get('nextid'),
      PREVID          = single.get('previd'),
      SINGLE_TITLE    = '"'+title+'"',
      SINGLE_SUBTITLE = subtitle,
      ISSUES          = "\n".join(issues)
    )

    target = single.get('id')+".html"
    with open(singles_root+target, "w") as singlefile:
      singlefile.write(single_text.encode('latin1'))
    count = single.get('count')
    suffix = ""
    if count > 1: suffix = "s"
    subtitle = SPAN(dclass="single_count",content=subtitle + BR()+'(' + count + '&nbsp;pressing'+suffix+')')
    iconTD = TD(dclass="single_icon", content=A(href=target, content=single_icon))
    textTD = TD(dclass="single_index", content=SPAN(dclass="single_index", content=A(href=target, content=title)) + subtitle)
    index_rows.append(DIV(dclass="bubble", content=TABLE(TR(iconTD + textTD))))

  #TBD index_rows.append(TR(TD("total worldwide pressings: " + str(total_issues))))

  # ----------------------------------------------------------------------------
  # Now write set of index pages that links to all the other single pages.
  # ----------------------------------------------------------------------------

  max_rows_per_index = 30;
  total_index_pages = len(index_rows)/max_rows_per_index
  if len(index_rows) % max_rows_per_index > 0: total_index_pages += 1

  for page in range(total_index_pages) :
    navDots=[]
    for link in range(total_index_pages) :
      suffix = str(link+1)
      if link == 0: suffix = ""
      if link == page:
        navDots.append(IMG(dclass="navdots", src="/pix/white_dot.gif"))
      else:
        navDots.append(A(href="index"+suffix+".html", alt="page "+suffix, content=IMG(dclass="noborder navdots", border="0", src="/pix/green_dot.gif")))

    my_rows = index_rows[:max_rows_per_index]
    del index_rows[:max_rows_per_index]
    single_index_text = templates.getSingleIndex().substitute(
      TITLE = DIV(dclass='heading padded10', content="Elton John Singles"),
      DESCR = DIV(dclass='description', content=description),
      ISSUES = "\n".join(my_rows),
      NAVBAR = DIV(content=DIV(content=" ".join(navDots))),
    )
    suffix = str(page+1)
    if page == 0: suffix = ""
    with open(singles_root+"index"+suffix+".html", "w") as singleindex:
      singleindex.write(single_index_text)

  return total_issues
예제 #19
0
def generate_songs():
    root = ET.parse(location.dbroot + "songs.xml").getroot()

    # STEP 1: set the alphabetizable id for each song
    alphaIndex = defaultdict(
        list)  # letter -> list of alphatitles starting with letter
    alphaElements = {}  # alpha-ranked_title -> XML_song
    for song in root:
        if song.tag == 'introduction':
            introduction = ET.tostring(song)
            continue
        if song.tag == 'copyright':
            warning = ET.tostring(song)
            continue
        if song.tag == 'metadata':
            metadata = song.text
            continue
        if song.get('nolink'): continue
        alphatitle = song.get('title')
        alphatitle = re.sub('\)', '', alphatitle)
        alphatitle = re.sub('\(', '', alphatitle)
        alphatitle = re.sub('^A ', '', alphatitle)
        alphatitle = re.sub('^The ', '', alphatitle)
        if alphatitle[0].isdigit(): alphatitle = "0" + alphatitle
        alphaIndex[alphatitle[0]].append(alphatitle)
        alphaElements[alphatitle] = song

    # STEP 2: set the alphabetized prev/next IDs for each song
    prevsong = None
    for aid in sorted(alphaElements):
        if prevsong != None:
            prevsong.set('nextid', alphaElements[aid].get('fileID'))
            alphaElements[aid].set('previd', prevsong.get('fileID'))
        prevsong = alphaElements[aid]

    # STEP 3: run each song through template and write to file
    totalsongs = 0
    searchable = []
    for song in root.findall('song'):
        if song.get('nolink'): continue
        totalsongs += 1
        title = song.get('title')
        asin = song.get('amazon')
        if asin: amazonWidget = getAmazonWidget(asin, title)
        else: amazonWidget = ""
        #itunesCode = song.get('itunes')
        #if itunesCode: itunesButton = getItunesLink(itunesCode)
        #else: itunesButton=""
        itunesButton = ""  # TBD: need new affiliate links

        copyright = ""
        lyrics = []
        notes = []
        creditrows = []
        searchtext = ""
        for element in song:
            if element.tag == 'copyright':
                copyright = " ".join(
                    ["&copy;",
                     element.get('year'),
                     element.get('owner')])
            if element.tag == 'credit':
                creditType = re.sub(' ', '&nbsp;', element.get('type'))
                creditrows.append(
                    TR(
                        TD(dclass="credit_type", content=creditType + ":") +
                        TD(dclass="credit_name", content=B(element.text))))
            if element.tag == 'note':
                notes.append(element.text)
            if element.tag == 'lyrics':
                for verse in element:
                    if verse.text: searchtext += re.sub('\n', ' ', verse.text)
                    if verse.tag == 'verse':
                        versecontent = re.sub('\n', '<br/>\n', verse.text[1:])
                        lyrics.append(DIV(dclass="verse",
                                          content=versecontent))
                    if verse.tag == 'chorus':
                        versecontent = re.sub('\n', '<br/>\n', verse.text[1:])
                        lyrics.append(
                            DIV(dclass="chorustag", content="chorus:") +
                            DIV(dclass="chorus", content=versecontent))
                    if verse.tag == 'repeat':
                        if verse.get('chorus'):
                            lyrics.append(
                                DIV(dclass="chorusrepeat",
                                    content="(repeat chorus " +
                                    verse.get('chorus') + ')'))
                        else:
                            lyrics.append(
                                DIV(dclass="chorusrepeat",
                                    content="(repeat chorus)"))

        if len(searchtext):
            searchable.append('|'.join([
                song.get('fileID'),
                song.get('title'),
                song.get('title').lower() + ' ' + searchtext.lower()
            ]))
        credittable = TABLE(dclass="credits", content="\n".join(creditrows))
        if lyrics: alllyrics = "".join(lyrics)
        else: alllyrics = "(instrumental)"
        allnotes = "<br/>".join(notes)
        nextlink = ""
        if song.get('nextid'): nextlink = song.get('nextid')
        prevlink = ""
        if song.get('previd'): prevlink = song.get('previd')

        song_text = getLyricPageTemplate().substitute(
            NEXTID=nextlink,
            PREVID=prevlink,
            SONG_TITLE=title,
            SONG_CREDITS=credittable,
            SONG_NOTES=allnotes,
            SONG_LYRICS=DIV(dclass="bubble large", content=alllyrics),
            AMAZON=amazonWidget,
            ITUNES=itunesButton,
            SONG_COPYRIGHT=copyright)

        songsroot = location.docroot + "songs/"
        with open(songsroot + song.get('fileID') + ".html", "w") as songfile:
            print "generating", title
            songfile.write(song_text.encode('UTF-8'))

    # STEP 4: generate an index page for each alphabet letter
    for letter in '0' + string.uppercase:
        songRows = []
        for title in sorted(alphaIndex[letter]):
            song = alphaElements[title]
            songRows.append(
                DIV(dclass="padded3",
                    content=A(href=song.get('fileID') + ".html",
                              content=song.get('title'))))

        index_text = getLyricsIndexTemplate(
            "Elton John \"" + letter + "\" Songs").substitute(
                EXTRA_HEADER="",
                LISTING=DIV(dclass="bubble important padded3",
                            content="\n".join(songRows)))
        with open(songsroot + letter + "_index.html", "w") as indexfile:
            indexfile.write(index_text.encode('UTF-8'))

    # STEP 5: generate a single introduction index page for all lyrics
    index_text = getLyricsIndexTemplate("Elton John Song Lyrics").substitute(
        EXTRA_HEADER=META(name="description", content=metadata),
        LISTING=DIV(dclass="margin20 important", content=introduction) +
        DIV(dclass="bubble small", content=warning),
    )
    with open(songsroot + "index.html", "w") as indexfile:
        indexfile.write(index_text.encode('UTF-8'))

    # STEP 6: generate a data file that the CGI script uses to search lyrics
    with open(location.dbroot + "searchable_lyrics.txt", "w") as searchfile:
        searchfile.write("\n".join(searchable).encode('UTF-8'))

    return totalsongs
예제 #20
0
def generate_session_albums():
    totalAlbums = 0
    loadTracks(location.dbroot + "album_tracks.xml")
    sessionroot = location.docroot + "albums/sessions/"
    picroot = sessionroot + "pix/"
    root = XML.parse(location.dbroot + 'sessionwork.xml').getroot()
    totalrecords = 0

    description = root.find('description')
    #description = description.text
    description = XML.tostring(description)
    index_rows = []
    songrows = []

    songrows.append(
        TR(
            TD(B(U("released"))) + TD(B(U("title"))) +
            TD(B(U("original artist")))))
    for song in root.findall('listing/song'):
        year = song.get('date')[:4]
        month = song.get('date')[5:7]
        month = monthAbbreviation[month]
        eltonvocals = song.get('elton', default="lead vocals")
        eltonvocals = " [" + eltonvocals + "]"
        songrow = TR(
            TD(month + " " + year) +
            TD(B(U(song.get('title'))) + eltonvocals) + TD(song.get('artist')))
        songrows.append(songrow)
    songtable = DIV(dclass="bubble",
                    content=TABLE(content="\n".join(songrows),
                                  dclass="left small"))
    description += songtable

    for category in root.findall('category'):
        if category.get('private'): continue
        format = category.get('format')
        categoryname = category.get('format')

        for issue in category:
            if issue.get('private'): continue
            #if issue.get('pic') == None: continue
            totalrecords += 1
            title = issue.get('title')
            if title == None: title = ""
            if format == "7": title = "7-inch single"
            if format == "CD5": title = "CD single"
            catalog = issue.get('catalog')
            if catalog == None:
                print "no catalog for", title
                continue

            pic = issue.get('pic')
            if pic == None:
                picTD = TD(dclass="missing_sleeve", content="[no sleeve]")
            else:
                picfile = picroot + pic
                if os.path.isfile(picfile):
                    (type, width, height) = getImageInfo(picfile)
                    picTD = TD(dclass="single_sleeve",
                               content=IMG(dclass="sleeve",
                                           src="pix/" + pic,
                                           width=width,
                                           height=height))
                else:
                    picTD = TD(dclass="missing_sleeve",
                               content="[photo not available]")
                    print "ERROR: can't find session picture:", title, catalog

            year = issue.get('year', default="")
            if len(year): year = " (" + year[:4] + ")"
            trackrows = []
            for track in issue.findall('track'):
                if track.get('artist') == "anonymous":
                    trackrows.append(
                        LI(dclass="anonymous", content=track.get('title')))
                else:
                    trackrows.append(
                        LI(dclass="track", content=linkTrack(track)))

            reftracks = []
            for element in issue:
                if element.tag == 'tracks':
                    reftracks = reftracks + alltracks[element.get('id')]
            for track in reftracks:
                trackrows.append(LI(dclass="track", content=linkTrack(track)))

            prefix = issue.get('discs', "")
            iconfile = "/pix/" + prefix + format + ".gif"
            (type, width, height) = getImageInfo(location.docroot + iconfile)
            icon = IMG(dclass="padded10",
                       src=iconfile,
                       width=width,
                       height=height)

            notes = ""
            for note in issue.findall('note'):
                notes += BR() + note.text

            tracktable = OL("\n".join(trackrows))
            title = DIV(dclass="large bold", content=title)
            detailsText = icon + title + catalog + year + notes
            detailsTD = TD(dclass="guest_text",
                           content=detailsText + BR() + tracktable)
            session_issue = TABLE(TR(picTD + detailsTD))
            index_rows.append(DIV(dclass="bubble", content=session_issue))

        session_index_text = templates.getSessionIndex().substitute(
            TITLE=DIV(dclass="heading padded10",
                      content="Elton John as a Session Musician"),
            DESCR=DIV(dclass="description", content=description),
            ALBUMS=DIV(dclass="full_width", content="\n\n".join(index_rows)),
        )
        with open(sessionroot + "index.html", "w") as sessionindex:
            sessionindex.write(session_index_text.encode('latin-1'))

    return totalrecords
예제 #21
0
def parse_standard_albums():
    totalAlbums = 0
    loadTracks(location.dbroot + "album_tracks.xml")
    albumroot = location.docroot + "albums/standard/"
    picroot = albumroot + "pix/"
    root = ET.parse(location.dbroot + 'category_albums.xml').getroot()
    ##decodedroot = ET.tostring(root)
    ##root2 = ET.fromstring(decodedroot)

    ### establish prev/next icons
    for category in root:
        if category.tag == 'description':
            pageDescription = DIV(dclass="description", content=category.text)
            continue
        prevalbum = None
        for album in category:
            album.set('previcon', "")
            album.set('nexticon', "")
            if prevalbum != None:
                prevpic = IMG(src="/pix/left_arrow.gif",
                              border="0",
                              title=prevalbum.get('title'))
                nextpic = IMG(src="/pix/right_arrow.gif",
                              border="0",
                              title=album.get('title'))
                prevalbum.set('nexticon',
                              A(href=album.get('id') + ".html",
                                content=nextpic))  # forward link
                album.set('previcon',
                          A(href=prevalbum.get('id') + ".html",
                            content=prevpic))  # backward link
            prevalbum = album

    styles = []
    catThumbs = {}
    categories = []
    for category in root:
        if category.tag == 'description': continue
        ### create the CSS style & index matrix for all the sprites in this category
        thumbs = []
        for album in category:
            id = album.get('id')
            XY = '-' + album.get('spriteX') + 'px ' + '-' + album.get(
                'spriteY') + 'px'
            imagecss = "img#" + id + "{ width:50px; height:50px; background:url(sprite.jpg) " + XY + ";}"
            styles.append(
                imagecss)  # each album gets an icon in their category
            thumbs.append(minilink(album))
        categories.append(category.get('name'))
        catThumbs[category.get('name')] = DIV(dclass="thumbnails",
                                              content=" ".join(thumbs))

        ### create an HMTL page for each album
        for album in category:
            totalAlbums += 1
            albumnotes = []
            versions = []
            title = album.get('title')
            for element in album:
                if element.tag == 'see': continue
                if element.tag == 'note':
                    albumnotes.append(element.text)
                    continue

                # otherwise it's a version
                tracks = []
                versionNotes = []
                version = element
                name = version.get('name')
                if name == None: name = ""
                year = '(' + version.get('year')[:4] + ')'
                amazonID = version.get('amazon')
                if amazonID: amazon = templates.getAmazonButton(amazonID)
                else: amazon = ""

                picname = version.get('pic')
                if not os.path.isfile(picroot + picname):
                    print "error no pic", picname
                (type, width, height) = getImageInfo(picroot + picname)
                image = IMG(dclass="sleeve",
                            src="pix/" + picname,
                            width=width,
                            height=height)
                picTD = TD(dclass="single_sleeve", content=image)

                for element in version:
                    if element.tag == 'tracks':
                        tracks = tracks + alltracks[element.get('id')]
                    elif element.tag == 'section':
                        tracks = tracks + [element]
                    elif element.tag == 'note':
                        versionNotes.append(element.text)
                    else:
                        print "bad tag", element.tag
                trackrows = []
                trackrows.append(
                    TR(
                        TD(dclass="single_details",
                           colspan=2,
                           content=" ".join([name, year]))))
                for note in versionNotes:
                    trackrows.append(
                        TR(TD(dclass="note", colspan=2, content=note)))
                trackrows.append(
                    TR(TD(dclass="amazon", colspan=2, content=amazon)))
                for track in tracks:
                    if track.tag == 'section':
                        trackrows.append(
                            TR(
                                TD(colspan=2,
                                   dclass="tracksection",
                                   content=track.get('title'))))
                        continue
                    tracktime = TD(dclass="time", content=track.get('length'))
                    tracktext = TD(dclass="track", content=linkTrack(track))
                    trackrows.append(TR(tracktime + tracktext))
                tracktable = TABLE("\n".join(trackrows))
                detailsTD = TD(tracktable)
                versiontable = TABLE(dclass="single_issue",
                                     content=TR(picTD + detailsTD))
                versions.append(DIV(dclass="bubble", content=versiontable))
            page_template = templates.getStandardAlbumTemplate(title)
            album_text = page_template.substitute(
                NEXTICON=album.get('nexticon'),
                PREVICON=album.get('previcon'),
                ALBUM_TITLE=DIV(dclass="heading", content=U(title)),
                ALBUM_NOTES=DIV(dclass="subheading",
                                content="<br/>".join(albumnotes)),
                VERSIONS="\n".join(versions))
            target = album.get('id') + ".html"
            with open(albumroot + target, "w") as albumfile:
                albumfile.write(album_text.encode('UTF-8'))
        # end album
    #end category

    catDivs = []
    for category in categories:
        catDivs.append(
            DIV(dclass="bubble",
                content=DIV(dclass="heading", content=category + ':') +
                catThumbs[category]))

    albumCSS = STYLE(content="\n".join(styles))
    index_template = templates.getStandardIndexTemplate()
    index_text = index_template.substitute(
        EXTRA_STYLE=albumCSS,
        CONTENT=pageDescription + "".join(catDivs),
    )
    with open(albumroot + "index.html", "w") as indexfile:
        indexfile.write(index_text.encode('UTF-8'))

    return totalAlbums
예제 #22
0
def generate_books():
    totalBooks = 0
    totalPages = 0
    bookspath = location.docroot + "books/"
    picpath = bookspath + "pix/"
    bubbles = []
    root = ET.parse(location.dbroot + 'books.xml').getroot()
    for book in root:
        if book.tag == "introduction":
            introduction = book.text
            continue
        pages = int(book.get('pages'))
        totalPages += pages
        totalBooks += 1
        if book.get('private'): continue

        rows = []
        pic = book.get('pic')
        picfile = picpath + pic
        try:
            (type, width, height) = getImageInfo(picfile)
            imageTD = TD(dclass="single_sleeve",
                         content=IMG(dclass="sleeve",
                                     src="pix/" + pic,
                                     width=width,
                                     height=height))
            if width != 200: print "bad width for", pic
        except IOError:
            print "cannot find picture for", book.get('title'), ":", pic
        titletext = book.get('title')
        rows.append(
            DIV(dclass="important left", content="Title: " + U(B(titletext))))
        if book.get('author'):
            authortext = book.get('author')
            rows.append(DIV(dclass="left", content="Author: " + B(authortext)))
        rows.append(DIV(dclass="left", content="Year: " + B(book.get('year'))))
        if book.get('publisher'):
            pubtext = book.get('publisher')
            rows.append(DIV(dclass="left", content="publisher: " + B(pubtext)))
        if book.get('ISBN'):
            rows.append(
                DIV(dclass="left", content="ISBN: " + B(book.get('ISBN'))))
        if book.get('country'):
            rows.append(
                DIV(dclass="left",
                    content="Country: " + B(book.get('country'))))
        rows.append(DIV(dclass="left", content="pages: " + B(str(pages))))
        rows.append(
            DIV(dclass="left", content="binding: " + B(book.get('format'))))
        if book.get('amazon'):
            rows.append(
                DIV(dclass="left",
                    content=templates.getAmazonButton(book.get('amazon'))))

        d = book.find('description')
        if d is not None:
            if d.get('source'):
                rows.append(
                    DIV(dclass="left small padded3 bold",
                        content="[description text from " + d.get('source') +
                        ":]"))
            rows.append(DIV(dclass="left", content=ET.tostring(element=d)))
        textTD = TD(dclass="top", content="".join(rows))
        bubbles.append(
            DIV(dclass="bubble", content=TABLE(TR(imageTD + textTD))))

    #index_text = templates.getBooksIndex().substitute(
    # DESCR  = DIV(dclass="description", content=introduction),
    # BOOKS  = DIV(dclass="full_width", content="\n\n".join(bubbles)),
    #)

    # figure out how many index pages we need to create
    max_rows_per_index = 14
    total_index_pages = len(bubbles) / max_rows_per_index
    if len(bubbles) % max_rows_per_index > 0: total_index_pages += 1

    # chop away at the bubbles list, moving them into the current index page
    bookroot = location.docroot + "books/"
    for page in range(total_index_pages):
        my_rows = bubbles[:
                          max_rows_per_index]  # grab the books that go into this index page
        del bubbles[:max_rows_per_index]  # clean up as we go
        book_index_text = templates.getBooksIndex().substitute(
            EXTRA_HEADER="",
            DESCR=DIV(dclass="description", content=introduction),
            BOOKS=DIV(dclass="full_width", content="\n\n".join(my_rows)),
            #NAVBAR = DIV(content=DIV(content=" ".join(navDots))),
            NAVBAR=templates.getDotsDiv(page, total_index_pages),
        )
        suffix = str(page + 1)
        if page == 0: suffix = ""
        with open(bookroot + "index" + suffix + ".html", "w") as bookindex:
            bookindex.write(book_index_text.encode('UTF-8'))
    return totalBooks
예제 #23
0
def parse_other_albums():
    totalAlbums = 0
    loadTracks(location.dbroot + "album_tracks.xml")
    albumroot = location.docroot + "albums/international/"
    picroot = albumroot + "pix/"
    root = ET.parse(location.dbroot + 'other_albums.xml').getroot()

    # establish next/prev links
    prevcountry = None
    for country in root:
        if country.tag == "description": continue
        if country.get('private'): continue
        country.set('previcon', "")
        country.set('nexticon', "")
        country.set('id', re.sub(' ', '_', country.get('name')).lower())
        if prevcountry != None:
            prevcountry.set('nexticon', linkto("right",
                                               country))  # forward link
            country.set('previcon', linkto("left",
                                           prevcountry))  # backward link
        prevcountry = country

    indexrows = []
    for country in root:
        if country.tag == "description":
            description = country.text
            continue
        if country.get('private'): continue
        count = 0
        name = country.get('name')
        bubbles = []

        for album in country:
            print album.get('title')
            if album.get('private'): continue
            count += 1
            totalAlbums += 1
            # TBD  id = album.get('id')
            picfile = country.get('id') + '/' + album.get('pic')
            picpath = picroot + picfile
            if not os.path.isfile(picpath): print "error no pic: " + picpath
            (type, width, height) = getImageInfo(picpath)
            image = IMG(dclass="sleeve",
                        src="pix/" + picfile,
                        width=width,
                        height=height)
            picTD = TD(dclass="single_sleeve", content=image)

            discs = album.get('discs')
            if discs: prefix = discs
            else: prefix = ""
            iconfile = "/pix/" + prefix + album.tag + ".gif"
            iconpath = location.docroot + iconfile
            (type, width, height) = getImageInfo(iconpath)
            iconTD = TD(
                IMG(dclass="padded10",
                    src=iconfile,
                    width=width,
                    height=height))
            details = []
            details.append(
                DIV(dclass="left important", content=U(album.get('title'))))
            details.append(
                DIV(dclass="left", content="Year: " + B(album.get('year'))))
            details.append(
                DIV(dclass="left",
                    content="Catalog: " + B(album.get('catalog'))))
            textTD = TD("\n".join(details))
            headerTable = TABLE(TR(iconTD + textTD))

            notes = []
            tracks = []
            for element in album:
                if element.tag == 'tracks':
                    tracks = tracks + alltracks[element.get('id')]
                elif element.tag == 'note':
                    notes.append(element.text)
                elif element.tag == 'see':
                    notes.append(element.text)
                else:
                    print "bad tag", element.tag
            notesDiv = DIV(dclass="left padded3", content="<br/>".join(notes))
            trackrows = []
            for track in tracks:
                tracktime = TD(dclass="time", content=track.get('length'))
                tracktext = TD(dclass="track", content=linkTrack(track))
                trackrows.append(TR(tracktime + tracktext))
            tracksTable = TABLE("\n".join(trackrows))
            detailsTD = TD(headerTable + notesDiv + tracksTable)
            bubbles.append(
                DIV(dclass="bubble",
                    content=TABLE(dclass="single_issue",
                                  content=TR(picTD + detailsTD))))

        page_template = templates.getInternationalAlbumTemplate(name)
        page_text = page_template.substitute(NEXTICON=country.get('nexticon'),
                                             PREVICON=country.get('previcon'),
                                             COUNTRY=DIV(dclass="heading",
                                                         content="select " +
                                                         name + " pressings"),
                                             ALBUMS="\n".join(bubbles))

        target = country.get('id') + ".html"
        with open(albumroot + target, "w") as countryfile:
            countryfile.write(page_text.encode('UTF-8'))

        flagimg = A(href=target,
                    content=IMG(dclass="hardleft20",
                                src="/pix/flags/" + country.get('id') +
                                ".gif"))
        namespan = SPAN(dclass="important hardleft200",
                        content=A(href=target, content=name))
        s = ""
        if count > 1: s = "s"
        countspan = SPAN(dclass="important hardleft400",
                         content=A(href=target,
                                   content=str(count) + " pressing" + s))
        indexrows.append(
            DIV(dclass="left bubble", content=flagimg + namespan + countspan))

    index_template = templates.getInternationalIndexTemplate()
    index_text = index_template.substitute(
        EXTRA_STYLE="",
        PAGE_TITLE="Elton John International Albums",
        PAGE_CONTENT=DIV(dclass="description", content=description) +
        "".join(indexrows),
    )

    with open(albumroot + "index.html", "w") as indexfile:
        indexfile.write(index_text)

    return totalAlbums
예제 #24
0
def topad():
    ebaylink = "http://www.ebay.com/sch/captain_fantastic/m.html?item=161127422228&ssPageName=STRK%3AMESELX%3AIT&rt=nc&_trksid=p2047675.l2562"
    return DIV(dclass="banner",
               content=A(href=ebaylink, content="Rare items for sale on Ebay"))
예제 #25
0
def generate_magazines():
    totalMags = 0
    magspath = location.docroot + "magazines/"
    picpath = magspath + "pix/"
    bubbles = defaultdict(list)
    root = ET.parse(location.dbroot + 'magazines.xml').getroot()
    for mag in root:
        if mag.tag == "introduction":
            #introduction = mag.text
            introduction = ET.tostring(mag)
            continue
        if mag.get('private'): continue  # skip stuff not ready for publication
        if mag.get('own') == "no":
            continue  # skip stuff that I don't actually have
        if mag.get('nocover'):
            continue  # skip stuff if elton not on the cover page
        if mag.tag == "fanmagazine":
            continue  # fan magazines will be done some other way
        pic = mag.get('pic')
        if pic == None: continue  # TBD: we should complain about missing pic
        totalMags += 1
        rows = []
        picfile = picpath + pic
        try:
            (type, width, height) = getImageInfo(picfile)
            allPicFiles.remove(pic)
            imageTD = TD(dclass="single_sleeve",
                         content=IMG(dclass="sleeve",
                                     src="pix/" + pic,
                                     width=width,
                                     height=height))
            if width != 200: print "bad width for", pic
        except:
            try:
                print "cannot find picture for", mag.get('title'), mag.get(
                    'date'), ":", pic
            except:
                print "cannot find picture for", mag.get('date')
        titletext = mag.get('title')
        rows.append(DIV(dclass="important left", content=U(B(titletext))))
        issuetext = mag.get('date')
        year = addYear(issuetext)
        date = issuetext.split('-')
        if len(date) > 1:
            if date[1] in monthAbbreviation:
                date[1] = monthAbbreviation[date[1]]
        if len(date) == 2:
            issuetext = date[1] + " " + date[0]
        if len(date) == 3:
            issuetext = date[1] + " " + date[2] + ", " + date[0]
        if (mag.get('issue') != None):
            if is_number(mag.get('issue')):
                issuetext = issuetext + ' (#' + mag.get('issue') + ')'
            else:
                issuetext = issuetext + ' (' + mag.get('issue') + ')'
        rows.append(DIV(dclass="left", content="Issue Date: " + B(issuetext)))
        rows.append(
            DIV(dclass="left", content="Country: " + B(mag.get('country'))))

        color = "blue"
        #if mag.get('own') != None : color = "yellow"

        textTD = TD(dclass="top", content="".join(rows))
        bubbles[year].append(
            DIV(dclass="bubble " + color, content=TABLE(TR(imageTD + textTD))))

    # this javascript gets added to each mags html file
    # it is the response to load a new page when a selection is made
    yearScript = '''
<script type="text/javascript">
  function showYear(selector,firstyear) {
    year = selector.options[selector.selectedIndex].value
    if (year == firstyear) year = ""
    newurl = "index" + year + ".html";
    document.location=newurl;
  }
</script>
'''

    # divide all the magazines into sepatate index files sorted by year
    magroot = location.docroot + "magazines/"
    prevlink = None
    for y in allYears:
        mag_index_text = templates.getMagazineIndex().substitute(
            EXTRA_HEADER=yearScript,
            DESCR=DIV(dclass="description", content=introduction),
            BOOKS=DIV(dclass="full_width", content="\n\n".join(bubbles[y])),
            NAVBAR=yearSelector(y),
        )
        suffix = str(y)
        if y == allYears[0]: suffix = ""
        with open(magroot + "index" + suffix + ".html", "w") as magindex:
            magindex.write(mag_index_text.encode('UTF-8'))
    return totalMags
예제 #26
0
def getSearchBox():
    searchform = """<form action="/cgi-bin/lyrics-search.cgi" METHOD=POST>
    Search Elton John song lyrics: <input type="TEXT" SIZE="45" name="query" maxsize=60>
  </form>"""
    return DIV(dclass="lyrics_search", content=searchform)
예제 #27
0
def parse_guest_appearances():
    records = 0
    picpath = location.docroot + "albums/appearances/pix/"
    guestAlbums = ET.parse(location.dbroot + 'guest.xml').getroot()
    index_rows = []
    for album in guestAlbums:
        if album.tag == 'description':
            guest_description = ET.tostring(album)
            continue

        if album.get('private'): continue
        records += 1
        if album.tag == "single":
            title = SPAN(dclass="title", content="[single]")
        if album.tag == "album":
            title = SPAN(dclass="title", content=album.get('title'))
        artist = SPAN(dclass="gartist",
                      content="(" + album.get('artist') + ")")
        if not artist: print "missing artist for album", album.get('title')
        if not title: print "missing title for album by", artist
        year = "(" + album.get('year')[:4] + ")"
        if not year: year = "(unknown)"

        pic = album.get('pic')
        if not pic:
            picTD = TD(dclass="missing_sleeve",
                       content="[photo not available]")
            print title, "missing guest pic", artist
            pic = "NA"
        picfile = picpath + pic
        if os.path.isfile(picfile):
            (type, width, height) = getImageInfo(picfile)
            picTD = TD(dclass="single_sleeve",
                       content=IMG(dclass="sleeve",
                                   src="pix/" + pic,
                                   width=width,
                                   height=height))
        else:
            picTD = TD(dclass="missing_sleeve",
                       content="[photo not available]")
            print "ERROR: can't find guest picture:", title, album.get(
                'artist')

        amazon = album.get('amazon')
        if amazon: amazon = templates.getAmazonButton(amazon)
        else: amazon = ""
        trackrows = []
        notes = []

        for track in album:
            if track.tag == 'issue': continue
            if track.tag == 'note':
                notes.append(track.text)
                continue
            length = track.get('length') or "#:##"
            containsTD = TD(dclass="top", content="contains:")
            textTD = TD(dclass="track", content=linkTrack(track))
            trackrows.append(TR(containsTD + textTD))

        tracktable = TABLE("\n".join(trackrows))
        detailsText = " ".join([title, artist])
        detailsText += BR() + year + BR() + amazon + BR() + BR().join(notes)
        detailsTD = TD(dclass="guest_text",
                       content=detailsText + BR() + tracktable)
        guest_entry = TABLE(TR(picTD + detailsTD))
        index_rows.append(DIV(dclass="bubble", content=guest_entry))

    # figure out how many index pages we need to create
    max_rows_per_index = 20
    total_index_pages = len(index_rows) / max_rows_per_index
    if len(index_rows) % max_rows_per_index > 0: total_index_pages += 1

    # chop away at the index_rows list, moving them into the current index page
    guestroot = location.docroot + "albums/appearances/"
    for page in range(total_index_pages):
        my_rows = index_rows[:
                             max_rows_per_index]  # grab the rows that go into this index page
        del index_rows[:max_rows_per_index]  # clean up as we go
        guest_index_text = templates.getGuestIndex().substitute(
            TITLE=DIV(dclass="heading padded10",
                      content="Elton John Guest Appearances"),
            DESCR=DIV(dclass="description", content=guest_description),
            ALBUMS=DIV(dclass="full_width", content="\n\n".join(my_rows)),
            #NAVBAR = DIV(content=DIV(content=" ".join(navDots))),
            NAVBAR=templates.getDotsDiv(page, total_index_pages),
        )
        suffix = str(page + 1)
        if page == 0: suffix = ""
        with open(guestroot + "index" + suffix + ".html", "w") as guestindex:
            guestindex.write(guest_index_text)
    return records
예제 #28
0
def generate_tours() :

  hiddenrowID = 0
  yearlist = defaultdict(list)
  locationlist = defaultdict(list)
  root = XML.parse(location.dbroot+"newconcerts.xml").getroot()
  for concert in root:
    if concert.tag == 'introduction':
      introduction = concert.text
      continue
    if concert.get('canceled'): continue
    if concert.get('postponed'): continue
    if concert.get('private'): continue
    ymd = concert.get('date')
    (year,month,day) = ymd.split('-')
    venue = concert.get('venue')
    city = concert.get('city')
    country = concert.get('country')
    tour = concert.get('tour')
    toggler = ""
    if len(list(concert)) == 0:  # if concert has any child elements
      row1 = (TR(TD(dmy(ymd))+TD(venue)+TD(city+", "+country)+TD(tour)+TD("")))
      row2 = ""
    else:
      hiddenrowID += 1
      elemID = "elem"+str(hiddenrowID)
      row1 = TR(TD(dmy(ymd))+TD(venue)+TD(city+", "+country)+TD(tour)+TD(onClick="toggle(\'"+elemID+"\')",style="cursor: pointer;",content=U("details")))
      row2 = TR(TD(dclass="left indent", style="display:none;", id=elemID, colspan=5,content=getDetails(concert)))
    yearlist[year].append(row1+row2)
    locationlist[getLocation(city,country)].append(row1+row2)

  year_opts = []
  year_opts.append(OPTION(value="index.html", content="Show Elton John Concerts By Year..."))
  for year in sorted(yearlist):
    year_opts.append(OPTION(value=str(year)+".html",content=str(year)+" ("+str(len(yearlist[year]))+") concerts"))
  yearSelector = SELECT(dclass="margin20 bold", size=1, onChange="showConcerts(this)", content="\n".join(year_opts))

  loc_opts = []
  loc_opts.append(OPTION(value="index.html", content="Show Elton John Concerts By Location..."))
  for loc in sorted(locationlist):
    loc_opts.append(OPTION(value=linkto(loc), content=loc+" ("+str(len(locationlist[loc]))+") concerts"))
  locSelector = SELECT(dclass="margin20 bold", size=1, onChange="showConcerts(this)", content="\n".join(loc_opts))

  headerRow = TR(dclass="bold underline large", content=TD("Date")+TD("Venue")+TD("City")+TD("Tour")+TD(""))  
  for year in sorted(yearlist):
    print year
    title = DIV(dclass="bold important padded10", content="Elton John " + year + " Concerts:")
    listing = TABLE(dclass="small center full_width", content=headerRow + "".join(yearlist[year]))
    tourtext = templates.getTourIndex().substitute(
      PAGE_CONTENT = yearSelector + locSelector + title + listing,
    )
    with open(toursroot + year + ".html","w") as yearfile:
      yearfile.write(tourtext.encode('UTF-8'))

  for loc in sorted(locationlist):
    title = DIV(dclass="bold important padded10", content="Elton John " + loc + " Concerts:")
    listing = TABLE(dclass="small center full_width", content=headerRow + "".join(locationlist[loc]))
    tourtext = templates.getTourIndex().substitute(
      PAGE_CONTENT = yearSelector + locSelector + title + listing,
    )
    with open(toursroot + linkto(loc),"w") as locfile:
      locfile.write(tourtext.encode('UTF-8'))

  indextext = templates.getTourIndex().substitute(
    PAGE_CONTENT = DIV(dclass="bubble description", content=introduction + "<br/>" + yearSelector + locSelector),
  )
  with open(toursroot + "index.html",'w') as indexfile:
    indexfile.write(indextext)

  return len(root)