From 50f958ece908e9cb4ee534f7776687f5be09a2da Mon Sep 17 00:00:00 2001 From: Charles Whittington Date: Thu, 12 Jun 2025 21:37:33 -0400 Subject: [PATCH 1/8] Fixed tag issues and tweaked some indendation --- content/contents.lr | 54 ++++++++++++++----------------- flowblocks/text-block.ini | 3 +- templates/blocks/text-block.html | 3 +- templates/home.html | 4 +-- templates/layout.html | 44 ++++++++++++------------- templates/macros/breadcrumbs.html | 2 +- 6 files changed, 53 insertions(+), 57 deletions(-) diff --git a/content/contents.lr b/content/contents.lr index 0eb3a6c426f..d440d93e491 100644 --- a/content/contents.lr +++ b/content/contents.lr @@ -56,81 +56,82 @@ is_block: body: #### text-block #### -title: ### One codebase. Multiple apps. +title: One codebase. Multiple apps. ---- text: BeeWare allows you to write your app in Python and release it on multiple platforms. No need to rewrite the app in multiple programming languages. It means **no issues** with build tools, environments, compatibility, etc. ----- -image: ----- -image_alignment: right + #### text-block #### -title: ### Python native tools... +title: Python native tools... ---- text: Python has proven itself as a highly capable language - approachable for newcomers, but powerful in the hands of experts. Why shouldn't you be able to **use Python everywhere** that you need to tell a computer to do something? And shouldn't your tools **exploit all the capabilities of Python** as a language, not just the bits that map nicely to a C binding? ---- image: python.png ---- image_alignment: right + #### text-block #### -title: ### ...on mobile & desktop... +title: ...on mobile & desktop... ---- text: Modern computing doesn't happen in an 80x25 console window. It happens on **phones, tablets, and desktop machines** with rich user interfaces. Shouldn't you be able to use Python in all those locations, and **exploit the unique capabilities of those platforms**? ---- image: cross-platform.png ---- image_alignment: left + #### text-block #### -title: ### ...behaving natively. +title: ...behaving natively. ---- text: End users shouldn't have to care what language their tools are written in. And that starts with looking and behaving **like completely native tools**. Native appearance, native behavior, delivered in the way a native app is delivered. Why shouldn't your Python tools fit in just as well as a native tool? ---- image: native.png ---- image_alignment: right + #### text-block #### -title: ## This is BeeWare. +title: This is BeeWare. ---- text: This is what BeeWare provides. Tools to help you write Python code with a rich, **native user interface**; and the libraries and support code necessary to get that code running on **iOS, Android, macOS, Linux, Windows, tvOS, and more**. ---- image: brutus-97.png ---- image_alignment: left + #### text-block #### -title: ### Open source +title: Open source ---- text: The Open Source development process has proven itself to be the most reliable way to develop robust and reliable software. That's why the entire BeeWare suite of tools are BSD licensed, and **available for all to use and modify**. ---- image: opensource.png ---- image_alignment: right + #### text-block #### -title: ### All contributions welcome +title: All contributions welcome ---- text: But it's not just about code. A successful software project requires documentation, design skills, feedback and bug reports. The BeeWare community acknowledges that **all contributions are important** — not just the ones that come as a pull request on GitHub. ---- image: labhr.png ---- image_alignment: left + #### text-block #### -title: ### From diversity comes strength +title: From diversity comes strength ---- text: A diverse community is a strong community. This means accepting people of all levels of experience, from all backgrounds, of all races, creeds, orientations and expressions. The BeeWare project is committed to **developing and maintaining a diverse, welcoming community**. We have an **open offer to mentor anyone** who wants to get involved as a contributor, backed up by a [Code of Conduct](community/behavior/code-of-conduct/) that is rigorously enforced. ---- image: diversity.png ---- image_alignment: right + #### text-block #### title: Contribute! ---- text: If all this sounds interesting, why not take a look at the [BeeWare projects](/project) and see how you can use them when developing Python applications? Or, if you'd like to contribute, and you've never contributed to open source before, start with our [guide for first time contributors](/contributing/first-time/). If you feel ready to dive straight in, check out the [project pages](/project/) or our guide on [what you can do to help](/contributing/). ----- -image: ----- -image_alignment: + #### button-block #### label: - Contribute to BeeWare +Contribute to BeeWare ---- link: /contributing/ ---- @@ -141,14 +142,12 @@ type: primary size: lg ---- is_block: yes + #### text-block #### -title: ### Stay in touch! +title: Stay in touch! ---- text: Follow [@beeware@fosstodon.org](https://fosstodon.org/@beeware) on Mastodon, or [join the BeeWare enthusiasts mailing list](/community/keep-informed/) for updates, hints, tips, and announcements related to the project. ----- -image: ----- -image_alignment: + #### button-block #### label: Keep in touch! ---- @@ -161,15 +160,12 @@ type: success size: lg ---- is_block: yes + #### text-block #### -title: ### Members ----- -text: BeeWare is supported by users like you! Every little bit helps: [click here to contribute](/membership/). ----- -image: +title: Members ---- -image_alignment: +text: BeeWare is supported by users like you! Every little bit helps: [click here to contribute](/membership/). --- gutter_top: --- -gutter_bottom: ### [... and many more](/project/) +gutter_bottom: [... and many more](/project/) diff --git a/flowblocks/text-block.ini b/flowblocks/text-block.ini index 77a1ae7c851..35d90deffca 100644 --- a/flowblocks/text-block.ini +++ b/flowblocks/text-block.ini @@ -4,8 +4,7 @@ button_label = Rich Text [fields.title] label = Title -description = Markdown -type = markdown +type = text translate = True [fields.text] diff --git a/templates/blocks/text-block.html b/templates/blocks/text-block.html index 8c6352f9841..5221821fb9f 100644 --- a/templates/blocks/text-block.html +++ b/templates/blocks/text-block.html @@ -1,2 +1,3 @@ {% if this.title %}

{{ this.title }}

{% endif %} -

{% if this.image %}{% endif %} {{ this.text }}

+

{% if this.image %}{% endif %}

+{{ this.text }} diff --git a/templates/home.html b/templates/home.html index 5b47adfe271..0b39f6ccefa 100644 --- a/templates/home.html +++ b/templates/home.html @@ -26,8 +26,8 @@

BeeWare

{{ this.title }}

-

{{ this.description }}

-

+ {{ this.description }} +

{% for blk in this.header.blocks %} {{ blk }} {% endfor %} diff --git a/templates/layout.html b/templates/layout.html index ce5d18d8ceb..636ffec8a99 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -94,25 +94,25 @@

diff --git a/templates/macros/breadcrumbs.html b/templates/macros/breadcrumbs.html index 5f383b60d94..19505bd540d 100644 --- a/templates/macros/breadcrumbs.html +++ b/templates/macros/breadcrumbs.html @@ -6,7 +6,7 @@ {% if not page.parent.parent %} {{ t_home }} {% else %} - {{ breadcrumbs(page.parent) }} > + {{ breadcrumbs(page.parent) }} > {{ page.parent.title }} {% endif %} {% endmacro %} From bf371c603427be0fb76f4f288308e91eac21b912 Mon Sep 17 00:00:00 2001 From: Charles Whittington Date: Fri, 13 Jun 2025 20:07:48 -0400 Subject: [PATCH 2/8] Remove Beeware package, update edit links --- databags/translate.ini | 45 +--- .../lektor_beeware_plugin.py | 205 ------------------ packages/lektor_beeware_plugin/pyproject.toml | 38 ---- packages/lektor_beeware_plugin/setup.py | 3 - templates/layout.html | 88 +++----- 5 files changed, 40 insertions(+), 339 deletions(-) delete mode 100644 packages/lektor_beeware_plugin/lektor_beeware_plugin.py delete mode 100644 packages/lektor_beeware_plugin/pyproject.toml delete mode 100644 packages/lektor_beeware_plugin/setup.py diff --git a/databags/translate.ini b/databags/translate.ini index ead76f03d6f..aa42bbad89a 100644 --- a/databags/translate.ini +++ b/databags/translate.ini @@ -2,10 +2,7 @@ ; Breadcrumbs home = Home edit_on_github = Edit on GitHub -create_on_github = Translate on GitHub -translation_out_of_date = This translation of the original content is out of date! -see_original_content = See what changed in the original content -update_translation = Update translation on Github +edit_translation = Edit translation on Weblate ; Footer sitemap = Sitemap @@ -135,10 +132,7 @@ polish = Polski ; Breadcrumbs home = الرئيسية edit_on_github = عدِّل على GitHub -create_on_github = ترجم على GitHub -translation_out_of_date = ترجمة هذا المحتوى تحتاج إلى تحديث -see_original_content = تحقق مما تم تحديثُه في المحتوى الأصلى -update_translation = قم بتحديث الترجمة على Github +update_translation = قم بتحديث الترجمة على Weblate ; Footer sitemap = خريطة الموقع @@ -250,10 +244,7 @@ missing_translations = الصفحات التالية تفتقد إلى التر ; Breadcrumbs home = Início edit_on_github = Editar no GitHub -create_on_github = Traduzir no GitHub -translation_out_of_date = Esta tradução está desatualizada! -see_original_content = Veja o que mudou na versão original -update_translation = Atualizar tradução no Github +update_translation = Atualizar tradução no Weblate ; Footer sitemap = Mapa do site @@ -365,10 +356,7 @@ missing_translations = As páginas a seguir não possuem tradução ; Breadcrumbs home = 主頁 edit_on_github = 在 GitHub 上編輯 -create_on_github = 在 GitHub 上翻譯 -translation_out_of_date = 這個頁面的翻譯可能已經過時! -see_original_content = 看看原來的內容有什麼變化 -update_translation = 在 Github 上更新翻譯 +update_translation = 在 Weblate 上更新翻譯 ; Footer sitemap = 網站地圖 @@ -480,10 +468,7 @@ missing_translations = The following pages are missing a translation ; Breadcrumbs home = Inicio edit_on_github = Editar en GitHub -create_on_github = Traducir en GitHub -translation_out_of_date = El contenido y/o traducción de esta página puede estar desactualizado! -see_original_content = Ver que ha cambiado -update_translation = Actualizar el contenido en Github +update_translation = Actualizar el contenido en Weblate ; Footer sitemap = Mapa del Sitio @@ -595,10 +580,7 @@ outdated_translations = Las siguientes páginas pueden contener traducciones des ; Breadcrumbs home = Accueil edit_on_github = Editer sur GitHub -create_on_github = Traduire sur GitHub -translation_out_of_date = Cette traduction du contenu original est obsolète! -see_original_content = Voir les modifications du contenu original -update_translation = Mettre à jour la traduction sur Github +update_translation = Mettre à jour la traduction sur Weblate ; Footer sitemap = Plan du site @@ -710,10 +692,7 @@ missing_translations = Les pages suivantes n'ont pas de traduction ; Breadcrumbs home = Home edit_on_github = Modifica su GitHub -create_on_github = Tradurre su GitHub -translation_out_of_date = Questa traduzione del contenuto originale non è aggiornata! -see_original_content = Vedi cosa è cambiato nel contenuto originale -update_translation = Aggiorna la traduzione su Github +update_translation = Aggiorna la traduzione su Weblate ; Footer sitemap = Mappa del sito @@ -825,10 +804,7 @@ missing_translations = Alle seguenti pagine manca una traduzione ; Breadcrumbs home = Strona główna edit_on_github = Edytuj na GitHubie -create_on_github = Tłumacz na GitHubie -translation_out_of_date = To tłumaczenie jest nieaktualne! -see_original_content = Zobacz co zmieniło się na oryginalnej stronie -update_translation = Zaktualizuj tłumaczenie na Githubie +update_translation = Zaktualizuj tłumaczenie na Weblateie ; Footer sitemap = Mapa strony @@ -940,10 +916,7 @@ missing_translations = Na tych stronach brakuje tłumaczenia ; Breadcrumbs home = 首页 edit_on_github = 在GitHub上编辑 -create_on_github = 在GitHub上翻译 -translation_out_of_date = 这份原始内容的翻译已经过时了! -see_original_content = 查看原始内容的变化 -update_translation = 在Github上更新翻译 +update_translation = 在Weblate上更新翻译 ; Footer sitemap = 站点地图 diff --git a/packages/lektor_beeware_plugin/lektor_beeware_plugin.py b/packages/lektor_beeware_plugin/lektor_beeware_plugin.py deleted file mode 100644 index 57138367028..00000000000 --- a/packages/lektor_beeware_plugin/lektor_beeware_plugin.py +++ /dev/null @@ -1,205 +0,0 @@ -# -*- coding: utf-8 -*- -"""This is a custom local plugin to ad extra functionality to BeeWare site.""" - -# Standard library imports -from datetime import datetime, date -import os -import subprocess -import sys -from urllib.parse import quote_plus - -# Third party imports -from lektor.pluginsystem import Plugin -from lektor.db import Record -from markupsafe import Markup -from pygments import highlight -from pygments import lexers -from pygments.formatters import HtmlFormatter -from pygments.styles import get_all_styles - - -PY3 = sys.version_info[0] == 3 - - -class BeeWarePlugin(Plugin): - name = 'BeeWare Custom Lektor Plugin' - description = 'This is a custom local plugin to add extra functionality.' - - DATE_FORMAT = "%Y-%m-%d %H:%M:%S" - EXECUTE_CACHE = {} - - def on_setup_env(self, **extra): - - # --- Helper methods - # --------------------------------------------------------------------- - def execute(cmd): - """Execute a cmd (list) and return the stdout and stderr.""" - joined_cmd = ' '.join(cmd) - if joined_cmd in self.EXECUTE_CACHE: - stdout, stderr = self.EXECUTE_CACHE[joined_cmd] - else: - stdout, stderr = None, None - try: - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - stdout, stderr = p.communicate() - - if PY3: - if stdout: - stdout = stdout.decode() - if stderr: - stderr = stderr.decode() - - except OSError: - print('\nCommand not found!\n') - print(joined_cmd) - print('\n') - except Exception as e: - print(e) - print('\n') - - self.EXECUTE_CACHE[joined_cmd] = (stdout, stderr) - - return stdout, stderr - - def git_commits(filepath, since): - """Get git commit hashes for `filepath` `since` a given date.""" - cmd = ('git', 'log', '--since="'+since+'"', '--pretty=format:%H', - '--', filepath) - stdout, stderr = execute(cmd) - - commits = [] - if stdout: - commits = [c for c in stdout.split('\n') if c] - - return commits - - def git_diff(filepath, since): - """Get git diff for a given `filepath` `since` a given date.""" - html_diff = None - commits = git_commits(filepath, since) - if commits: - cmd = ('git', '--no-pager', 'diff', commits[-1]+'^', '--', - filepath) - stdout, stderr = execute(cmd) - - if stdout: - html_diff = highlight(stdout, lexers.DiffLexer(), - HtmlFormatter()) - - # print(' '.join(cmd)) - # print(diff) - # print('\n') - - return html_diff - - def git_modified_date(filepath): - """Get last modified date of `filepath` from git.""" - git_mod_date = None - - if os.path.isfile(filepath): - cmd = ('git', 'log', '-1', - '--date=format:"'+self.DATE_FORMAT+'"', - '--format="%ad"', filepath) - stdout, stderr = execute(cmd) - - if stdout: - stdout = stdout.split('\n')[0] - stdout = stdout.replace('"', '') - stdout = stdout.replace("'", '') - - if stdout: - git_mod_date = datetime.strptime(stdout, self.DATE_FORMAT) - - # print(' '.join(cmd)) - # print(git_mod_date) - # print('\n') - - return git_mod_date - - # --- Exposed methods - # --------------------------------------------------------------------- - def get_pygments_css_styles(style='default'): - """Get pygments CSS.""" - class_name = '.highlight' - css = None - if style in get_all_styles(): - cmd = ('pygmentize', '-S', style, '-f', 'html', '-a', - class_name) - stdout, stderr = execute(cmd) - css = ''.format(stdout) - - return css - - def is_alt_outdated(record): - """Check if record alternative is outdated.""" - return _alt_outdated_diff(record, return_diff=False) - - def alt_outdated_diff(record): - """Check if record alternative is outdated and returns the diff.""" - return _alt_outdated_diff(record, return_diff=True) - - def _alt_outdated_diff(record, return_diff=True): - """Check if record alternative is outdated and returns the diff.""" - if not isinstance(record, Record): - raise ValueError('Must provide a `Record` object') - - config = self.env.jinja_env.globals['config'] - site = self.env.jinja_env.globals['site'] - primary_path = site.get(record.path, alt="_primary").contents.filename - primary_path = primary_path.replace( - '+{0}.lr'.format(config.primary_alternative), '.lr') - try: - alt_path = record.contents.filename - alt_text = '+{0}.lr'.format(config.primary_alternative) - if alt_text in alt_path: - alt_path = alt_path.replace(alt_text, '.lr') - except IOError: - # This means the alt content file does not exist - alt_path = None - - primary_modtime = None - if os.path.isfile(primary_path): - # primary_modtime = os.path.getmtime(primary_path) - primary_modtime = git_modified_date(primary_path) - - alt_modtime = None - if os.path.isfile(alt_path): - # alt_modtime = os.path.getmtime(alt_path) - alt_modtime = git_modified_date(alt_path) - - diff = None - if alt_modtime and primary_modtime > alt_modtime and return_diff: - diff = git_diff(primary_path, - alt_modtime.strftime(self.DATE_FORMAT)) - - if not return_diff: - diff = alt_modtime and primary_modtime > alt_modtime - - return diff - - def urlencode_limit(string, limit=6000): - """Encodes url for uri but if over limit returns None.""" - if type(string) == 'Markup': - string = string.unescape() - - if len(string) <= limit: - string = string.encode('utf8') - string = quote_plus(string) - string = Markup(string) - else: - string = None - - return string - - # Add additional methods to the environment globlas - self.env.jinja_env.globals.update(is_alt_outdated=is_alt_outdated) - self.env.jinja_env.globals.update(alt_outdated_diff=alt_outdated_diff) - self.env.jinja_env.globals.update(urlencode_limit=urlencode_limit) - self.env.jinja_env.globals.update( - get_pygments_css_styles=get_pygments_css_styles) - - self.env.jinja_env.globals['today'] = date.today() - - # Add some python builtins that are good for debugging - self.env.jinja_env.globals.update(dir=dir) diff --git a/packages/lektor_beeware_plugin/pyproject.toml b/packages/lektor_beeware_plugin/pyproject.toml deleted file mode 100644 index 2a097789201..00000000000 --- a/packages/lektor_beeware_plugin/pyproject.toml +++ /dev/null @@ -1,38 +0,0 @@ -# This is a custom local plugin to add extra functionality to BeeWare site. - -[build-system] -requires = [ - "setuptools==80.7.1", -] -build-backend = "setuptools.build_meta" - -[project] -name = "lektor-beeware-plugin" -version = "0.2.1" -description = "" -license = "MIT" -requires-python = ">= 3.9" -authors = [ - {name="Gonzalo Peña-Castellanos", email="goanpeca@gmail.com"}, -] -maintainers = [ - {name="BeeWare Team", email="team@beeware.org"}, -] -classifiers = [ - "Environment :: Plugins", - "Environment :: Web Environment", - "Framework :: Lektor", - "Intended Audience :: Developers", -] -keywords = [ - "Lektor", - "plugin", - "static-site", -] -dependencies = ["Lektor", "MarkupSafe", "Pygments"] - -[project.urls] -Source = "https://github.com/beeware/beeware.github.io/tree/lektor/packages/lektor_beeware_plugin" - -[project.entry-points."lektor.plugins"] -beeware-plugin = "lektor_beeware_plugin:BeeWarePlugin" diff --git a/packages/lektor_beeware_plugin/setup.py b/packages/lektor_beeware_plugin/setup.py deleted file mode 100644 index 606849326a4..00000000000 --- a/packages/lektor_beeware_plugin/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup() diff --git a/templates/layout.html b/templates/layout.html index 636ffec8a99..93fa837bbfb 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -13,11 +13,14 @@ {%- set t_sitemap = transbag('translate', this.alt, 'sitemap') -%} {%- set t_welcome = transbag('translate', this.alt, 'welcome') -%} {%- set t_edit_on_github = transbag('translate', this.alt, 'edit_on_github') -%} -{%- set t_create_on_github = transbag('translate', this.alt, 'create_on_github') -%} -{%- set t_translation_out_of_date = transbag('translate', this.alt, 'translation_out_of_date') -%} -{%- set t_see_original_content = transbag('translate', this.alt, 'see_original_content') -%} -{%- set t_update_translation = transbag('translate', this.alt, 'update_translation') -%} -{%- set diff = alt_outdated_diff(this) -%} +{%- set t_edit_translation = transbag('translate', this.alt, 'edit_translation') -%} + +{%- + set language_codes = { + "zh_CN": "zh_Hans", + "zh_TW": "zh_Hant", + } +-%} @@ -94,23 +97,28 @@