Пример #1
0
    def get(self):
        _LATEST_COUNT = 6

        channels = globalconfig.getChannels()
        for channel in channels:
            slug = channel.get('slug')
            channel['url'] = webapp2.uri_for('channel', channel=slug)

            events = heapi.getEventPages(slug)
            for page in events:
                if page['event']['exposed']:
                    eventUrlType = 'event'
                else:
                    eventUrlType = 'hidden-event'
                # if eventId=0, error happens: 'Missing argument "eventId" to build URI.'
                page['event']['url'] = webapp2.uri_for(eventUrlType, eventScope=slug, eventId=page['event']['id'])
            events.sort(key=lambda page: page['weight'], reverse=True)
            events = events[:_LATEST_COUNT]
            globalutil.populateSourceUrl(events)
            channel['events'] = events

        chartses = snapi.getChartses()
        chartses.sort(key=lambda charts: charts['source']['added'], reverse=True)
        for charts in chartses:
            charts['url'] = webapp2.uri_for('charts', charts=charts['source']['slug'])
            charts['pages'] = charts['pages'][:_LATEST_COUNT]

        templateValues = {
            'channels': channels,
            'chartses': chartses,
        }
        self.render(templateValues, 'home.html')
Пример #2
0
    def get(self):
        siteEvents = heapi.getEventPages('sites')
        for page in siteEvents:
            if page['event']['exposed']:
                eventUrlType = 'event'
            else:
                eventUrlType = 'hidden-event'
            # if eventId=0, error happens: 'Missing argument "eventId" to build URI.'
            page['event']['url'] = webapp2.uri_for(eventUrlType, eventScope='sites', eventId=page['event']['id'])
        siteEvents.sort(key=lambda page: page['weight'], reverse=True)
        globalutil.populateSourceUrl(siteEvents)

        chartsEvents = heapi.getEventPages('chartses')
        for page in chartsEvents:
            if page['event']['exposed']:
                eventUrlType = 'event'
            else:
                eventUrlType = 'hidden-event'
            # if eventId=0, error happens: 'Missing argument "eventId" to build URI.'
            page['event']['url'] = webapp2.uri_for(eventUrlType, eventScope='chartses', eventId=page['event']['id'])
        chartsEvents.sort(key=lambda page: page['weight'], reverse=True)

        _LATEST_COUNT = 10
        chartses = snapi.getChartses()
        chartses.sort(key=lambda charts: charts['source']['added'], reverse=True)
        for charts in chartses:
            charts['url'] = webapp2.uri_for('charts', charts=charts['source']['slug'])
            charts['pages'] = charts['pages'][:_LATEST_COUNT]


        templateValues = {
            'siteEvents': siteEvents,
            'chartsEvents': chartsEvents,
            'chartses': chartses,
        }
        self.render(templateValues, 'hot.html')