コード例 #1
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def show_person(nickname = None):
    cat = read_json(root + '/html/cat.json')

    if nickname not in cat['people']:
        return not_found()

    person = copy.deepcopy(cat['people'][nickname])
    person['videos'] = []
    for video in cat['videos']:
        if nickname in video['speakers']:
            person['videos'].append(video)

    podcasts = {
        'guests' : [],
        'hosts'  : [],
    }
    for field in ['guests', 'hosts']:
        for podcast in cat['podcasts']:
            for episode in podcast['episodes']:
                if field in episode:
                    if nickname in episode[field]:
                        podcasts[field].append(episode)

#        for field in ['episodes', 'hosting']:
#            if field not in self.people[p]:
#                self.people[p][field] = []
#            self.people[p][field].sort(key=lambda x : x['date'], reverse=True)
    return render_template('person.html',
        h1          = person['info']['name'],
        title       = 'Presentations and podcasts by ' + person['info']['name'],
        person      = person,
        events      = cat['events'],
        id          = nickname,
        podcasts    = podcasts,
    )
コード例 #2
0
def people():
    term = _term()
    cat = read_json(root + '/html/cat.json')
    ppl = cat['people']
    result = {}
    if term != '':
        for nickname in ppl.keys():
            if re.search(term, ppl[nickname]['info']['name'].lower()):
                catapp.logger.debug("People: '{}'".format(nickname))
                result[nickname] = ppl[nickname]
            elif re.search(term, ppl[nickname]['info'].get('location',
                                                           '').lower()):
                result[nickname] = ppl[nickname]
            elif term in ppl[nickname]['info'].get('topics', []):
                result[nickname] = ppl[nickname]
            #elif 'tags' in ppl[nickname] and term in ppl[nickname]['tags']:
            #    result[nickname] = ppl[nickname]

    return render_template(
        'people.html',
        title='People who talk at conferences or in podcasts',
        h1='People who talk',
        number_of_people=len(ppl.keys()),
        term=term,
        people=result,
        people_ids=sorted(result.keys()),
    )
コード例 #3
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def main():
    cat = read_json(root + '/html/cat.json')
    return render_template('index.html',
        h1          = 'Presentations from tech events worth watching',
        title       = 'Conferences, Videos, Podcasts, and People',
        stats       = cat['stats'],
    )
コード例 #4
0
def serve_collections():
    cat = read_json(root + '/html/cat.json')
    now = datetime.now().strftime('%Y-%m-%d')
    directories = {
        '/topics': 't',
        '/countries': 'l',
        '/cities': 'l',
    }
    titles = {
        '/topics': 'Topics',
        '/countries': 'Countries',
        '/cities': 'Cities',
    }
    directory = directories[request.path]
    title = titles[request.path]

    if request.path == '/cities':
        data = cat['stats']['cities']

    if request.path == '/countries':
        data = cat['stats']['countries']

    if request.path == '/topics':
        data = cat['tags']

    return render_template(
        'topics.html',
        h1=title,
        title=title,
        data=data,
        directory=directory,
        stats=cat['stats'],
        videos=(directory == 't'),
        episodes=(directory == 't'),
    )
コード例 #5
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def blasters():
    cat = read_json(root + '/html/cat.json')
    return render_template('blasters.html',
        h1           = 'Blasters - get notified about new videos',
        title        = 'Blasters',
        all_blasters = cat['blasters'],
    )
コード例 #6
0
def show_video(event=None, filename=None):
    cat = read_json(root + '/html/cat.json')
    for vid in cat['videos']:
        if vid['event'] == event and vid['filename'] == filename:
            video = vid
            break
    else:
        return not_found()

    speakers = []
    speaker_twitters = ''

    for s in video['speakers']:
        p = copy.deepcopy(cat['people'][s])
        p['nickname'] = s
        speakers.append(p)
        tw = p['info'].get('twitter')
        if tw:
            speaker_twitters += ' @' + tw

    return render_template(
        'video.html',
        h1=video['title'],
        title=video['title'],
        video=video,
        blasters=video.get('blasters'),
        events=cat['events'],
        speakers=speakers,
        speaker_twitters=speaker_twitters,
        tweet_video=get_tweet_video(video, speakers,
                                    cat['events'][video['event']]),
    )
コード例 #7
0
def by_tag(tag):
    cat = read_json(root + '/html/cat.json')
    now = datetime.now().strftime('%Y-%m-%d')

    future, earlier = events_by_tag(cat, tag)

    videos = []
    for video in cat['videos']:
        #if 'tags' in video:
        #    catapp.logger.debug("Video '{}'".format(video['tags']))
        if 'tags' in video and tag in [t['link'] for t in video['tags']]:
            videos.append(video)

    episodes = episodes_by_tag(cat, tag)

    if not future and not earlier and not videos and not episodes:
        return not_found()

    #catapp.logger.debug("Reading '{}'".format(filename))
    title = 'Open source conferences discussing {}'.format(tag)
    return render_template(
        'list.html',
        h1=title,
        title=title,
        conferences=future,
        earlier_conferences=earlier,
        videos=videos,
        events=cat['events'],
        #episodes    = data[d].get('episodes'),
        cal='t/{}.ics'.format(tag),
    )
コード例 #8
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def contribute(filename = None):
    cat = read_json(root + '/html/cat.json')
    return render_template('contribute.html',
        h1          = 'Contribute to Code And Talk',
        title       = 'Contribute to Code And Talk',
        stats       = cat['stats'],
    )
コード例 #9
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def about(filename = None):
    cat = read_json(root + '/html/cat.json')
    return render_template('about.html',
        h1          = 'About Code And Talk',
        title       = 'About Code And Talk',
        stats       = cat['stats'],
    )
コード例 #10
0
def sitemap():
    cat = read_json(root + '/html/cat.json')
    now = datetime.now().strftime('%Y-%m-%d')

    sitemap = []
    for event in cat['events'].values():
        sitemap.append({
            'url': '/e/' + event['nickname'],
            'lastmod': event['file_date'],
        })

    for page in [
            '/',
            '/about',
            '/all-conferences',
            '/blasters',
            '/cfp',
            '/cities',
            '/code-of-conduct',
            '/conferences',
            '/contribute',
            '/countries',
            '/diversity-tickets',
            '/series',
            '/topics',
            '/videos',
    ]:
        sitemap.append({'url': page})
    #sitemap.append({ 'url' : '/featured' })

    # add tags, cities, and countries to sitemap
    for t in cat['tags']:
        sitemap.append({'url': '/t/' + t})
    for c in cat['stats']['cities']:
        sitemap.append({'url': '/l/' + c})
    for c in cat['stats']['countries']:
        sitemap.append({'url': '/l/' + c})
    #for b in blasters:
    #    sitemap.append({ 'url' : '/blaster/' + b['file'] })

    for video in cat['videos']:
        sitemap.append({
            'url': '/v/' + video['event'] + '/' + video['filename'],
            'lastmod': video['file_date'],
        })

    html = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'
    for e in sitemap:
        #catapp.logger.debug(e)
        html += '  <url>\n'
        html += '    <loc>https://codeandtalk.com{}</loc>\n'.format(e['url'])
        if 'lastmod' in e:
            date = e['lastmod']
        else:
            date = now
        html += '    <lastmod>{}</lastmod>\n'.format(date)
        html += '  </url>\n'
    html += '</urlset>\n'
    return html
コード例 #11
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def conferences():
    cat = read_json(root + '/html/cat.json')
    return render_template('list.html',
        h1          = 'Open Source conferences',
        title       = 'Open Source conferences',
        conferences = tools.future(cat),
        stats       = cat['stats'],
        cal         = 'all.ics',
    )
コード例 #12
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def cfp_conferences():
    cat = read_json(root + '/html/cat.json')
    now = datetime.now().strftime('%Y-%m-%d')
    cfp = sorted(list(filter(lambda e: 'cfp_end' in e and e['cfp_end'] >= now, cat["events"].values())), key = lambda e: e['event_start'])
    return render_template('list.html',
        h1          = 'Call for Papers',
        title       = 'Call for Papers',
        conferences = cfp,
    )
コード例 #13
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def series():
    cat = read_json(root + '/html/cat.json')
    series = copy.deepcopy(cat['series'])
    for v in series.values():
        for e in v['events']:
            e['year'] = e['event_start'][0:4]
    return render_template('series.html',
        h1     = 'Event Series',
        title  = 'Event Series',
        series = series,
    )
コード例 #14
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def show_podcasts():
    cat = read_json(root + '/html/cat.json')
    return render_template('podcasts.html',
       h1      = 'List of podcasts',
       title   = 'List of podcasts',
#       stats   = cat['stats'],
#       tags    = cat['tags'],
       podcasts = sorted(cat['podcasts'], key=lambda s: s['title']),
#       people = cat['people'],
#       people_ids = sorted(cat['people'].keys()),
    )
コード例 #15
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def code_of_conduct():
    cat = read_json(root + '/html/cat.json')
    now = datetime.now().strftime('%Y-%m-%d')

    no_code = list(filter(lambda e: not e.get('code_of_conduct'), cat['events'].values()))
    return render_template('code-of-conduct.html',
        h1          = 'Code of Conduct',
        title       = 'Code of Conduct (or lack of it)',
        conferences = list(filter(lambda x: x['event_start'] >= now, no_code)),
        earlier_conferences = list(filter(lambda x: x['event_start'] < now, no_code)),
        stats       = cat['stats'],
    )
コード例 #16
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def diversity_tickets():
    cat = read_json(root + '/html/cat.json')
    now = datetime.now().strftime('%Y-%m-%d')

    diversity_tickets = list(filter(lambda e: e.get('diversitytickets'), cat['events'].values()))
    return render_template('diversity-tickets.html',
        h1          = 'Diversity Tickets',
        title       = 'Diversity Tickets',
        conferences = list(filter(lambda e: e['event_start'] >= now, diversity_tickets)),
        earlier_conferences = list(filter(lambda e: e['event_start'] < now, diversity_tickets)),
        stats       = cat['stats'],
    )
コード例 #17
0
def videos():
    term = _term()
    mindate = _term('mindate')
    maxdate = _term('maxdate')
    mintime = _term('mintime')
    maxtime = _term('maxtime')
    if mintime:
        min_sec = tools.in_sec(mintime)
    if maxtime:
        max_sec = tools.in_sec(maxtime)

    cat = read_json(root + '/html/cat.json')
    results = []
    if term != '' or mindate or maxdate or mintime or maxtime:
        for v in cat['videos']:
            if mindate and v['recorded'] < mindate:
                continue
            if maxdate and v['recorded'] > maxdate:
                continue
            if mintime and v['l'] < min_sec:
                continue
            if maxtime and v['l'] > max_sec:
                continue
            if term != '':
                if term in v['title'].lower():
                    results.append(v)
                    continue
                if term in v['short_description'].lower():
                    results.append(v)
                    continue
                if 'tags' in v:
                    tags = [x['link'] for x in v['tags']]
                    if term in tags:
                        results.append(v)
                        continue
            else:
                results.append(v)
                continue

    return render_template(
        'videos.html',
        title='Tech videos worth watching',
        h1='Videos',
        number_of_videos=len(cat['videos']),
        term=term,
        mindate=mindate,
        maxdate=maxdate,
        mintime=mintime,
        maxtime=maxtime,
        videos=results,
        people=cat['people'],
        events=cat['events'],
    )
コード例 #18
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def all_conferences():
    cat = read_json(root + '/html/cat.json')
    events = []
    for nick in cat['events'].keys():
        event = copy.deepcopy(cat['events'][nick])
        if 'youtube' in event and event['youtube'] == '-':
            event['youtube'] = None
        events.append(event)

    return render_template('list.html',
        h1          = 'All the Tech related conferences',
        title       = 'All the Tech related conferences',
        conferences = events,
    )
コード例 #19
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def show_blaster(nickname):
    cat = read_json(root + '/html/cat.json')
    for b in cat['blasters']:
        if b['file'] == nickname:
            blaster = b
            break
    else:
        return not_found()

    return render_template('blaster.html',
        h1          = blaster['name'] + ' Blaster',
        title       = blaster['name'] + ' Blaster',
        blaster     = blaster,
    )
コード例 #20
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def location(location):
    cat = read_json(root + '/html/cat.json')

    name, future, past = events_in_location(cat, location)
    if future == None:
        return not_found()
    title = 'Conferences in {}'.format(name.encode('ascii', 'ignore')) # was needed in Python 2

    return render_template('list.html',
        h1          = title,
        title       = title,
        conferences = future,
        earlier_conferences = past,
        cal         = 'l/{}.ics'.format(location),
    )
コード例 #21
0
def calendar(location=None, tag=None):
    cat = read_json(root + '/html/cat.json')

    if location:
        name, future, past = events_in_location(cat, location)
        prodid = 'l/{}'.format(location)
    elif tag:
        future, past = events_by_tag(cat, tag)
        prodid = 't/{}'.format(tag)
    else:
        future = tools.future(cat)
        prodid = 'all'

    if not future:
        return not_found()

    cal = _calendar(prodid, future)
    return cal
コード例 #22
0
def event(nickname):
    cat = read_json(root + '/html/cat.json')
    if nickname not in cat['events']:
        return not_found()
    event = copy.deepcopy(cat['events'][nickname])
    if 'youtube' in event and event['youtube'] == '-':
        event['youtube'] = None

    diversity = event.get('diversitytickets', None)
    if diversity:
        catapp.logger.debug("Diversity")
        event[
            'diversitytickets_url'] = "https://diversitytickets.org/events/" + diversity
    if 'diversitytickets_url' in event and 'diversitytickets_text' not in event:
        event['diversitytickets_text'] = 'Diversity Tickets'

    people = {}
    videos = []
    for video in cat['videos']:
        if video['event'] == nickname:
            videos.append(video)
        for s in video['speakers']:
            p = copy.deepcopy(cat['people'][s])
            p['nickname'] = s
            people[s] = p
    series = []
    if 'series' in event:
        series = copy.deepcopy(cat['series'][event['series']])
        for e in series['events']:
            e['year'] = e['event_start'][0:4]
    event['year'] = event['event_start'][0:4]

    #    return(str(event))
    return render_template(
        'event.html',
        title=event['name'] + ' ' + event['year'],
        h1=event['name'] + ' ' + event['year'],
        event=event,
        people=people,
        videos=videos,
        series=series,
    )
コード例 #23
0
def featured():
    cat = read_json(root + '/html/cat.json')
    now = datetime.now().strftime('%Y-%m-%d')
    featured_by_date = {}
    featured_by_blaster = {}

    for video in cat['videos']:
        featured = video.get('featured')
        blasters = video.get('blasters', [])
        if featured:
            class_name = ''
            if video['featured'] == now:
                class_name = 'today_feature'
            elif video['featured'] > now:
                class_name = 'future_feature'
            video['class_name'] = class_name
            if featured not in featured_by_date:
                featured_by_date[featured] = []
            featured_by_date[featured].append(video)

            for b in blasters:
                if b not in featured_by_blaster:
                    featured_by_blaster[b] = []
                featured_by_blaster[b].append(video)

    if request.path == '/featured':
        return render_template(
            'featured.html',
            h1='Featured Videos',
            title='Featured Videos',
            featured_by_blaster=featured_by_blaster,
        )
    elif request.path == '/featured-by-date':
        return render_template(
            'featured-by-date.html',
            h1='Featured Videos',
            title='Featured Videos',
            featured_by_date=featured_by_date,
        )
    else:
        return 'Oups'
コード例 #24
0
ファイル: app.py プロジェクト: notwaving/codeandtalk.com
def show_episodes(source):
    cat = read_json(root + '/html/cat.json')
    for p in cat['podcasts']:
        if p['name'] == source:
            podcast = copy.deepcopy(p)
            break
    else:
        return not_found()

    for e in podcast['episodes']:
        for field in ('guests', 'hosts'):
            if field in e:
                people = {}
                for person in e[field]:
                    people[person] = cat['people'][person]['info']
            e[field] = people

    return render_template('podcast.html',
        podcast = podcast,
        h1     = podcast['title'],
        title  = podcast['title'],
    )
コード例 #25
0
ファイル: notify.py プロジェクト: yishaiz/codeandtalk.com
env = Environment(loader=PackageLoader('cat'))
template = env.get_template('email.html')
# add in e-mail from https://docs.python.org/3.4/library/email-examples.html
root = os.path.dirname((os.path.realpath(__file__)))
sys.path.insert(0, root)
from cat import tools
from cat.tools import read_json

with open('subscribers.json', 'r') as fh:
    subscriptions = json.load(fh)

logger.debug(subscriptions)

db_file = root + '/html/cat.json'

cat = read_json(db_file)
if not 'events' in cat:
    raise ValueError(
        "key events is missing in {}, please generate db file (see readme)".
        format(db_file))

conferences = tools.future(cat)

html = template.render(events=conferences, title="Hello")

text = "Hello"
me = "me@email"
you = "me@email"

msg = MIMEMultipart('alternative')
msg['Subject'] = "Upcoming Events"