In [1]:
list_of_workshops = pd.read_csv("2017/workshops-2017.csv")

In [7]:
#Creates individual section for workshop speaker
def speaker_block(speaker_name, speaker_bio, bio_id):
    return """
          <div class="row">
          
              <div class="col-md-4>
                <img class="img-responsive" src="assets/img/wks/{bio_id}.jpg" >
                  
              </div>
              
              <div class="col-md-8">
                <h3>{speaker_name}</h3>
                <p>{speaker_bio}</p>
                <p></p><!--Social media/website links-->
                <p>Other workshops: <a href="">Workshop 1</a>, <a href="">Workshop 2</a></p><!--If applicable-->
              </div>
              
          </div>
          
""".format(speaker_name=speaker_name, speaker_bio=speaker_bio, bio_id = bio_id)

In [ ]:
#Compile all of the speakers of one workshop
def get_all_speakers(list_of_workshops, num_speakers):
    #Create a list of all of the speaker names
    list_of_names = list_of_workshops.iloc[3,5,7]
    #Create a list of all of the speaker bios
    list_of_bios = list_of_workshops.iloc[4,6,8]
    list_of_ids = list_of_workshops #create id creator function to add to dataframe
    total_speaker_blocks = """"""
    #Create a speaker block string for each speaker
    for x in range(num_speakers):
        total_speaker_blocks += speaker_block(list_of_names[x], list_of_bios[x], list_of_ids[x])
    return total_speaker_blocks

In [8]:
def presentor_section(num_presentor, presentor_block):
    presentor_chunk = """<div class="row">"""
    for presentor in range(num_presentor):
    if ((presentor % 3) == 0) & presentor !=0:
        presentor_chunk += """</div> \n <div class="row">"""
      
        presentor_chunk += str(presentor_block[presentor]) #future present_block(function)
      
    else: 
        presentor_chunk += presentor_block[presentor]
        presentor_chunk += """</div>"""
    return presentor_chunk
#add end div
#def for taking first lower(initial), and lower(lastname) to construct different directores
#def for creating short bio

In [9]:
#presentor_block = ['A', 'B', 'C', 'D', 'E']
#presentor_block = ['A', 'B', 'C', 'D', 'E', 'F']
presentor_block = ['A', 'B']
num_presentor = len(presentor_block)
print presentor_section(num_presentor, presentor_block)

In [2]:
#Creates speaker directory ID from track id and speaker name (probably not necessary)
def speaker_directory (track_id, speaker_first, speaker_last):
    first_names = speaker_first.split(' ')
    first_initials = ""
    for name in first_names:
        first_initials += name[0]
  
    return track_id + first_initials + speaker_last


1RBLu

In [11]:
#Creates shortened bio (probably not necessary)
def short_bio(bio):
    charcount = 0
    wordcount = 0
      for char in bio:
        charcount += 1
        if wordcount < 20:
            if char == ' ':
                wordcount += 1 
        else:
              return bio[:charcount-2] + "..." #return first 20 words of bio
  
    return bio[:50] + "..." #return first 50 chars by default

In [12]:
def presentor_chunk(presentor_img_url, presentor_img_alt_txt, presentor_bio_prev):
    return """
  <div class="col-sm-6 col-md-4">
     <div class="thumbnail">
         <img src="{presentor_img_url}" alt="{presentor_img_alt_txt}">
                  <div class="caption">
                    <h3>Thumbnail label</h3>
                    <p>{presentor_bio_prev}</p>
                    <p><a href="#" class="btn btn-primary" role="button">Read Full Bio</a></p>
                  </div>
      </div>
   </div>""".format(presentor_img_url=presentor_img_url, presentor_img_alt_txt=presentor_img_alt_txt, presentor_bio_prev=presentor_bio_prev)

In [13]:
#Creates formatted opening section with workshop track, title, description
def wks_info (track, wks_title, wks_descr):
    if track == 1:
        track-string = "Track 1: Community"
    elif track == 2:
        track-string = "Track 2: National"
    elif track == 3:
        track-string = "Track 3: Global"
    
    return = """
    <h2>""" + track-string + """Track 1: Community</h2>

    <h2>{wks_title}</h2>

    <p>{wks_descr}</p>
      """.format(track=track, wks_title=wks_title, wks_descr=wks_descr)

In [14]:
def write_wks_page(list_of_workshops, year):
    header = """
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content=".">
    <meta name="author" content="Richard Lu">
    <link rel="icon" href="assets/favicon.ico">

    <title>NYCAASC | {year} Workshops </title>

    <!-- Bootstrap core CSS -->
    <link href="assets/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="assets/css/navbar-fixed-top.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="assets/css/nycaasc-custom.css" rel="stylesheet">
    <!-- Streetvertising Font CSS -->
    <link href="assets/css/font-streetvertising.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="..//assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

</head>
""".format(year=year, title=title)
    
    navigator = """
    
    <header id="header"></header>
    
    """
    
    # Loop through all lines in the file
    year = year
    for row in list_of_workshops:
        background_img = list_of_workshops['background_img'][x]
        track_title = list_of_workshops['track_title'][x]
        wks_title = list_of_workshops['Title of workshop']
        num_speakers = list_of_workshops['Number of speakers/facilitators'][x]
        presentor_img_url = list_of_workshops['presentor_img_url'][x]
        presentor_img_alt_txt = list_of_workshops['presentor_img_alt_txt'][x]
        presentor_bio_prev = list_of_workshops['presentor_bio_prev'][x]
        presentor_section = presentor_section()
    
    wks_page = header + navigator + wks_info(track, wks_title, wks_descr) + wks_presentors(presentor_img_url, presentor_img_alt_txt, presentor_bio_prev)
  
  #path_to_repo is the path where you are storing the NYCAASC website locally
    directory ="{path_to_repo}/wks/{year}/{track_id}/{wks_num}.html".format("path_to_repo=path_to_repo, year=year, track_id=track_id wks_num=wks_num")
    f = open(directory, 'w')
    f.write(wks_page)
    f.close()

In [ ]: