示例#1
0
def generate_output(setup, title, img_height, conts_to_display, skin, imgs=[]):
    """Recursively generate output for setup+continuations."""
    #not the penultimate bag, need to go deeper
    if len(setup.continuations[0].continuations) > 0:
        #store images in list to print at the end
        new_imgs = imgs.copy()  #don't think this needs to be a deepcopy
        new_imgs.append(fumen_to_image(setup.solution.fumen, img_height, skin))
        # this naming scheme could get messy, anything better? maybe Setup 1-A-A?
        # but I'm not sure what to do if more continuatons than 26, maybe just AA, then AAA
        new_ctd = conts_to_display - 1 if conts_to_display > 1 else 1
        for i, s in enumerate(tqdm(setup.continuations, unit="setup", leave=False)):
            generate_output(s, title + (" - Sub-Setup %d" % i), img_height, new_ctd, skin, new_imgs)
    else:
        h2(title)
        with div():
            for url in imgs:
                img(src=url)
            #final setup with conts, still need to display it's image
            img(src=fumen_to_image(setup.solution.fumen, img_height, skin))
            conts_to_display -= 1
            for cont in setup.continuations[:conts_to_display]:
                img(src=fumen_to_image(cont.solution.fumen, img_height, skin))
        with p():
            total_conts = len(setup.continuations)
            text("Showing ")
            b("%d" % min(conts_to_display, total_conts))
            text(" of ")
            b(a("%d continuations" % total_conts, href=fumen_url + setup.to_fumen()))
示例#2
0
def suggestions_for_goal():
    def suggestion():
        url = "{% url 'suggestion' the_goal.slug the_suggestion.slug %}"
        with column(2) as result:
            with a(href=url):
                with django_with("the_suggestion.get_current_revision as the_revision"):
                    suggestion_image()
        return result

    def list_of_suggestions():
        with django_for("the_chunk in the_suggestions|chunks:6") as result:
            with div(_class="row small-gap-below profile--suggestion-list"):
                with django_for("the_suggestion in the_chunk"):
                    suggestion()
            with django_empty():
                h5("No suggestions yet")
        return result

    with span() as result:
        with div(_class="row"):
            with column(4):
                with h4(_class=""):
                    text("Suggestions for ")
                    a("{{ the_goal }}", href=goal_url)

        with django_with("the_goal|suggestions_by:global_user as " "the_suggestions"):
            list_of_suggestions()
    return result
示例#3
0
def suggestions_for_goal():
    def suggestion():
        url = "{% url 'suggestion' the_goal.slug the_suggestion.slug %}"
        with column(2) as result:
            with a(href=url):
                with django_with(
                        "the_suggestion.get_current_revision as the_revision"):
                    suggestion_image()
        return result

    def list_of_suggestions():
        with django_for("the_chunk in the_suggestions|chunks:6") as result:
            with div(_class="row small-gap-below profile--suggestion-list"):
                with django_for("the_suggestion in the_chunk"):
                    suggestion()
            with django_empty():
                h5("No suggestions yet")
        return result

    with span() as result:
        with div(_class="row"):
            with column(4):
                with h4(_class=""):
                    text("Suggestions for ")
                    a("{{ the_goal }}", href=goal_url)

        with django_with("the_goal|suggestions_by:global_user as "
                         "the_suggestions"):
            list_of_suggestions()
    return result
示例#4
0
def reviews_for_goal():
    def review():
        with django_with("the_review.revision as the_revision") as result:
            with django_with("the_revision.suggestion as the_suggestion"):
                url = (
                    "{% url 'suggestion' the_goal.slug the_suggestion.slug %}"
                    "#sg-review-{{ the_review.pk }}")
                with column(2) as result:
                    with a(href=url):
                        suggestion_image()
        return result

    def list_of_reviews():
        with django_for("the_chunk in the_reviews|chunks:6") as result:
            with div(_class="row small-gap-below profile--suggestion-list"):
                with django_for("the_review in the_chunk"):
                    review()
            with django_empty():
                h5("No reviews yet")
        return result

    with span() as result:
        with div(_class="row"):
            with column(4):
                with h4(_class=""):
                    text("Reviews for ")
                    a("{{ the_goal }}", href=goal_url)

        with django_with("the_goal|reviews_by:global_user as the_reviews"):
            list_of_reviews()
    return result
示例#5
0
def goal_header():
    with div(_class="text-center"):
        h1("{{ request.goal.title }}")
        with div(_class="button-grp"):
            button(
                "Suggestions",
                _class="btn btn-default",
                onclick="location.href='{% url 'goal' request.goal.slug %}';"
            )
            button(
                "Members",
                _class="btn btn-default",
                onclick="location.href='{% url 'members' request.goal.slug %}';"
            )
            with django_if("request.global_user"):
                with button(
                    _class="btn btn-default",
                    onclick=(
                        "location.href='{{ profile_url }}';"
                    )
                ):
                    text("Profile")
                    with django_with(
                        "request.global_user.notifications|unread "
                        "as unread_notifications"
                    ):
                        with django_if("unread_notifications.count"):
                            text(" ({{ unread_notifications.count }})")
示例#6
0
 def list_them():
     with django_for("the_notification in notifications") as result:
         with div(_class="row"):
             text("{{ the_notification.html|safe }}")
         with django_empty():
             h5("No notifications yet")
     return result
示例#7
0
 def list_them():
     with django_for("the_notification in notifications") as result:
         with div(_class="row"):
             text("{{ the_notification.html|safe }}")
         with django_empty():
             h5("No notifications yet")
     return result
示例#8
0
def reviews_for_goal():
    def review():
        with django_with("the_review.revision as the_revision") as result:
            with django_with("the_revision.suggestion as the_suggestion"):
                url = "{% url 'suggestion' the_goal.slug the_suggestion.slug %}" "#sg-review-{{ the_review.pk }}"
                with column(2) as result:
                    with a(href=url):
                        suggestion_image()
        return result

    def list_of_reviews():
        with django_for("the_chunk in the_reviews|chunks:6") as result:
            with div(_class="row small-gap-below profile--suggestion-list"):
                with django_for("the_review in the_chunk"):
                    review()
            with django_empty():
                h5("No reviews yet")
        return result

    with span() as result:
        with div(_class="row"):
            with column(4):
                with h4(_class=""):
                    text("Reviews for ")
                    a("{{ the_goal }}", href=goal_url)

        with django_with("the_goal|reviews_by:global_user as the_reviews"):
            list_of_reviews()
    return result
示例#9
0
    def format(trait, objs, *args, **kwargs) -> Htmlish:
        # TODO would be nice to have spinboard imported here for type checking..
        res = T.div(cls='pinboard')

        title = trait.title(objs)
        link = trait.link(objs)
        res.add(T.div(T.a(title, href=link)))

        with adhoc_html('pinboard', cb=lambda children: res.add(*children)):
            with T.table():
                for _, obj in objs:
                    if not isempty(obj.description):
                        with T.tr():
                            with T.td(colspan=3):
                                T.span(obj.description, cls='description')
                    with T.tr():
                        # TODO wtf is min??
                        with T.td(cls='min'):
                            T.a(f'{fdate(obj.when)}',
                                href=obj.blink,
                                cls='permalink timestamp')
                        with T.td(cls='min'):
                            text('by ')
                            trait.user_link(user=obj.user)
                        with T.td():
                            for t in obj.ntags:
                                trait.tag_link(tag=t, user=obj.user)
        # TODO userstats
        return res
示例#10
0
    def writeContent(self):
        self.writeln('<h1>Using Webware with Dominate</h1>')
        self.writeln(
            '<p>Dominate is a Python library that can be used in Webware'
            ' applications to generate HTML programmatically.</p>')
        if not dominate:
            self.writeln(
                f'<p>Please install <a href="{self.homepage}">Dominate</a>'
                ' in order to view this demo.</p>')
            return

        content = div(id='content')
        with content:
            h2('Hello World!')
            with table(cls="NiceTable").add(tbody()):
                tr(th('Demo table', colspan=3))
                r = tr()
                r += td('One')
                r.add(td('Two'))
                with r:
                    td('Three')
            para = p(__pretty=False)
            with para:
                text('This content has been produced with ')
                a('Dominate', href=self.homepage)
                text(' programmatically.')
        self.write(content)
示例#11
0
 def sources_summary(cls, items):
     # TODO FIXME need adhoc thing?
     key = lambda i: i.user
     for sub, cnt in cls.sources_stats(items, key=key):
         with T.div():
             cls.FTrait.user_link(sub)
             text(f': {cnt}')
示例#12
0
 def sources_summary(cls, items):
     # TODO eh. sort in reverse?
     key = lambda i: i.user
     for sub, cnt in cls.sources_stats(items, key=key):
         with T.div():
             cls.FTrait.user_link(sub)
             text(f': {cnt}')
示例#13
0
 def add_images(self, ims, txts, links, width=400):
     """add images to the HTML file
     Parameters:
         ims (str list)   -- a list of image paths
         txts (str list)  -- a list of image names shown on the website
         links (str list) --  a list of hyperref links; when you click an image, it will redirect you to a new page
     """
     self.t = table(border=1,
                    style="table-layout: fixed;")  # Insert a table
     self.doc.add(self.t)
     with self.t:
         with tr():
             for im, txt, link in zip(ims, txts, links):
                 with td(style="word-wrap: break-word;",
                         halign="center",
                         valign="top"):
                     with p():
                         with a(href=link):
                             img(style="width:%dpx" % width, src=im)
                         br()
                         #                            attrs_path = os.path.join(self.web_dir,'attributes', txt)
                         #                            with open(attrs_path, "r") as attr_log_file:
                         #                                attrs_str =attr_log_file.read()  # save the message
                         #                            attrs_str.replace('\n','<br>')
                         text(txt)
示例#14
0
 def sources_summary(cls, items):
     # TODO FIXME clearly looks it could be generic..
     key = lambda i: i.subreddit
     for sub, cnt in cls.sources_stats(items, key=key):
         with T.div():
             cls.FTrait.user_link(sub)
             text(f': {cnt}')
示例#15
0
def slide_title():
    h1('multiplayer 2D gaming')
    h2('with python-arcade')
    with p(style='font-size: 0.7em'):
        text('@caleb_hattingh ● ')
        # a('github.com/cjrh', href='github.com/cjrh')
        a('github.com/cjrh/pyconau2018-arcade2Dmultiplayer', href='github.com/cjrh/pyconau2018-arcade2Dmultiplayer')
示例#16
0
def failed(fixture_test_path, test_name, actual_hash, expected_hash):
    doc = dominate.document(title=test_name)
    recorded_path = fixture_test_path / "recorded"
    actual_path = fixture_test_path / "actual"

    download_failed = False

    if not recorded_path.exists():
        recorded_path.mkdir()
    try:
        download.fetch_recorded(expected_hash, recorded_path)
    except Exception:
        download_failed = True

    recorded_screens = sorted(recorded_path.iterdir())
    actual_screens = sorted(actual_path.iterdir())

    with doc:
        _header(test_name, expected_hash, actual_hash)

        if download_failed:
            with p():
                strong("WARNING:")
                text(" failed to download recorded fixtures. Is this a new test case?")

        with table(border=1, width=600):
            with tr():
                th("Expected")
                th("Actual")

            html.diff_table(recorded_screens, actual_screens)

    return html.write(REPORTS_PATH / "failed", doc, test_name + ".html")
示例#17
0
    def upload_form(self):
        with tags.form(
            id=self.config['upload_name'],
            onsubmit=self.config['onsubmit'],
            enctype='multipart/form-data',
            method=self.config['upload_method'],
            action=self.config['upload_route'],
            cls='card p-3 bg-light'):

            tags.h5('Upload an image', cls='card-title')

            with tags.div(cls='form-group row'):
                with tags.div(cls='col-12'):
                    # This requires JavaScript to show the filename.
                    # https://github.com/Johann-S/bs-custom-file-input
                    #
                    # 'style' is necessary to avoid overlapping in Safari and
                    # Chrome on iOS:
                    # https://github.com/twbs/bootstrap/issues/26933
                    with tags.div(cls='custom-file', style='overflow: hidden;'):
                        tags.input(
                            type='file', cls='custom-file-input p-1 rounded',
                            id=self.config['upload_name'], name=self.config['upload_name'])
                        tags.label(
                            'Choose file', fr=self.config['upload_name'],
                            cls='custom-file-label bg-light')

            with tags.div(cls='form-group row'):
                with tags.div(cls='col-3'):
                    with tags.button(type='submit', cls='btn btn-primary'):
                        util.text('Submit')
示例#18
0
def suggestion_description_div():
    column(2)
    with column(8):
        h5(
            "Published by {{ the_suggestion.owner.name }}, "
            "{{ the_suggestion.pub_date|naturaltime }}"
        )
        text("{{ the_revision.description|markdown }}")
示例#19
0
def comment_body():
    column(2)
    with column(8):
        with div(
            _class="comment--description",
            style="padding-left: {{ the_comment.indent }}px;"
        ):
            text("{{ the_comment.body }}")
示例#20
0
def create_homepage(entries):
    print("Updating homepage.")

    pagegroups = [entries[i:i+12] for i in range(0, len(entries), 12)]

    pagegroup_count = len(pagegroups)

    pagenum = 1 

    for group in pagegroups:
        h = create_numbered_page(entries)
        l = h.body[1].add(ul(id="results-list"))
        for entry in group:
            post_link = urllib.parse.urljoin(
                "posts/", entry['slug'])
            if pagenum != 1:
                post_link = "../" + post_link
            tile = l.add(li(h2(a(entry['name'], href=post_link))))
            obit_link = a(
                entry['headline'], href=entry['obit_url'])

            with tile:
                if entry['short_desc']:
                    text(entry['short_desc'], escape = False)
                p(a("Read more »", href=post_link))
                p("New York Times obit: ",
                    __pretty = False).add(obit_link)

        nav = h.body[1].add(div(id="page-nav"))

        pagination = nav.add(ul(id="pagination"))

        page_links = [home]
        page_links.extend([urllib.parse.urljoin(home, str(page)) for page in range(2, pagegroup_count + 1)])

        pagination.add(li(a("«", href=home)))
        
        for index in range(len(page_links)):
            number = index + 1
            page = pagination.add(li(a(number, href=page_links[index])))
            if number == pagenum:
                with page:
                    attr(cls="current-page")

        pagination.add(li(a("»", href=page_links[-1])))

        firstpage = True if pagenum == 1 else False
       
        if firstpage:
            filename = "site/index.html"
        else:
            os.makedirs("site/{}".format(pagenum), exist_ok=True)
            filename = "site/{}/index.html".format(pagenum)

        with open(filename, "w") as f:
            f.write(h.render())    

        pagenum += 1
示例#21
0
def result():
    with span() as content:
        with a(
                _class="sg-notification sg-notification-read-{{ is_read }}",
                href="{{ target_url }}",
        ):
            text("{{ comment.owner.name }} {{ did_what }}")

    return (content, )
示例#22
0
 def noscript(self):
     with tags.noscript():
         with tags.div(cls='container'):
             with tags.div(cls='row mt-3 justify-content-center'):
                 with tags.div(cls='col-md-8 col-lg-6'):
                     with tags.div(
                              cls='alert alert-warning text-center',
                              role='alert'):
                         util.text('Enable JavaScript for better experience')
示例#23
0
def result():
    with span() as content:
        with a(
                _class="sg-notification sg-notification-read-{{ is_read }}",
                href="{{ target_url }}",
        ):
            text("{{ review.owner.name }} reviewed your suggestion "
                 "{{ suggestion.get_current_revision.title }}")

    return (content, )
示例#24
0
def slide_run_examples():
    h2('lots of examples')
    exnames = ['bouncing_ball', 'sprite_collect_coins',
               'sprite_move_keyboard']
    with ul():
        for example in exnames:
            cmd = f'arcade.examples.{example}'
            with code_bullet(btn_text=example, cmd=cmd):
                text('(venv) $ python -m arcade.examples.')
                mark(example)
示例#25
0
def player_inputs():
    h2('1. Player input state')
    p('send client 🠊 server')
    with ul():
        with li():
            b('inputs ')
            text('not "speed" or "position"')
        li('Use dataclasses:')

    code_block('player_event.py', highlights=['class PlayerEvent'])
示例#26
0
def client_code1():
    h2('Client code needs TWO loops!')
    with ul():
        li('python-arcade: game loop')
        li('asyncio: IO loop')
        with li():
            b('Cannot ')
            text('run both loops in same thread')

    p('Least-effort solution: run asyncio loop in a thread')
示例#27
0
 def image(self, src, alt):
     with tags.figure(cls='figure'):
         tags.img(cls='figure-img img-fluid rounded', src=src, alt=alt)
         with tags.figcaption(
                 cls='figure-caption',
                 # Requires browser-specific hyphens to work in different browsers.
                 style=('-webkit-hyphens: auto; '
                        '-moz-hyphens: auto; '
                        '-ms-hyphens: auto; '
                        'hyphens: auto;')):
             util.text(alt)
示例#28
0
def slide_why_arcade():
    h2('Why Python-Arcade?')
    with ul():
        li('Easy to install')
        li('OpenGL (via Pyglet)')
        li('Modern (Python 3 only, type annotations)')
        with li():
            code('(0, 0)')
            text(' is at the bottom-left')
        li('Very clean, simple API')
        with li(cls='fragment'):
            strong('Examples 🎁🎁🎁')
示例#29
0
def create_mainpage_html(local, url_list, path, web_title):
    _html = dmtags.html(style="background-color:#fcfbeb;")
    _head, _body = _html.add(dmtags.head(dmtags.title(web_title)),
                             dmtags.body(cls="main_page"))
    with _head:
        dmtags.comment("The page is genarated on {} by Ein".format(
            time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())))
        dmtags.meta(charset="utf-8",
                    name="viewport",
                    content="width=device-width, initial-scale=1")
        dmtags.link(
            href="https://fonts.googleapis.com/css?family=Noto+Sans+JP:500",
            rel="stylesheet")
        dmtags.link(
            href=
            "https://cdnjs.cloudflare.com/ajax/libs/milligram/1.3.0/milligram.min.css",
            rel="stylesheet")
        dmtags.link(href="https://rawcdn.githack.com/c892836a/python_for_fun/"
                    "b2fa53022b0ae5a26d6f140c38b860a210c21040/css/custom.css",
                    rel="stylesheet")
        dmtags.link(
            href="https://lh3.googleusercontent.com/S__tM5EYqZDFLuv1uPG" +
            "mlZTTLLyNAbUvljzDH8-S0Pxq2nA9fnFF3SwU0w0wF8PlMu_hv3WhLMdlFodKbQ=s0",
            rel="shortcut icon",
            type="image/vnd.microsoft.icon")
    main_div = _body.add(
        dmtags.div(
            style=
            "text-align:center; font-family: 'Noto Sans JP', sans-serif; font-size:36px;"
        ))

    with main_div:
        _p1 = dmtags.p(style="color:#470000;")
        for url in url_list:
            _p2 = dmtags.p(style="font-size:20px;")
            with _p2:
                dmtags.a(url[0], href="{}".format(url[1]))
        with _p1:
            text("{}".format(web_title))

    # create html file
    if local:
        os.chdir(path)
        os.chdir(os.pardir)
        with open("{}.html".format(web_title), "w", encoding='utf8') as f:
            f.write("<!DOCTYPE html>\n")
            f.write(_html.render())

    else:
        with open("{}\\{}.html".format(path, web_title), "w",
                  encoding='utf8') as f:
            f.write("<!DOCTYPE html>\n")
            f.write(_html.render())
示例#30
0
def top_right_div():
    with django_if("user.is_authenticated"):

        with django_if("request.member"):
            suggestion_buttons()

        with django_if("request.global_user"):
            goal_buttons()

        top_right_menu()
        with django_else():
            with a(href="{% url 'auth_login' %}"):
                text("{% trans 'Log in' %}")
示例#31
0
    def _delimited_text(self):
        assert isinstance(self._value, list)
        if not self._value:
            return

        values = iter(self._value)
        with td(colspan=1, class_name='value') as column:
            text(next(values))
            for value in values:
                span('/', class_name='delimeter')
                text(value)

        return column
def result():
    with span() as content:
        with a(
            _class="sg-notification sg-notification-read-{{ is_read }}",
            href="{{ target_url }}",
        ):
            text(
                "{{ comment.owner.name }} {{ did_what }}"
            )

    return (
        content,
    )
示例#33
0
def suggestion_buttons():
    url_update_suggestion = (
        "location.href='{% url 'update-suggestion' request.goal.slug "
        "suggestion.slug %}';")
    url_new_suggestion = \
        "location.href='{% url 'new-suggestion' request.goal.slug %}';"

    with django_if("suggestion and suggestion.owner == request.global_user"):
        with button(_class="btn btn-info", onclick=url_update_suggestion):
            text("Edit Suggestion")

    with button(_class="btn btn-success", onclick=url_new_suggestion):
        text("New Suggestion")
示例#34
0
def top_right_div():
    with django_if("user.is_authenticated"):

        with django_if("request.member"):
            suggestion_buttons()

        with django_if("request.global_user"):
            goal_buttons()

        top_right_menu()
        with django_else():
            with a(href="{% url 'auth_login' %}"):
                text("{% trans 'Log in' %}")
示例#35
0
def test_text():
    from dominate.util import text
    d = div()
    with d:
        text('Hello World')

    assert d.render() == \
        """<div>Hello World</div>"""

    assert div(text('<>', escape=False)).render() == \
        """<div><></div>"""

    assert div(text('<>')).render() == \
        """<div>&lt;&gt;</div>"""
示例#36
0
def test_text():
  from dominate.util import text
  d = div()
  with d:
    text('Hello World')

  assert d.render() == \
    '''<div>Hello World</div>'''

  assert div(text('<>', escape=False)).render() == \
    '''<div><></div>'''

  assert div(text('<>')).render() == \
    '''<div>&lt;&gt;</div>'''
示例#37
0
def goal_buttons():
    url_new_goal = \
        "location.href='{% url 'new-goal' %}';"

    url_join_goal = \
        "location.href='{% url 'join-goal' request.goal.slug %}';"

    with django_if("not request.goal"):
        with button(_class="btn btn-success", onclick=url_new_goal):
            text("New Goal")

    with django_if("request.goal and not request.member"):
        with button(_class="btn btn-success", onclick=url_join_goal):
            text("Join Goal")
def result():
    with span() as content:
        with a(
            _class="sg-notification sg-notification-read-{{ is_read }}",
            href="{{ target_url }}",
        ):
            text(
                "{{ review.owner.name }} reviewed your suggestion "
                "{{ suggestion.get_current_revision.title }}"
            )

    return (
        content,
    )
示例#39
0
def goal_buttons():
    url_new_goal = \
        "location.href='{% url 'new-goal' %}';"

    url_join_goal = \
        "location.href='{% url 'join-goal' request.goal.slug %}';"

    with django_if("not request.goal"):
        with button(_class="btn btn-success", onclick=url_new_goal):
            text("New Goal")

    with django_if("request.goal and not request.member"):
        with button(_class="btn btn-success", onclick=url_join_goal):
            text("Join Goal")
示例#40
0
def goal_header():
    with div(_class="text-center"):
        h1("{{ request.goal.title }}")
        with div(_class="button-grp"):
            button(
                "Suggestions", _class="btn btn-default", onclick="location.href='{% url 'goal' request.goal.slug %}';"
            )
            button(
                "Members", _class="btn btn-default", onclick="location.href='{% url 'members' request.goal.slug %}';"
            )
            with django_if("request.global_user"):
                with button(_class="btn btn-default", onclick=("location.href='{{ profile_url }}';")):
                    text("Profile")
                    with django_with("request.global_user.notifications|unread " "as unread_notifications"):
                        with django_if("unread_notifications.count"):
                            text(" ({{ unread_notifications.count }})")
示例#41
0
def suggestion_buttons():
    url_update_suggestion = (
        "location.href='{% url 'update-suggestion' request.goal.slug "
        "suggestion.slug %}';"
    )
    url_new_suggestion = \
        "location.href='{% url 'new-suggestion' request.goal.slug %}';"

    with django_if(
        "suggestion and suggestion.owner == request.global_user"
    ):
        with button(_class="btn btn-info", onclick=url_update_suggestion):
            text("Edit Suggestion")

    with button(_class="btn btn-success", onclick=url_new_suggestion):
        text("New Suggestion")
示例#42
0
def result():
    with django_block("head") as head:
        text("{{ form.media }}")

    with django_block("content") as content:
        with div(_class="row"):
            column(2)
            with column(8):
                goal_form()

        text("{% init_django_jcrop %}")

    return (
        "{% extends 'base.html' %}",
        "{% load django_jcrop_tags %}",
        head,
        content,
    )
示例#43
0
def top_left_div():
    with a(href="{% url 'home' %}"):
        text("Shared Goals")

    with a(href="{% url 'about' %}"):
        text("| About")

    with a(href="{% url 'tos' %}"):
        text("| Terms")

    with a(href="{% url 'feedback' %}"):
        text("| Give feedback")
def result():
    with django_block("content") as content:
        goal_header()

        with div(_class="row"):
            column(2)
            with column(8):
                suggestion_form()

        text("{% init_django_jcrop %}")
        inline_script(settings.BASE_DIR, "suggestion/init_suggestion_form.js")

    return (
        "{% extends 'base.html' %}",
        "{% load notification_tags %}",
        "{% load shared_goals_tags %}",
        "{% load django_jcrop_tags %}",
        content,
    )
示例#45
0
def comment_form():
    django_csrf_token()

    with p():
        text("{{ comment_form.body.errors }}")
        with label(
            _for="{{ comment_form.body.id_for_label }}",
            _class="form-label"
        ):
            text("{{ reply_header }}")
        with textarea(
            name="body",
            _class="form-field"
        ):
            text("{{ comment_form.body.value }}")

    with div():
        button(
            "Submit",
            name="submit",
            value="save"
        )
        button(
            "Save draft",
            name="submit",
            value="cancel"
        )
示例#46
0
def result():
    with django_block("content") as content:
        goal_header()

        with django_with("suggestion as the_suggestion"):
            with django_with("revision as the_revision"):
                with div(_class="row small-gap-below"):
                    column(4)
                    with column(4):
                        suggestion_image()

                with div(_class="row small-gap-below"):
                    column(2)
                    with column(8):
                        with p():
                            text("This is a previous version of a ")
                            a("suggestion", href=suggestion_url)
                            text(" by {{ the_suggestion.owner.name }}")
                        text("{{ the_revision.description|markdown }}")

    return (
        "{% extends 'base.html' %}\n",
        "{% load humanize %}",
        "{% load markdown_deux_tags %}",
        "{% load notification_tags %}",
        content,
    )
示例#47
0
def published_review_header():
    revision_href = (
        "{% url 'revision' request.goal.slug "
        "the_review.revision.suggestion.slug the_review.revision.pk %}"
    )

    column(2)
    with column(2):
        readonly_rateit("{{ the_review.rating }}")

    with column(6):
        with django_if("the_review.description"):
            text("Review ")
            with django_else():
                text("Rating ")

        with django_if(
            "the_review.revision.pk != latest_revision.pk"
        ):
            text("of a ")
            with a(href=revision_href):
                text("previous version ")

        text("by {{ the_review.header }}")
示例#48
0
def comment_header():
    column(2)
    with column(8):
        with div(
            id="sg-comment-{{ the_comment.pk }}",
            style="text-indent: {{ the_comment.indent }}px;"
        ):
            text("{{ the_comment.owner.name }}")
            with django_if("the_comment.reply_to"):
                text("(=> {{ the_comment.reply_to.owner.name }})")

            text(", {{ the_comment.pub_date|naturaltime }}")
示例#49
0
def top_right_menu():
    with a(
        _class="btn dropdown-toggle",
        data_toggle="dropdown",
        href="#"
    ):
        text("{{ user.first_name }}")

    span(_class="caret")
    with ul(_class="dropdown-menu"):
        with li():
            with a(href="{% url 'auth_logout' %}"):
                text("{% trans 'Log out' %}")
            with a(href="{% url 'auth_password_change' %}"):
                text("{% trans 'Change password' %}")
示例#50
0
def goal_form():
    django_csrf_token()

    with p():
        with django_if("show_errors"):
            text("{{ form.title.errors }}")
        with label(
            _for="{{ form.title.id_for_label }}",
            _class="form-label"
        ):
            text("Title")
        input_(
            id="id_title",
            type="text",
            name="title",
            maxlength="100",
            value="{{ form.title.value }}",
            _class="form-field"
        )

    with django_if("show_image_form"):
        with div(_class="goal-form--image"):
            text("{{ crop_settings|django_jcrop_widget }}")

            with p():
                with django_if("show_errors"):
                    text("{{ form.image.errors }}")
                with label(
                    _for="{{ form.image.id_for_label }}",
                    _class="form-label"
                ):
                    text(
                        "Upload an image to illustrate your goal")
                text("{{ form.image }}")
                button(
                    "Upload",
                    id="upload-submit",
                    name="submit",
                    value="upload"
                )

    with div():
        with div(_class="small-gap-above small-gap-below"):
            with label(
                _class="form-label"
            ):
                text("{{ submit_button_header }}")
            button(
                "{{ post_button_label }}",
                name="submit",
                value="save"
            )
            button(
                "Cancel",
                name="submit",
                value="cancel"
            )
示例#51
0
def review_comments_notice():
    text("Note: updating your review will remove ")
    with a(href="#comments-on-my-review"):
        text("{{ review.published_comments|length }} related comments")
def suggestion_form():
    django_csrf_token()

    with p():
        with django_if("show_errors"):
            text("{{ form.type.errors }}")
        with label(
            _for="{{ form.type.id_for_label }}",
            _class="form-label"
        ):
            text(
                "Will you suggest a one-time Action, "
                "or a continuous Practice?"
            )
        text("{{ form.type }}")

    with p():
        with django_if("show_errors"):
            text("{{ form.title.errors }}")
        with label(
            _for="{{ form.title.id_for_label }}",
            _class="form-label"
        ):
            text("Title")
        input_(
            id="id_title",
            type="text",
            name="title",
            maxlength="100",
            value="{{ form.title.value }}",
            _class="form-field"
        )

    url_markdown = 'http://commonmark.org/help/'
    with p():
        with django_if("show_errors"):
            text("{{ form.description.errors }}")
        with label(
            _for="{{ form.description.id_for_label }}",
            _class="form-label"
        ):
            text("Describe your suggestion")

            with label(
                _class="form-label pull-right"
            ):
                input(type="checkbox", id="chkPreview")
                span("Preview")

                with span(style="font-size: 10px;"):
                    with a(href=url_markdown):
                        text("Markdown")
                    text(" allowed")

        with textarea(
            id="description",
            name="description",
            rows="16",
            _class="form-field"
        ):
            text("{{ form.description.value }}")

        div(
            id="descriptionPreview",
            _class="tiny-gap-above small-gap-below",
            data_ajax_url=(
                "{% url 'preview-suggestion' request.goal.slug %}"
            )
        )

    with django_if("show_image_form"):
        text("{{ crop_settings|django_jcrop_widget }}")

        with div(_class="suggestion-form--image"):
            with p():
                with django_if("show_errors"):
                    text("{{ form.image.errors }}")
                with label(
                    _for="{{ form.image.id_for_label }}",
                    _class="form-label"
                ):
                    text(
                        "Make your suggestion look good by uploading an image")
                text("{{ form.image }}")
                button(
                    "Upload",
                    # todo reenable automatic upload
                    # _class="hidden",
                    id="upload-submit",
                    name="submit",
                    value="upload"
                )

    with div():
        with div(_class="small-gap-above small-gap-below"):
            with label(
                _class="form-label"
            ):
                text("{{ submit_button_header }}")
            button(
                "{{ post_button_label }}",
                name="submit",
                value="save"
            )
            button(
                "Cancel",
                name="submit",
                value="cancel"
            )

        with django_if("show_delete_button"):
            button(
                "Delete this suggestion",
                name="submit",
                value="delete",
                _class="btn btn-danger suggestion--delete-button"
            )
示例#53
0
def published_review_description():
    column(2)
    with column(8):
        with div(_class="review--description"):
            text("{{ the_review.description }}")
示例#54
0
def review_form():
    django_csrf_token()
    with p():
        with label(
            _for="{{ form.rating.id_for_label }}",
            _class="form-label"
        ):
            text("{{ post_button_header }}")
        text("{{ form.rating.errors }}")
        input_(
            id="id_rating",
            type="hidden",
            name="rating",
            value="{{ form.rating.value }}",
            _class="form-field"
        )
        div(
            id="rateit-review",
            _class="rateit",
            data_rateit_resetable="false",
            data_rateit_value="{{ form.rating.value }}"
        )

    with p():
        text("{{ form.experience.errors }}")
        with label(
            _for="{{ form.experience.id_for_label }}",
            _class="form-label"
        ):
            text(
                "Do you have any experience with the suggested "
                "{{ latest_revision.suggestion.get_type_display }}?"
            )
        text("{{ form.experience }}")

    with p():
        text("{{ form.description.errors }}")
        with textarea(
            name="description",
            rows="10",
            _class="form-field"
        ):
            text("{{ form.description.value }}")

    with div():
        button(
            "{{ post_button_label }}",
            name="submit",
            value="save"
        )
        button(
            "Cancel",
            name="submit",
            value="cancel"
        )
示例#55
0
 def header():
     with div(_class="row") as result:
         with column(4):
             with h4(_class=""):
                 text("Notifications:")
     return result