Esempio n. 1
0
 def html_dropdown_add(self, cnt, above=True):
     difference = 0 if above else 1
     html_string = html.div(
         className="dropdown",
         children=[
             html.button(
                 className="btn btn-secondary dropdown-toggle btn-sm",
                 type="button",
                 data_toggle="dropdown",
                 aria_haspopup="true",
                 aria_expanded="false",
                 style="margin-right:10px",
                 children="Add " + ("above" if above else "below"),
             ),
             html.div(
                 className="dropdown-menu",
                 children=[
                     html.a(
                         children=[possibility],
                         className="dropdown-item",
                         href=url_for(
                             "blueprint.add_element",
                             type=possibility,
                             position=cnt + 1,
                         ),
                     ) for possibility in self.possible_adds.keys()
                 ],
             ),
         ],
     )
     return html_string
Esempio n. 2
0
def dict_to_html(dictionary, action):
    html_string = html.form(
        method="POST",
        action=action,
        children=[
            html.div(
                className="form-group row",
                children=[
                    html.div(className="col-sm-1"),
                    html.label(className="col-sm-2 col-form-label",
                               children=[key]),
                    html.div(
                        className="col-sm-6",
                        children=generate_html_input(key, value),
                    ),
                ],
            ) for key, value in dictionary.items()
        ] + [
            html.div(
                className=" d-flex flex-row-reverse",
                style="justify-content-right; margin-top:10px;",
                children=[
                    html.button(type="submit",
                                className="btn btn-secondary",
                                children="Save"),
                ],
            )
        ],
    )
    return html_string
Esempio n. 3
0
def index():
    if request.form:
        print("AM I EVER HERE?")
        raise ValueError("IM AM HERE")
        document.from_dict(dict(request.form))
    body = page.to_html()

    body += html.div(
        className=" d-flex flex-row-reverse",
        style="justify-content-right; margin-top:10px;",
        children=[
            html.div(
                className="dropdown show",
                children=[
                    html.a(
                        className="btn btn-secondary dropdown-toggle",
                        href="#",
                        children="Download",
                        data_toggle="dropdown",
                        aria_haspopup="true",
                        aria_expanded="false",
                    ),
                    html.div(
                        className="dropdown-menu",
                        children=[
                            html.a(
                                className="dropdown-item",
                                href=url_for("blueprint.download", type="pdf"),
                                children="pdf",
                            ),
                            html.a(
                                className="dropdown-item",
                                href=url_for("blueprint.download",
                                             type="json"),
                                children="json",
                            ),
                            html.a(
                                className="dropdown-item",
                                href=url_for("blueprint.download", type="tex"),
                                children="tex",
                            ),
                        ],
                    ),
                ],
            ),
            html.a(
                className="btn btn-secondary",
                style="margin-right:10px;",
                children="Upload",
                href=url_for("blueprint.upload"),
            ),
        ],
    ).__str__()

    lat = (page.to_latex().replace("\n",
                                   "<br>").replace("\t",
                                                   "&nbsp;&nbsp;&nbsp;&nbsp;"))
    return render_template("main.html", body=body, latex=lat)
Esempio n. 4
0
 def submit(self):
     return html.div(
         className=" d-flex flex-row-reverse",
         style="justify-content-right; margin-top:10px;",
         children=[
             html.button(type="submit",
                         className="btn btn-secondary",
                         children="Save")
         ],
     )
Esempio n. 5
0
 def to_html(self, name):
     return html.div(
         className="form-row",
         children=[
             html.div(className="col-sm-1"),
             html.div(
                 className="col-sm-10",
                 children=[
                     html.input(
                         type="text",
                         placeholder="title",
                         value=self.title if self.title is not None else "",
                         name=name + "-title",
                         className="form-control",
                     ),
                 ],
             ),
         ],
     )
Esempio n. 6
0
    def to_html(self):
        html_string = ""
        for name, obj in zip(
            [
                "DocumentClass", "Packages", "Config", "PersonalSettings",
                "Document"
            ],
            [
                self.documentclass,
                self.packages,
                self.config,
                self.personalsettings,
                self.document,
            ],
        ):
            htmlObj = html.div(
                className="card",
                style="margin-bottom:10px;",
                children=[
                    html.div(
                        className="card-header",
                        children=[
                            html.a(
                                className="card-link CollapseHeader",
                                data_toggle="collapse",
                                aria_controls=name,
                                href=f"#{name}",
                                children=name,
                            )
                        ],
                    ),
                    html.div(
                        className="collapse",
                        aria_expanded="false",
                        id=name,
                        children=[obj.to_html()],
                    ),
                ],
            )
            html_string += htmlObj.__str__()

        return html_string
Esempio n. 7
0
 def add_control_row(self, cnt):
     return html.div(
         className=" d-flex flex-row-reverse",
         style="justify-content-right; margin-top:10px;",
         children=[
             self.html_move_content(name="up", start=cnt, dest=cnt - 1),
             self.html_move_content(name="down", start=cnt, dest=cnt + 1),
             self.html_dropdown_add(cnt, above=True),
             self.html_dropdown_add(cnt, above=False),
         ],
     )
Esempio n. 8
0
 def block_title(self, type):
     return html.div(
         style=
         "width: 100%; height: 20px; border-bottom: 1px solid black;text-align: left; margin-bottom:10px;",
         children=[
             html.span(
                 style=
                 "padding:2px 10px;background-color:gray;margin-left:20px",
                 children=[html.strong(type)],
             )
         ],
     )
Esempio n. 9
0
 def test_div(self):
     div = html.div("hello")
     assert str(div) == '<div style="" class="" >\n\thello\n</div>'
Esempio n. 10
0
 def to_html(self, name):
     html_string = [
         html.div(
             className="col",
             children=[
                 html.input(
                     type="text",
                     value=value if value is not None else key,
                     name=str(name) + "-" + str(key),
                 )
             ],
         ) for key, value in self.to_dict().items()
     ]
     html_string = html.div(
         className="form-row",
         # style="margin-right:200px;",
         children=[
             html.div(className="col-sm-1"),
             html.div(
                 className="col-sm-2",
                 children=[
                     html.input(
                         type="text",
                         placeholder="year",
                         value=self.year if self.year is not None else "",
                         name=name + "-year",
                         className="form-control",
                     ),
                 ],
             ),
             html.div(
                 className="col-sm-2",
                 children=[
                     html.input(
                         type="text",
                         placeholder="job_title",
                         value=self.job_title
                         if self.job_title is not None else "",
                         name=name + "-job_title",
                         className="form-control",
                     ),
                 ],
             ),
             html.div(
                 className="col-sm-2",
                 children=[
                     html.input(
                         type="text",
                         placeholder="institution",
                         value=self.institution
                         if self.institution is not None else "",
                         name=name + "-institution",
                         className="form-control",
                     ),
                 ],
             ),
             html.div(
                 className="col-sm-2",
                 children=[
                     html.input(
                         type="text",
                         placeholder="city",
                         value=self.city if self.city is not None else "",
                         name=name + "-city",
                         className="form-control",
                     ),
                 ],
             ),
             html.div(
                 className="col-sm-2",
                 children=[
                     html.input(
                         type="text",
                         placeholder="grade",
                         value=self.grade if self.grade is not None else "",
                         name=name + "-grade",
                         className="form-control",
                     ),
                 ],
             ),
         ],
     ).__str__()
     html_string += html.div(
         className="form-row",
         style="margin-top:20px;",
         # style="margin-right:200px;",
         children=[
             html.div(className="col-sm-1"),
             html.div(
                 className="col-sm-10",
                 children=[
                     html.textarea(
                         type="text",
                         placeholder="description",
                         value=self.description
                         if self.description is not None else "",
                         name=name + "-description",
                         className="form-control",
                         children=[
                             self.description
                             if self.description not in [None, [""]] else ""
                         ],
                     ),
                 ],
             ),
         ],
     ).__str__()
     return html_string
Esempio n. 11
0
    def to_html(self, name):
        html_string = ""
        # nCols
        children = [
            html.div(className="col-sm-1"),
            html.label(className="col-sm-1", children="nCols"),
            html.div(
                className="col-sm-1",
                children=[
                    html.input(
                        type="text",
                        value=self.nCols,
                        name=name + "-nCols",
                        className="form-control",
                    ),
                ],
            ),
        ]
        html_string += html.div(className="row", children=children).__str__()

        length = len(self.children)
        row_step = math.ceil(length / self.nCols)

        for row in range(row_step):
            child = [html.div(className="col-sm-1")]
            for col in range(self.nCols):
                coln = row + col * row_step
                if coln >= length:
                    break
                child += [
                    html.div(
                        className="col-sm-2",
                        children=[
                            html.input(
                                type="text",
                                value=self.children[coln],
                                name=name + "-" + str(coln),
                                className="form-control",
                            ),
                        ],
                    )
                ]

            html_string += html.div(className="form-row",
                                    style="margin-top:10px;",
                                    children=child).__str__()
        # Add button for adding of fields
        html_string += html.div(
            className="row",
            style="margin-top:10px;",
            children=[
                html.div(className=f"col-sm-{2*self.nCols}"),
                html.div(
                    className="col-sm-4",
                    children=[
                        html.a(
                            className="btn btn-secondary",
                            type="button",
                            children="Add field",
                            style="margin-right:10px;",
                            href=url_for("blueprint.add_multi_elem",
                                         document_element=name
                                         ),  # f"/add_multicolumn/{name}",
                        ),
                    ],
                ),
            ],
        ).__str__()
        return html_string