Skip to content

Commit

Permalink
Merge branch 'master' into zack/521-default-lang-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
blatinier authored Dec 22, 2021
2 parents 36ad436 + 9e021cb commit eeae07e
Show file tree
Hide file tree
Showing 31 changed files with 298 additions and 67 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Python package

on: [push, pull_request]

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, pypy3]
fail-fast: false

steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install isso dependencies
run: python setup.py develop
- name: Install test suite dependencies
run: pip3 install nose
- name: Run test suite
run: make test
env:
PYTHONHASHSEED: random
- name: Install style check dependencies
run: pip3 install flake8
- name: Run style check
run: make flakes
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ script:
notifications:
irc:
channels:
- "chat.freenode.net#isso"
- "irc.libera.chat#isso"
on_success: change
on_failure: always
16 changes: 16 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
Changelog for Isso
==================

%(version)s (%(date)s)

%(version)s (%(date)s)
-------------------

- Don't ignore missing configuration files.
(Jelmer Vernooij)
- Serve isso.css separately to avoid `style-src: unsafe-inline` CSP and allow
clients to override fetch location (#704, ix5):

data-isso-css-url="https://comments.example.org/css/isso.css"
- New "samesite" option in [server] section to override SameSite header for
cookies. (#700, ix5)
- Fallback for SameSite header depending on whether host is served over https
or http (#700, ix5)

0.12.4 (2021-02-03)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COPY --from=jsBuilder /src .
RUN python3 -m venv /isso \
&& . /isso/bin/activate \
&& pip3 install --no-cache-dir --upgrade pip \
&& pip3 install --no-cache-dir gunicorn cffi flask \
&& pip3 install --no-cache-dir gunicorn flask \
&& python setup.py install \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Expand Down
11 changes: 11 additions & 0 deletions docs/docs/configuration/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ preferably in the script tag which embeds the JS:
<script data-isso="/prefix/"
data-isso-id="thread-id"
data-isso-css="true"
data-isso-css-url="null"
data-isso-lang="ru"
data-isso-reply-to-self="false"
data-isso-require-author="false"
Expand Down Expand Up @@ -97,6 +98,16 @@ override the API location:

<script data-isso="/isso" src="/path/to/embed.min.js"></script>

data-isso-css-url
-----------------

Set URL from which to fetch ``isso.css``, e.g. from a CDN.
Defaults to fetching from the API endpoint.

.. code-block:: html

<script src="..." data-isso-css-url="/path/to/isso.css"></script>

data-isso-css
-------------

Expand Down
11 changes: 11 additions & 0 deletions docs/docs/configuration/server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ trusted-proxies
`X-Forwarded-For` HTTP header, which is important for the mechanism
forbiding several comment votes coming from the same subnet.

samesite
override ``Set-Cookie`` header ``SameSite`` value.
Needed for setups where isso is not hosted on the same domain, e.g. called
from example.org and hosted under comments.example.org.
By default, isso will set ``SameSite=None`` when served over https and
``SameSite=Lax`` when served over http
(see `MDM: SameSite <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite>`_
and `#682 <https://github.com/posativ/isso/issues/682>`_ for details).

Accepted values: ``None``, ``Lax``, ``Strict``

.. _configure-smtp:

SMTP
Expand Down
1 change: 1 addition & 0 deletions docs/docs/extras/contribs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Related projects
* `wonderfall/isso Docker image <https://github.com/Wonderfall/docker-isso>`
* `a grav plugin to integrate isso comments <https://github.com/Sommerregen/grav-plugin-jscomments>`
* `a Pelican theme supporting isso comments <https://github.com/Lucas-C/pelican-mg>`
* `a Sphinx extension to integrate isso comments <https://github.com/sphinx-notes/isso>`
14 changes: 9 additions & 5 deletions docs/docs/extras/deployment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,14 @@ isso distribution as `run.py`:
from __future__ import unicode_literals
import os
import pkg_resources
from isso import make_app
from isso import dist, config
application = make_app(
config.load(
os.path.join(dist.location, dist.project_name, "defaults.ini"),
pkg_resources.resource_filename('isso', 'defaults.ini'),
"/path/to/isso.cfg"),
multiprocessing=True)
Expand All @@ -128,13 +129,14 @@ of the virtualenv to the site-specific paths of Python:
site.addsitedir("/path/to/isso_virtualenv")
import os
import pkg_resources
from isso import make_app
from isso import dist, config
application = make_app(
config.load(
os.path.join(dist.location, dist.project_name, "defaults.ini"),
pkg_resources.resource_filename('isso', 'defaults.ini'),
"/path/to/isso.cfg",
multiprocessing=True)
Expand All @@ -148,6 +150,7 @@ the virtualenv have priority over system modules, the following script does the
import os
import site
import pkg_resources
import sys
# Remember original sys.path.
Expand All @@ -169,7 +172,7 @@ the virtualenv have priority over system modules, the following script does the
application = make_app(
config.load(
os.path.join(dist.location, dist.project_name, "defaults.ini"),
pkg_resources.resource_filename('isso', 'defaults.ini'),
"/path/to/isso.cfg",
multiprocessing=True)
Expand Down Expand Up @@ -241,12 +244,13 @@ Finally, copy'n'paste to `/var/www/isso.fcgi` (or whatever location you prefer):
from isso import make_app, dist, config
import os
import pkg_resources
from flup.server.fcgi import WSGIServer
application = make_app(config.load(
os.path.join(dist.location, dist.project_name, "defaults.ini"),
"/path/to/isso.cfg"))
pkg_resources.resource_filename('isso', 'defaults.ini'),
"/path/to/isso.cfg"))
WSGIServer(application).run()
`Openshift <http://openshift.com>`__
Expand Down
3 changes: 1 addition & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ <h2>Links</h2>
</ul>
<h2>Help</h2>
<p>
Join <a href="http://webchat.freenode.net/?channels=isso">
<code>#isso</code></a> on <a href="http://freenode.net/">Freenode</a>
Join <code>#isso</code> on <a href="https://libera.chat/">Libera.Chat</a>
or open an issue on <a href="https://github.com/posativ/isso/issues">GitHub</a>.
</p>
<h2>Contribute</h2>
Expand Down
2 changes: 1 addition & 1 deletion isso/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def main():

args = parser.parse_args()
conf = config.load(
join(dist.location, dist.project_name, "defaults.ini"), args.conf)
pkg_resources.resource_filename('isso', 'defaults.ini'), args.conf)

if args.command == "import":
conf.set("guard", "enabled", "off")
Expand Down
12 changes: 9 additions & 3 deletions isso/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import datetime

from email.utils import parseaddr, formataddr
from configparser import ConfigParser, NoOptionError, NoSectionError
from configparser import ConfigParser, NoOptionError, NoSectionError, DuplicateSectionError

logger = logging.getLogger("isso")

Expand Down Expand Up @@ -123,12 +123,14 @@ def setify(cp):
for option in cp.options(section))

parser = new()
parser.read(default)
with open(default, 'r') as f:
parser.read_file(f)

a = setify(parser)

if user:
parser.read(user)
with open(user, 'r') as f:
parser.read_file(f)

for item in setify(parser).difference(a):
logger.warn("no such option: [%s] %s", *item)
Expand All @@ -140,6 +142,10 @@ def setify(cp):
logger.info("Your `session-key` has been stored in the "
"database itself, this option is now unused")

try:
parser.add_section('smtp')
except DuplicateSectionError:
pass
try:
fromaddr = parser.get("smtp", "from")
except (NoOptionError, NoSectionError):
Expand Down
6 changes: 5 additions & 1 deletion isso/db/spam.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-

import time
from configparser import NoOptionError, NoSectionError


class Guard:
Expand All @@ -9,7 +10,10 @@ def __init__(self, db):

self.db = db
self.conf = db.conf.section("guard")
self.max_age = db.conf.getint("general", "max-age")
try:
self.max_age = db.conf.getint("general", "max-age")
except (NoOptionError, NoSectionError):
self.max_age = None

def validate(self, uri, comment):

Expand Down
6 changes: 3 additions & 3 deletions isso/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
import logging

from glob import glob
import pkg_resources

from werkzeug.middleware.dispatcher import DispatcherMiddleware
from werkzeug.wrappers import Response

from isso import dist, make_app, wsgi, config
from isso import make_app, wsgi, config

logger = logging.getLogger("isso")

Expand All @@ -25,8 +26,7 @@ class Dispatcher(DispatcherMiddleware):
def __init__(self, *confs):
self.isso = {}

default = os.path.join(
dist.location, dist.project_name, "defaults.ini")
default = pkg_resources.resource_filename('isso', 'defaults.ini')
for i, path in enumerate(confs):
conf = config.load(default, path)

Expand Down
1 change: 1 addition & 0 deletions isso/js/app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ define(["app/utils"], function(utils) {
"css": true,
"lang": "",
"default-lang": "en",
"css-url": null,
"reply-to-self": false,
"require-email": false,
"require-author": false,
Expand Down
6 changes: 4 additions & 2 deletions isso/js/app/i18n.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
define(["app/config", "app/i18n/bg", "app/i18n/cs", "app/i18n/da",
"app/i18n/de", "app/i18n/en", "app/i18n/fa", "app/i18n/fi",
"app/i18n/fr", "app/i18n/hr", "app/i18n/hu", "app/i18n/ru", "app/i18n/it",
"app/i18n/fr", "app/i18n/hr", "app/i18n/hu", "app/i18n/ru", "app/i18n/it", "app/i18n/ko",
"app/i18n/eo", "app/i18n/oc", "app/i18n/pl", "app/i18n/pt_BR", "app/i18n/pt_PT", "app/i18n/sk", "app/i18n/sv", "app/i18n/nl", "app/i18n/el_GR",
"app/i18n/es", "app/i18n/vi", "app/i18n/zh_CN", "app/i18n/zh_CN", "app/i18n/zh_TW"],
function(config, bg, cs, da, de, en, fa, fi, fr, hr, hu, ru, it, eo, oc, pl, pt_BR, pt_PT, sk, sv, nl, el, es, vi, zh, zh_CN, zh_TW) {
function(config, bg, cs, da, de, en, fa, fi, fr, hr, hu, ru, it, ko, eo, oc, pl, pt_BR, pt_PT, sk, sv, nl, el, es, vi, zh, zh_CN, zh_TW) {

"use strict";

Expand All @@ -25,6 +25,7 @@ define(["app/config", "app/i18n/bg", "app/i18n/cs", "app/i18n/da",
case "hu":
case "it":
case "pt":
case "ko":
case "sv":
case "nl":
case "vi":
Expand Down Expand Up @@ -88,6 +89,7 @@ define(["app/config", "app/i18n/bg", "app/i18n/cs", "app/i18n/da",
fi: fi,
fr: fr,
it: it,
ko: ko,
hr: hr,
hu: hu,
oc: oc,
Expand Down
34 changes: 34 additions & 0 deletions isso/js/app/i18n/ko.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
define({
"postbox-text": "여기에 댓글을 입력해주세요(최소 3문자 이상)",
"postbox-author": "이름 (선택)",
"postbox-email": "이메일 (선택)",
"postbox-website": "웹사이트 (선택)",
"postbox-preview": "미리보기",
"postbox-edit": "수정",
"postbox-submit": "댓글쓰기",
"postbox-notification": "댓글이 달리면 이메일로 알립니다",

"num-comments": "한 개의 댓글\n{{ n }} 개의 댓글",
"no-comments": "아직 댓글이 없습니다",
"atom-feed": "Atom 피드",

"comment-reply": "댓글",
"comment-edit": "수정",
"comment-save": "저장",
"comment-delete": "삭제",
"comment-confirm": "확인",
"comment-close": "닫기",
"comment-cancel": "취소",
"comment-deleted": "댓글이 삭제됨.",
"comment-queued": "검토 대기 중인 댓글.",
"comment-anonymous": "익명",
"comment-hidden": "{{ n }} 개의 숨김 댓글",

"date-now": "방금 전",
"date-minute": "1 분 전\n{{ n }} 분 전",
"date-hour": "1 시간 전\n{{ n }} 시간 전",
"date-day": "어제\n{{ n }} 일 전",
"date-week": "저번 주\n{{ n }} 주 전",
"date-month": "저번 달\n{{ n }} 개월 전",
"date-year": "작년\n{{ n }} 년 전"
});
1 change: 1 addition & 0 deletions isso/js/app/i18n/vi.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ define({
"postbox-preview": "Xem trước",
"postbox-edit": "Sửa",
"postbox-submit": "Gửi",
"postbox-notification": "Nhận thông báo email cho các bình luận phản hồi",

"num-comments": "Một bình luận\n{{ n }} bình luận",
"no-comments": "Chưa có bình luận nào",
Expand Down
5 changes: 0 additions & 5 deletions isso/js/app/text/css.js

This file was deleted.

1 change: 0 additions & 1 deletion isso/js/build.count.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
mainConfigFile: 'config.js',
paths: {
"app/text/svg": "app/text/dummy",
"app/text/css": "app/text/dummy"
},

name: "../../node_modules/almond/almond",
Expand Down
Loading

0 comments on commit eeae07e

Please sign in to comment.