當前位置: 首頁>>代碼示例>>Python>>正文


Python Timeline.get_json方法代碼示例

本文整理匯總了Python中timeline.Timeline.get_json方法的典型用法代碼示例。如果您正苦於以下問題:Python Timeline.get_json方法的具體用法?Python Timeline.get_json怎麽用?Python Timeline.get_json使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在timeline.Timeline的用法示例。


在下文中一共展示了Timeline.get_json方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: timeline_json

# 需要導入模塊: from timeline import Timeline [as 別名]
# 或者: from timeline.Timeline import get_json [as 別名]
def timeline_json():
    headline = "Timeline Photo Headline"
    text = "this is the text"
    start_date = '2012,4,12'

    # find settings
    settings = Setting.query.order_by(desc(Setting.id)).all()
    if len(settings) > 0:
        setting = settings[0]
        headline = setting.headline
        text = setting.setting_text
        start_date = setting.start_date.replace("-", ",")

    # convert timeline's start date to datetime obj
    album_start_date = datetime.datetime.strptime(start_date, "%Y,%m,%d")

    # collect all photos
    tl = Timeline(headline, text, start_date)
    photos = Photo.query.filter(Photo.visibility == True).all()
    for photo in photos:
        dt = photo.start_date.replace("-", ",")

        # convert photo's start date to datetime obj
        photo_start_date = datetime.datetime.strptime(dt, "%Y,%m,%d")
        days_in_album = (photo_start_date - album_start_date).days + 1
        # get No.D after timeline's start date
        asset_caption = _("Day %(value)d", value=days_in_album)

        text = photo.photo_text + "<BR/><BR/><A href='%s'><i class='icon-zoom-in'></i>%s</A>" % (url_for("photos.show_html", filename=photo.filename), photo.filename)

        tl.add_date(startDate=dt, headline=photo.headline, asset_media=url_for("photos.show_thumb", filename=photo.filename), text=text, asset_caption=asset_caption)
    return tl.get_json()
開發者ID:ChinaHackers,項目名稱:timeline-gallery-in-openshift,代碼行數:34,代碼來源:index.py


注:本文中的timeline.Timeline.get_json方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。