{"id":19188974,"url":"https://github.com/openprocurement/web-renderer","last_synced_at":"2025-05-08T03:13:35.507Z","repository":{"id":142882715,"uuid":"278284642","full_name":"openprocurement/web-renderer","owner":"openprocurement","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-02T14:16:24.000Z","size":747,"stargazers_count":1,"open_issues_count":0,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-08T03:13:30.617Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openprocurement.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-09T06:42:39.000Z","updated_at":"2021-10-07T16:20:55.000Z","dependencies_parsed_at":"2023-05-06T00:34:03.591Z","dependency_job_id":null,"html_url":"https://github.com/openprocurement/web-renderer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openprocurement%2Fweb-renderer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openprocurement%2Fweb-renderer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openprocurement%2Fweb-renderer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openprocurement%2Fweb-renderer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openprocurement","download_url":"https://codeload.github.com/openprocurement/web-renderer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252990003,"owners_count":21836668,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T11:27:03.218Z","updated_at":"2025-05-08T03:13:35.502Z","avatar_url":"https://github.com/openprocurement.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# web-renderer\n\n### Debug mode\n```\nexport DEBUG=true\n```\n### Requests:\n\n```\npaths:\n    /:\n    post:\n        summary: Render a document.\n        requestBody:\n            json_data:\n                description: json data\n                content: application/json:\n            template:\n                description: template .docx file\n                content: application/msword\n            include_attachments:\n                description: include attachment files\n                content: True \n            document_names:\n                description: output document names without extensions\n                content: application/json\n                fields: {\n                    \"contractProforma\": \"contractProformaFileName\",\n                    \"contractData\"    : \"contractDataFileName\",\n                    \"contractTemplate\": \"contractTemplateFileName\"\n                }\n        responses:\n        '200':\n            file: \n                description: Generated file\n                content: application/pdf\n    post:\n        summary: Get template JSON schema.\n        requestBody:\n            json_data:\n                description: json data\n                content: application/json:\n            template:\n                description: template .docx file\n                content: application/msword\n            get_template_json_schema:\n                content: True \n            hide_empty_fields:\n                description: hide empty fields of the schema\n                content: True or False\n        responses:\n        '200':\n            data: \n                description: generated JSON schema of the document\n                content: application/json\n    # Additional requests:\n    post:\n        summary: Get template JSON tag schema.\n        requestBody:\n            json_data:\n                description: json data\n                content: application/json:\n            template:\n                description: template .docx file\n                content: application/msword\n            get_template_tag_schema:\n                content: True \n        responses:\n        '200':\n            data: \n                description: generated JSON tag schema of the document\n                content: application/json\n    post:\n        summary: display html form from the document\n        requestBody:\n            json_data:\n                description: json data\n                content: application/json:\n            template:\n                description: template .docx file\n                content: application/msword\n            display_template_form:\n                content: True \n        responses:\n        '200':\n            data: \n                description: generated HTML document\n                content: text/html\n```\n\n### Renderer features:\n\n- #### Pictures replacement:\n\n    Renderer have some limitations such as can't add picture to header or footer using `InlineImage`, for resolve this problem, renderer has reserved keyword in context `replace_pics` its array of objects which contains two attributes:\n\n    - `current_name` - name of dummy picture already placed in template.\n    - `url` - link for picture which will replace dummy picture.\n\n    example:\n    ```python\n    \u003e\u003e\u003e context = {\n    ...     'title': 'My company',\n    ...     'phone': '+15552345712',\n    ...     'replace_pics': [\n    ...         {'current_name': 'dummy_logo.png', 'url': '\u003clink to your logo\u003e'}\n    ...     ]\n    ... }\n    ```\n\n    **Note**: the aspect ratio will be the same as the replaced image\n\n### Jinja template functions:\n\n- ##### `{{ iso_str_date | format_date}}`  \n   The function for formating an ISO date to the string one. \n    - **input:** date (ISO): 2019-08-22T13:35:00+03:00 \n    - **output:** date (str): \"22\" серпня 2019 року \n- ##### `{{ str_float_number | to_float}}`\n    The function for formatting comma float string to float. \n    - **input:** \"12\\xa0588\\xa0575.00\" \n    - **output:** 12588575.0 \n- ##### `{{ str_float_number | convert_amount_to_words}}`\n    The function for formatting an amount of money to the word string.\n    - **input:** \"12\\xa0588\\xa0575.00\" \n    - **output:** \"триста двадцять двi тисячi шiстсот шiстдесят дев'ять гривень 00 копійок\"\n- ##### `{{ items_list | common_classification }}`\n    The function for formatting common classification of all items in format \"ДК021 32100000-1, Текстовий опис класифікатора\"\n    - **input:** \"Список айтемів контракту\"\n    - **output:** \"Текстове значення класифікатора у форматі: 'ДК021 32100000-1, Текстовий опис класифікатора'\"\n- ##### `{{ items_list | common_classification_code}}`\n    The function for formatting common classification of all items in format \"ДК021 32100000-1\n    - **input:** \"Список айтемів контракту\"\n    - **output:** \"Текстове значення класифікатора у форматі: 'ДК021 32100000-1'\"\n- ##### `{{ items_list | common_classification_description}}`\n    The function for getting common classification description of all items\n    - **input:** \"Список айтемів контракту\"\n    - **output:** \"Текстовий опис спільного для всіх айтемів класифікатора\"\n- ##### `{{ classification_data | classification}}`\n    The function for getting classification description\n    - **input:** \"об'єкт класифікатора\"\n    - **output:** \"Текстовий опис класифікатора згідно словника\"\n- ##### `{{ data | json_query ('search_string')}}`\n    The function for searching a string using JMESPATH format in data JSON.\n    - **input:**:\n      - data: JSON data, e.g: contract.supplier\n      - search_string, e.g: 'id'\n    - **output:** \n      - search result\n- ##### `{{ data | default ('default')}}`\n    If data is empty return default\n- ##### `{{ unit_code | unit_shortcut}}`\n    The function for getting the shortcut of measurement units\n    - **input:** \"MLT\"\n    - **output:** \"мл.\"  \n- ##### `{{ Image | InlineImage(width=50, height=50, unit=’mm’)}}`\n    The function for getting image by download url\n    Units: Inches, Cm, Mm, Pt, Emu\n    - **input:** \"Image url\"\n    - **output:** \"InlineImage\"\n\n### Run tests\n\n```bash\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\npytest --cov\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenprocurement%2Fweb-renderer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenprocurement%2Fweb-renderer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenprocurement%2Fweb-renderer/lists"}