merge branche "@"

This commit is contained in:
Goffi 2021-08-27 14:51:40 +02:00
commit 436696f28c
7 changed files with 49 additions and 30 deletions

View file

@ -106,6 +106,8 @@ the comments to get the meaning of each option.
; background luminance, used by terminal frontends ; background luminance, used by terminal frontends
; can be "auto" (default) to autodetect, "dark" or "light" ; can be "auto" (default) to autodetect, "dark" or "light"
background = auto background = auto
# end-user facing URL, used by Web frontend
public_url = example.com
# uncomment next line if you don't want to use local cache for pubsub items # uncomment next line if you don't want to use local cache for pubsub items
; pubsub_cache_strategy = "no_cache" ; pubsub_cache_strategy = "no_cache"

View file

@ -78,28 +78,34 @@ Libervia Web
The Web frontend is the second main interface for most users. This frontend has the The Web frontend is the second main interface for most users. This frontend has the
particularity to be in 2 parts: a server which serves HTTP content, and a client which particularity to be in 2 parts: a server which serves HTTP content, and a client which
runs in the browser. So you have Libervia server which connect to Libervia backend which itself runs in the browser. So you have Libervia Web server which connect to Libervia backend which itself
connect to the XMPP server, and your browser will connect to Libervia server. connect to the XMPP server, and your browser will connect to Libervia Web server.
In the browser, you can access the server in two ways: either directly with what we call ..
**Libervia pages**, or with a JavaScript code in `single-page application`_ which is the # NOTE: currently not relevant as there is no Web APP anymore, may come back in the
**Libervia client** (or **Libervia web app**) that we have mentioned above. future though
In the browser, you can access the server in two ways: either directly with what we call
**Libervia pages**, or with a JavaScript code in `single-page application`_ which is the
**Libervia client** (or **Libervia web app**) that we have mentioned above.
The **Libervia pages** are web pages managing a single feature. They can work without The **Libervia Web Pages** are web pages managing a single feature. They can work without
JavaScript when it's possible (it's not the case for instant messaging or similar highly JavaScript when it's possible (it's not the case for instant messaging or similar highly
dynamic contents). They aims to be simple and straightforward to use. dynamic contents). They aims to be simple and straightforward to use. That what you're
accessing when you're using Libervia Web.
The **Libervia client** is a highly dynamic web application, used to access more features. ..
It's more complete and may be well adapted if you want to let Libervia running in a browser tab #Note: as above, not relevant anymore but may come back in the future
for an extended period. The **Libervia Web Client** is a highly dynamic web application, used to access more features.
It's more complete and may be well adapted if you want to let Libervia running in a browser tab
for an extended period.
Last but not least, Libervia is also the central part of the new **web framework** of Libervia Web is also the central part of the **Web Framework**. Indeed, in addition of
Libervia. Indeed, in addition of being a frontend to Libervia features (which is built with being a frontend to Libervia features (which is built with this framework), you can create
this framework), you can create totally different websites which are integrated in Libervia totally different websites which are integrated in Libervia (and so XMPP) ecosystem. This
(and so XMPP) ecosystem. This framework uses Libervia template engine (based on `Jinja2`_) and framework uses Libervia template engine (based on `Jinja2`_) and makes the creation of
makes the creation of decentralised and federated websites simple. Thanks to this framework, decentralised and federated websites simple. Thanks to this framework, it's easy to
it's easy to experiment new ideas/features, or to change completely the look and feel of experiment new ideas/features, or to change completely the look and feel of the Libervia
the Libervia frontend. frontend.
The `official Libervia website`_ is made with Libervia web framework. The `official Libervia website`_ is made with Libervia web framework.

View file

@ -25,6 +25,7 @@ import datetime
from dateutil import tz, parser from dateutil import tz, parser
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
from dateutil.utils import default_tzinfo from dateutil.utils import default_tzinfo
from dateutil.parser import ParserError
from babel import dates from babel import dates
import calendar import calendar
import time import time
@ -64,9 +65,15 @@ def date_parse(value, default_tz=TZ_UTC):
value = str(value).strip() value = str(value).strip()
dayfirst = False if YEAR_FIRST_RE.match(value) else True dayfirst = False if YEAR_FIRST_RE.match(value) else True
dt = default_tzinfo( try:
parser.parse(value, default=DEFAULT_DATETIME, dayfirst=dayfirst), dt = default_tzinfo(
default_tz) parser.parse(value, default=DEFAULT_DATETIME, dayfirst=dayfirst),
default_tz)
except ParserError as e:
if value == "now":
dt = datetime.datetime.now(tz.tzutc())
else:
raise e
return calendar.timegm(dt.utctimetuple()) return calendar.timegm(dt.utctimetuple())
def date_parse_ext(value, default_tz=TZ_UTC): def date_parse_ext(value, default_tz=TZ_UTC):

View file

@ -49,7 +49,7 @@ class Get(base.CommandBase):
async def showImage(self, path): async def showImage(self, path):
sat_conf = config.parseMainConf() sat_conf = config.parseMainConf()
cmd = config.getConfig(sat_conf, "jp", "image_cmd") cmd = config.getConfig(sat_conf, C.CONFIG_SECTION, "image_cmd")
cmds = [cmd] + DISPLAY_CMD if cmd else DISPLAY_CMD cmds = [cmd] + DISPLAY_CMD if cmd else DISPLAY_CMD
for cmd in cmds: for cmd in cmds:
try: try:

View file

@ -637,7 +637,9 @@ class Edit(base.CommandBase, BlogPublishCommon, common.BaseEdit):
async def start(self): async def start(self):
# if there are user defined extension, we use them # if there are user defined extension, we use them
SYNTAX_EXT.update(config.getConfig(self.sat_conf, "jp", CONF_SYNTAX_EXT, {})) SYNTAX_EXT.update(
config.getConfig(self.sat_conf, C.CONFIG_SECTION, CONF_SYNTAX_EXT, {})
)
self.current_syntax = await self.get_current_syntax() self.current_syntax = await self.get_current_syntax()
( (
@ -782,11 +784,13 @@ class Preview(base.CommandBase, common.BaseEdit):
aionotify = None aionotify = None
sat_conf = self.sat_conf sat_conf = self.sat_conf
SYNTAX_EXT.update(config.getConfig(sat_conf, "jp", CONF_SYNTAX_EXT, {})) SYNTAX_EXT.update(
config.getConfig(sat_conf, C.CONFIG_SECTION, CONF_SYNTAX_EXT, {})
)
try: try:
self.open_cb_cmd = config.getConfig( self.open_cb_cmd = config.getConfig(
sat_conf, "jp", "blog_preview_open_cmd", Exception sat_conf, C.CONFIG_SECTION, "blog_preview_open_cmd", Exception
) )
except (NoOptionError, NoSectionError): except (NoOptionError, NoSectionError):
self.open_cb_cmd = None self.open_cb_cmd = None
@ -795,7 +799,7 @@ class Preview(base.CommandBase, common.BaseEdit):
open_cb = self.openPreviewExt open_cb = self.openPreviewExt
self.update_cb_cmd = config.getConfig( self.update_cb_cmd = config.getConfig(
sat_conf, "jp", "blog_preview_update_cmd", self.open_cb_cmd sat_conf, C.CONFIG_SECTION, "blog_preview_update_cmd", self.open_cb_cmd
) )
if self.update_cb_cmd is None: if self.update_cb_cmd is None:
update_cb = self.showPreview update_cb = self.showPreview

View file

@ -199,13 +199,13 @@ class BaseEdit(object):
content_file_obj.close() content_file_obj.close()
# we prepare arguments # we prepare arguments
editor = config.getConfig(self.sat_conf, "jp", "editor") or os.getenv( editor = config.getConfig(self.sat_conf, C.CONFIG_SECTION, "editor") or os.getenv(
"EDITOR", "vi" "EDITOR", "vi"
) )
try: try:
# is there custom arguments in sat.conf ? # is there custom arguments in sat.conf ?
editor_args = config.getConfig( editor_args = config.getConfig(
self.sat_conf, "jp", editor_args_opt, Exception self.sat_conf, C.CONFIG_SECTION, editor_args_opt, Exception
) )
except (NoOptionError, NoSectionError): except (NoOptionError, NoSectionError):
# no, we check if we know the editor and have special arguments # no, we check if we know the editor and have special arguments

View file

@ -176,7 +176,7 @@ def use_e2e_env():
if not compose_e2e_path.is_file(): if not compose_e2e_path.is_file():
raise exceptions.NotFound('"docker-compose-e2e.yml" file can\'t be found') raise exceptions.NotFound('"docker-compose-e2e.yml" file can\'t be found')
with tempfile.TemporaryDirectory(prefix="sat_test_e2e_") as temp_dir: with tempfile.TemporaryDirectory(prefix="libervia_test_e2e_") as temp_dir:
override_path = Path(temp_dir) / "test_override.yml" override_path = Path(temp_dir) / "test_override.yml"
override = yaml.load( override = yaml.load(
dedent(f"""\ dedent(f"""\