├── fiduswriter └── website │ ├── __init__.py │ ├── tests │ ├── __init__.py │ └── test_website.py │ ├── migrations │ ├── __init__.py │ ├── 0013_delete_editor.py │ ├── 0007_publication_abstract.py │ ├── 0004_publication_title.py │ ├── 0002_auto_20220703_1201.py │ ├── 0005_auto_20220715_1044.py │ ├── 0006_auto_20220715_1350.py │ ├── 0008_alter_editor_user.py │ ├── 0010_alter_publication_status.py │ ├── 0011_alter_authors.py │ ├── 0009_design.py │ ├── 0003_auto_20220707_1955.py │ ├── 0012_editor_group.py │ └── 0001_initial.py │ ├── static │ ├── js │ │ ├── plugins │ │ │ ├── website │ │ │ │ └── init.js │ │ │ ├── app │ │ │ │ └── website.js │ │ │ ├── menu │ │ │ │ └── website.js │ │ │ └── editor │ │ │ │ └── website.js │ │ └── modules │ │ │ └── website │ │ │ ├── index.js │ │ │ ├── menu.js │ │ │ ├── tools.js │ │ │ ├── app.js │ │ │ ├── publish_doc.js │ │ │ ├── website │ │ │ ├── article.js │ │ │ ├── overview.js │ │ │ └── templates.js │ │ │ ├── templates.js │ │ │ └── editor.js │ └── css │ │ └── website.css │ ├── apps.py │ ├── admin.py │ ├── urls.py │ ├── models.py │ ├── emails.py │ └── views.py ├── .flake8 ├── ci ├── configuration.py └── .coveragerc ├── dev-requirements.txt ├── .editorconfig ├── MANIFEST.in ├── .gitignore ├── pyproject.toml ├── README.md ├── setup.py ├── .pre-commit-config.yaml ├── stylelint.config.js ├── .github └── workflows │ └── main.yml ├── lint └── django_import_resolver.js ├── biome.json └── LICENSE /fiduswriter/website/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fiduswriter/website/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | extend-ignore = E203, E501 3 | -------------------------------------------------------------------------------- /ci/configuration.py: -------------------------------------------------------------------------------- 1 | INSTALLED_APPS = ["website"] 2 | -------------------------------------------------------------------------------- /dev-requirements.txt: -------------------------------------------------------------------------------- 1 | pre-commit==4.0.1 2 | fiduswriter 3 | -------------------------------------------------------------------------------- /fiduswriter/website/static/js/plugins/website/init.js: -------------------------------------------------------------------------------- 1 | // Placeholder for publish plugins 2 | -------------------------------------------------------------------------------- /fiduswriter/website/static/js/plugins/app/website.js: -------------------------------------------------------------------------------- 1 | export {AppWebsite} from "../../modules/website" 2 | -------------------------------------------------------------------------------- /fiduswriter/website/static/js/plugins/menu/website.js: -------------------------------------------------------------------------------- 1 | export {MenuWebsite} from "../../modules/website" 2 | -------------------------------------------------------------------------------- /fiduswriter/website/static/js/plugins/editor/website.js: -------------------------------------------------------------------------------- 1 | export {EditorWebsite} from "../../modules/website" 2 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | 7 | [*.py] 8 | insert_final_newline = true -------------------------------------------------------------------------------- /fiduswriter/website/static/js/modules/website/index.js: -------------------------------------------------------------------------------- 1 | export {AppWebsite} from "./app" 2 | export {EditorWebsite} from "./editor" 3 | export {MenuWebsite} from "./menu" 4 | -------------------------------------------------------------------------------- /fiduswriter/website/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class WebsiteConfig(AppConfig): 5 | default_auto_field = "django.db.models.BigAutoField" 6 | name = "website" 7 | -------------------------------------------------------------------------------- /ci/.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | parallel = True 3 | concurrency = thread,multiprocessing 4 | sigterm = True 5 | relative_files = True 6 | omit = 7 | *migrations* 8 | venv/* 9 | *virtualenv* 10 | configuration.py 11 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include README.md 3 | recursive-include fiduswriter/website/static * 4 | recursive-include fiduswriter/website/fixtures * 5 | recursive-include fiduswriter/website/templates * 6 | recursive-include fiduswriter/website/locale * 7 | prune travis 8 | prune fiduswriter/venv 9 | prune venv 10 | prune fiduswriter/configuration.py 11 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/0013_delete_editor.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.2 on 2023-02-16 17:31 2 | 3 | from django.db import migrations 4 | 5 | 6 | class Migration(migrations.Migration): 7 | dependencies = [ 8 | ("website", "0012_editor_group"), 9 | ] 10 | 11 | operations = [ 12 | migrations.DeleteModel( 13 | name="Editor", 14 | ), 15 | ] 16 | -------------------------------------------------------------------------------- /fiduswriter/website/static/js/modules/website/menu.js: -------------------------------------------------------------------------------- 1 | export class MenuWebsite { 2 | constructor(menu) { 3 | this.menu = menu 4 | } 5 | 6 | init() { 7 | const documentsItem = this.menu.navItems.find( 8 | item => item.id === "documents" 9 | ) 10 | if (!documentsItem) { 11 | return 12 | } 13 | documentsItem.url = "/documents/" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/0007_publication_abstract.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2022-07-22 17:24 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | dependencies = [ 8 | ("website", "0006_auto_20220715_1350"), 9 | ] 10 | 11 | operations = [ 12 | migrations.AddField( 13 | model_name="publication", 14 | name="abstract", 15 | field=models.TextField(default=""), 16 | ), 17 | ] 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *~ 3 | dist/ 4 | build/ 5 | fiduswriter_website.egg-info/ 6 | fiduswriter_website.egg-info/ 7 | __pycache__/ 8 | venv/ 9 | .envrc 10 | .direnv/ 11 | fiduswriter/.transpile 12 | .transpile 13 | fiduswriter/media 14 | fiduswriter/static-libs 15 | static-libs/ 16 | fiduswriter/static-transpile 17 | fiduswriter/static-collected 18 | fiduswriter/.coveragerc 19 | fiduswriter/.coverage 20 | fiduswriter/configuration.py 21 | fiduswriter/fiduswriter.sql 22 | fiduswriter.sql 23 | fiduswriter/screenshots/ 24 | -------------------------------------------------------------------------------- /fiduswriter/website/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | from . import models 4 | 5 | 6 | class PublicationAdmin(admin.ModelAdmin): 7 | pass 8 | 9 | 10 | admin.site.register(models.Publication, PublicationAdmin) 11 | 12 | 13 | class PublicationAssetAdmin(admin.ModelAdmin): 14 | pass 15 | 16 | 17 | admin.site.register(models.PublicationAsset, PublicationAssetAdmin) 18 | 19 | 20 | class DesignAdmin(admin.ModelAdmin): 21 | pass 22 | 23 | 24 | admin.site.register(models.Design, DesignAdmin) 25 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/0004_publication_title.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2022-07-11 12:35 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | dependencies = [ 8 | ("website", "0003_auto_20220707_1955"), 9 | ] 10 | 11 | operations = [ 12 | migrations.AddField( 13 | model_name="publication", 14 | name="title", 15 | field=models.CharField(blank=True, default="", max_length=255), 16 | ), 17 | ] 18 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/0002_auto_20220703_1201.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2022-07-03 10:01 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | dependencies = [ 8 | ("website", "0001_initial"), 9 | ] 10 | 11 | operations = [ 12 | migrations.RemoveField( 13 | model_name="publication", 14 | name="message_to_editor", 15 | ), 16 | migrations.AddField( 17 | model_name="publication", 18 | name="messages", 19 | field=models.JSONField(default=list), 20 | ), 21 | ] 22 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/0005_auto_20220715_1044.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2022-07-15 08:44 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | dependencies = [ 8 | ("website", "0004_publication_title"), 9 | ] 10 | 11 | operations = [ 12 | migrations.AddField( 13 | model_name="publication", 14 | name="authors", 15 | field=models.JSONField(default=list), 16 | ), 17 | migrations.AddField( 18 | model_name="publication", 19 | name="keywords", 20 | field=models.JSONField(default=list), 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /fiduswriter/website/static/js/modules/website/tools.js: -------------------------------------------------------------------------------- 1 | export function getTextContent(node) { 2 | let text = "" 3 | if (node.attrs && node.attrs.hidden) { 4 | return text 5 | } 6 | if (node.type === "text") { 7 | text += node.text 8 | } 9 | if (node.content) { 10 | text += node.content.map(subNode => getTextContent(subNode)).join("") 11 | } 12 | if ( 13 | [ 14 | "paragraph", 15 | "heading1", 16 | "heading2", 17 | "heading3", 18 | "heading4", 19 | "heading5", 20 | "heading6" 21 | ].includes(node.type) 22 | ) { 23 | text += "\n" 24 | } 25 | return text 26 | } 27 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/0006_auto_20220715_1350.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2022-07-15 11:50 2 | 3 | from django.db import migrations, models 4 | import django.utils.timezone 5 | 6 | 7 | class Migration(migrations.Migration): 8 | dependencies = [ 9 | ("website", "0005_auto_20220715_1044"), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name="publication", 15 | name="added", 16 | field=models.DateTimeField( 17 | auto_now_add=True, 18 | default=django.utils.timezone.now, 19 | ), 20 | preserve_default=False, 21 | ), 22 | migrations.AddField( 23 | model_name="publication", 24 | name="updated", 25 | field=models.DateTimeField(auto_now=True), 26 | ), 27 | ] 28 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/0008_alter_editor_user.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.2 on 2023-01-04 16:02 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | dependencies = [ 10 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 11 | ("website", "0007_publication_abstract"), 12 | ] 13 | 14 | operations = [ 15 | migrations.AlterField( 16 | model_name="editor", 17 | name="user", 18 | field=models.ForeignKey( 19 | blank=True, 20 | null=True, 21 | on_delete=django.db.models.deletion.CASCADE, 22 | related_name="website_editor", 23 | to=settings.AUTH_USER_MODEL, 24 | ), 25 | ), 26 | ] 27 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/0010_alter_publication_status.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.2 on 2023-02-15 10:16 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | dependencies = [ 8 | ("website", "0009_design"), 9 | ] 10 | 11 | operations = [ 12 | migrations.AlterField( 13 | model_name="publication", 14 | name="status", 15 | field=models.CharField( 16 | choices=[ 17 | ("unsubmitted", "Unsubmitted"), 18 | ("submitted", "Submitted"), 19 | ("published", "Published"), 20 | ("rejected", "Rejected"), 21 | ("resubmitted", "Resubmitted"), 22 | ], 23 | default="unsubmitted", 24 | max_length=11, 25 | ), 26 | ), 27 | ] 28 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/0011_alter_authors.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.2 on 2023-02-16 11:12 2 | 3 | from django.db import migrations 4 | 5 | 6 | def convert_author(author_string): 7 | author_string = author_string.strip() 8 | if " " in author_string: 9 | author_parts = author_string.split(" ") 10 | firstname = author_parts.pop(0) 11 | lastname = " ".join(author_parts) 12 | return {"firstname": firstname, "lastname": lastname} 13 | else: 14 | return {"firstname": author_string} 15 | 16 | 17 | def update_publications(apps, schema_editor): 18 | Publication = apps.get_model("website", "Publication") 19 | publications = Publication.objects.all().iterator() 20 | for publication in publications: 21 | publication.authors = list(map(convert_author, publication.authors)) 22 | publication.save() 23 | 24 | 25 | class Migration(migrations.Migration): 26 | dependencies = [ 27 | ("website", "0010_alter_publication_status"), 28 | ] 29 | 30 | operations = [ 31 | migrations.RunPython(update_publications), 32 | ] 33 | -------------------------------------------------------------------------------- /fiduswriter/website/static/js/modules/website/app.js: -------------------------------------------------------------------------------- 1 | export class AppWebsite { 2 | constructor(app) { 3 | this.app = app 4 | } 5 | 6 | init() { 7 | this.app.routes[""] = { 8 | app: "website", 9 | requireLogin: false, 10 | open: () => 11 | import(/* webpackPrefetch: true */ "./website/overview").then( 12 | ({WebsiteOverview}) => new WebsiteOverview(this.app.config) 13 | ) 14 | } 15 | this.app.routes["article"] = { 16 | app: "website", 17 | requireLogin: false, 18 | open: pathnameParts => { 19 | let id = pathnameParts.pop() 20 | if (!id.length) { 21 | id = pathnameParts.pop() 22 | } 23 | return import( 24 | /* webpackPrefetch: true */ "./website/article" 25 | ).then( 26 | ({WebsiteArticle}) => 27 | new WebsiteArticle(this.app.config, id) 28 | ) 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=65.6.3", "wheel", "babel"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "fiduswriter-website" 7 | version = "4.0.0" 8 | description = "A Fidus Writer plugin to allow publishing articles publically directly." 9 | readme = "README.md" 10 | license = {text = "AGPL-3.0-or-later"} 11 | authors = [ 12 | {email = "johannes@fiduswriter.org", name = "Johannes Wilm"}, 13 | ] 14 | classifiers = [ 15 | "Development Status :: 5 - Production/Stable", 16 | "Intended Audience :: Science/Research", 17 | "Framework :: Django :: 5.1", 18 | "License :: OSI Approved :: GNU Affero General Public License v3", 19 | "Programming Language :: Python :: 3", 20 | "Topic :: Scientific/Engineering", 21 | "Topic :: Text Editors :: Word Processors", 22 | "Topic :: Text Processing", 23 | "Topic :: Text Processing :: Markup :: HTML", 24 | "Topic :: Utilities", 25 | "Topic :: Internet :: WWW/HTTP :: Dynamic Content" 26 | ] 27 | dependencies = ["fiduswriter"] 28 | 29 | [project.urls] 30 | homepage = "https://www.fiduswriter.org" 31 | repository = "https://www.github.com/fiduswriter/fiduswriter-website" 32 | -------------------------------------------------------------------------------- /fiduswriter/website/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import re_path 2 | 3 | from . import views 4 | 5 | urlpatterns = [ 6 | re_path( 7 | "^get_doc_info/$", 8 | views.get_doc_info, 9 | name="website_get_doc_info", 10 | ), 11 | re_path("^submit_doc/$", views.submit_doc, name="website_submit_doc"), 12 | re_path("^reject_doc/$", views.reject_doc, name="website_reject_doc"), 13 | re_path("^review_doc/$", views.review_doc, name="website_review_doc"), 14 | re_path("^publish_doc/$", views.publish_doc, name="website_publish_doc"), 15 | re_path( 16 | "^list_publications/$", 17 | views.list_publications, 18 | name="website_list_publications", 19 | ), 20 | re_path( 21 | "^list_publications/(?P[0-9]+)/(?P[0-9]+)/$", 22 | views.list_publications, 23 | name="website_list_publications", 24 | ), 25 | re_path( 26 | "^get_publication/(?P[0-9]+)/$", 27 | views.get_publication, 28 | name="website_get_publication", 29 | ), 30 | re_path( 31 | "^get_style/$", 32 | views.get_style, 33 | name="website_get_style", 34 | ), 35 | ] 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | FidusWriter-Website 2 | =================== 3 | 4 | FidusWriter-Website is a Fidus Writer plugin to allow for making 5 | documents available directly to the general public from within Fidus 6 | Writer on the frontpage of Fidus Writer itself. 7 | 8 | # Installation 9 | 10 | 1) Install Fidus Writer like this: 11 | 12 | > pip install fiduswriter\[website\] 13 | 14 | 2) Add "book" to your INSTALLED\_APPS setting in the configuration.py 15 | file like this: 16 | 17 | INSTALLED_APPS += ( 18 | ... 19 | 'website', 20 | ) 21 | 22 | 3) Run `fiduswriter setup` to create the needed database tables and to 23 | create the needed JavaScript files. 24 | 25 | 4) (Re)start your Fidus Writer server 26 | 27 | # Assign editor status 28 | 29 | Assign editor status by giving users the permissions `website.change_publication` (to change existing posts on website) and/or `website.add_publication` (to add completely new posts to website). 30 | 31 | By default, a group with both access rights is created with the name "Website Editors". You can add users to this group to obtain 32 | the two types of access rights. 33 | 34 | Super users will also be treated as editors. 35 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | from glob import glob 3 | 4 | from setuptools import find_namespace_packages 5 | from setuptools import setup 6 | from setuptools.command.build_py import build_py as _build_py 7 | 8 | 9 | # From https://github.com/pypa/setuptools/pull/1574 10 | class build_py(_build_py): 11 | def find_package_modules(self, package, package_dir): 12 | modules = super().find_package_modules(package, package_dir) 13 | patterns = self._get_platform_patterns( 14 | self.exclude_package_data, 15 | package, 16 | package_dir, 17 | ) 18 | 19 | excluded_module_files = [] 20 | for pattern in patterns: 21 | excluded_module_files.extend(glob(pattern)) 22 | 23 | for f in excluded_module_files: 24 | for module in modules: 25 | if module[2] == f: 26 | modules.remove(module) 27 | return modules 28 | 29 | 30 | os.chdir(os.path.normpath(os.path.join(__file__, os.pardir))) 31 | 32 | setup( 33 | packages=find_namespace_packages(), 34 | exclude_package_data={ 35 | "": ["configuration.py", "django-admin.py", "build/*"], 36 | }, 37 | include_package_data=True, 38 | cmdclass={"build_py": build_py}, 39 | ) 40 | -------------------------------------------------------------------------------- /fiduswriter/website/static/js/modules/website/publish_doc.js: -------------------------------------------------------------------------------- 1 | import {postJson} from "../common" 2 | import {HTMLExporter} from "../exporter/html" 3 | 4 | import {htmlExportTemplate} from "./templates" 5 | 6 | // Send the HTML version of a document to the server for publication as a webpage. 7 | export class PublishDoc extends HTMLExporter { 8 | constructor( 9 | url, 10 | user, 11 | message, 12 | authors, 13 | keywords, 14 | abstract, 15 | ...exporterArgs 16 | ) { 17 | const returnValue = super(...exporterArgs) 18 | this.url = url 19 | this.user = user 20 | this.message = message 21 | this.authors = authors 22 | this.keywords = keywords 23 | this.abstract = abstract 24 | this.htmlExportTemplate = htmlExportTemplate 25 | return returnValue 26 | } 27 | download(blob) { 28 | return postJson(this.url, { 29 | doc_id: this.doc.id, 30 | title: this.docTitle, 31 | authors: JSON.stringify(this.authors), 32 | keywords: this.keywords, 33 | abstract: this.abstract, 34 | "html.zip": {file: blob, filename: "html.zip"}, 35 | message: this.message 36 | }) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/0009_design.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.2 on 2023-01-29 22:16 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | dependencies = [ 9 | ("sites", "0002_alter_domain_unique"), 10 | ("website", "0008_alter_editor_user"), 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name="Design", 16 | fields=[ 17 | ( 18 | "id", 19 | models.BigAutoField( 20 | auto_created=True, 21 | primary_key=True, 22 | serialize=False, 23 | verbose_name="ID", 24 | ), 25 | ), 26 | ( 27 | "style", 28 | models.TextField( 29 | default="\n:root {\n --posts_per_page: 10; /* Number of posts per page on frontpage. Disable for all. */\n}\n", 30 | help_text="The CSS style definiton.", 31 | ), 32 | ), 33 | ( 34 | "site", 35 | models.OneToOneField( 36 | on_delete=django.db.models.deletion.CASCADE, 37 | to="sites.site", 38 | ), 39 | ), 40 | ], 41 | ), 42 | ] 43 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/psf/black-pre-commit-mirror 3 | rev: 24.10.0 4 | hooks: 5 | - id: black 6 | args: [--line-length=79] 7 | language_version: python3.13 8 | - repo: https://github.com/pycqa/flake8 9 | rev: '7.1.1' 10 | hooks: 11 | - id: flake8 12 | entry: flake8 --extend-ignore E203,E501 13 | - repo: https://github.com/biomejs/pre-commit 14 | rev: "75149f4e3b63c4df805860d7b04186d56dcbc05c" 15 | hooks: 16 | - id: biome-check 17 | #entry: biome check --files-ignore-unknown=true --no-errors-on-unmatched --fix --unsafe 18 | additional_dependencies: ["@biomejs/biome@1.9.2"] 19 | - repo: https://github.com/awebdeveloper/pre-commit-stylelint 20 | rev: "4200758f4cb2f53dd06898dd8dca35e4b8cfb785" 21 | hooks: 22 | - id: stylelint 23 | additional_dependencies: 24 | [ 25 | "stylelint@15.11.0", 26 | "stylelint-config-standard@34.0.0", 27 | "stylelint-value-no-unknown-custom-properties@5.0.0", 28 | "postcss@8.4.32", 29 | ] 30 | - repo: local 31 | hooks: 32 | - id: django-import-resolver 33 | name: Django Import Resolver 34 | entry: node lint/django_import_resolver.js 35 | language: node 36 | files: \.js$ 37 | additional_dependencies: ["acorn@8.10.0"] 38 | -------------------------------------------------------------------------------- /stylelint.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path") 2 | const {execSync} = require("child_process") 3 | 4 | function getFidusWriterPath() { 5 | try { 6 | const fwPath = execSync( 7 | "python -c \"import fiduswriter; print(next(filter(lambda path: '/site-packages/' in path, fiduswriter.__path__), ''))\"" 8 | ) 9 | .toString() 10 | .trim() 11 | if (fwPath) { 12 | return fwPath 13 | } 14 | throw new Error("Fidus Writer not found") 15 | } catch (error) { 16 | console.error( 17 | "Failed to find Fidus Writer installation:", 18 | error.message 19 | ) 20 | process.exit(1) 21 | } 22 | } 23 | 24 | const fidusWriterPath = getFidusWriterPath() 25 | 26 | module.exports = { 27 | extends: "stylelint-config-standard", 28 | plugins: ["stylelint-value-no-unknown-custom-properties"], 29 | rules: { 30 | "color-hex-length": "long", 31 | "max-nesting-depth": 2, 32 | "csstools/value-no-unknown-custom-properties": [ 33 | true, 34 | { 35 | importFrom: [ 36 | path.join(fidusWriterPath, "base/static/css/colors.css") 37 | ] 38 | } 39 | ], 40 | "selector-class-pattern": [ 41 | "^(([a-z][a-z0-9]*)(-[a-z0-9]+)*)|(ProseMirror(-[a-z0-9]+)*)$", 42 | { 43 | message: 44 | "Selector should use lowercase and separate words with hyphens (selector-class-pattern)" 45 | } 46 | ] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/0003_auto_20220707_1955.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2022-07-07 17:55 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | import website.models 6 | 7 | 8 | class Migration(migrations.Migration): 9 | dependencies = [ 10 | ("website", "0002_auto_20220703_1201"), 11 | ] 12 | 13 | operations = [ 14 | migrations.AddField( 15 | model_name="publication", 16 | name="html_output", 17 | field=models.TextField(default=""), 18 | ), 19 | migrations.AddField( 20 | model_name="publication", 21 | name="html_src", 22 | field=models.TextField(default=""), 23 | ), 24 | migrations.CreateModel( 25 | name="PublicationAsset", 26 | fields=[ 27 | ( 28 | "id", 29 | models.BigAutoField( 30 | auto_created=True, 31 | primary_key=True, 32 | serialize=False, 33 | verbose_name="ID", 34 | ), 35 | ), 36 | ( 37 | "file", 38 | models.FileField( 39 | help_text="A file references in the HTML of a Publication. The filepath will be replaced with the final url of the file in the style.", 40 | upload_to=website.models.publication_asset_location, 41 | ), 42 | ), 43 | ( 44 | "filepath", 45 | models.CharField( 46 | help_text="The original filepath.", 47 | max_length=255, 48 | ), 49 | ), 50 | ( 51 | "publication", 52 | models.ForeignKey( 53 | on_delete=django.db.models.deletion.CASCADE, 54 | to="website.publication", 55 | ), 56 | ), 57 | ], 58 | ), 59 | ] 60 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/0012_editor_group.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.2 on 2023-02-16 12:05 2 | 3 | # Replace Editor model with a permissions group for editors 4 | 5 | from django.db import migrations 6 | from django.contrib.auth.management import create_permissions 7 | from django.db.models import Count 8 | 9 | 10 | def convert_editors(apps, schema_editor): 11 | # Ensure that permissions exist 12 | # See https://code.djangoproject.com/ticket/23422#comment:29 13 | for app_config in apps.get_app_configs(): 14 | app_config.models_module = True 15 | create_permissions(app_config, apps=apps, verbosity=0) 16 | app_config.models_module = None 17 | Permission = apps.get_model("auth", "Permission") 18 | Group = apps.get_model("auth", "Group") 19 | ContentType = apps.get_model("contenttypes", "ContentType") 20 | website_ct = ContentType.objects.get( 21 | app_label="website", model="publication" 22 | ) 23 | add_perm, _created = Permission.objects.get_or_create( 24 | content_type=website_ct, codename="add_publication" 25 | ) 26 | change_perm, _created = Permission.objects.get_or_create( 27 | content_type=website_ct, codename="change_publication" 28 | ) 29 | website_editor_group = ( 30 | Group.objects.annotate(perm_count=Count("permissions")) 31 | .filter(perm_count=2) 32 | .filter(permissions=add_perm) 33 | .filter(permissions=change_perm) 34 | .first() 35 | ) 36 | if not website_editor_group: 37 | website_editor_group = Group.objects.create(name="Website Editors") 38 | website_editor_group.permissions.add(add_perm) 39 | website_editor_group.permissions.add(change_perm) 40 | Editor = apps.get_model("website", "Editor") 41 | editors = Editor.objects.all().iterator() 42 | for editor in editors: 43 | editor.user.groups.add(website_editor_group) 44 | 45 | 46 | class Migration(migrations.Migration): 47 | dependencies = [ 48 | ("contenttypes", "0002_remove_content_type_name"), 49 | ("website", "0011_alter_authors"), 50 | ] 51 | 52 | operations = [ 53 | migrations.RunPython(convert_editors), 54 | ] 55 | -------------------------------------------------------------------------------- /fiduswriter/website/models.py: -------------------------------------------------------------------------------- 1 | from django.conf import settings 2 | from django.db import models 3 | from django.contrib.sites.models import Site 4 | 5 | from document.models import Document 6 | 7 | 8 | STATUS_CHOICES = ( 9 | ("unsubmitted", "Unsubmitted"), 10 | ("submitted", "Submitted"), 11 | ("published", "Published"), 12 | ("rejected", "Rejected"), 13 | ("resubmitted", "Resubmitted"), 14 | ) 15 | 16 | 17 | class Publication(models.Model): 18 | document = models.OneToOneField( 19 | Document, 20 | on_delete=models.deletion.CASCADE, 21 | ) 22 | title = models.CharField(max_length=255, default="", blank=True) 23 | added = models.DateTimeField(auto_now_add=True) 24 | updated = models.DateTimeField(auto_now=True) 25 | submitter = models.ForeignKey( 26 | settings.AUTH_USER_MODEL, 27 | on_delete=models.deletion.CASCADE, 28 | ) 29 | status = models.CharField( 30 | choices=STATUS_CHOICES, 31 | max_length=11, 32 | default="unsubmitted", 33 | ) 34 | messages = models.JSONField(default=list) 35 | authors = models.JSONField(default=list) 36 | keywords = models.JSONField(default=list) 37 | abstract = models.TextField(default="") 38 | 39 | html_src = models.TextField( 40 | default="", 41 | ) # The original HTML as exported from the frontend 42 | html_output = models.TextField( 43 | default="", 44 | ) # The HTML with asset locations replaced. 45 | 46 | def __str__(self): 47 | return f"{self.title} ({self.document_id}, {self.status})" 48 | 49 | 50 | def publication_asset_location(instance, filename): 51 | # preserve the original filename 52 | instance.filename = filename 53 | return "/".join(["publication_assets", filename]) 54 | 55 | 56 | class PublicationAsset(models.Model): 57 | publication = models.ForeignKey( 58 | Publication, 59 | on_delete=models.deletion.CASCADE, 60 | ) 61 | file = models.FileField( 62 | upload_to=publication_asset_location, 63 | help_text=( 64 | "A file references in the HTML of a Publication. The filepath " 65 | "will be replaced with the final url of the file in the style." 66 | ), 67 | ) 68 | filepath = models.CharField( 69 | max_length=255, 70 | help_text="The original filepath.", 71 | ) 72 | 73 | 74 | default_style = """ 75 | :root { 76 | --posts_per_page: 10; /* Number of posts per page on frontpage. Disable for all. */ 77 | } 78 | """ 79 | 80 | 81 | class Design(models.Model): 82 | site = models.OneToOneField(Site, on_delete=models.deletion.CASCADE) 83 | style = models.TextField( 84 | help_text="The CSS style definiton.", default=default_style 85 | ) 86 | 87 | def __str__(self): 88 | return f"{self.site.name}" 89 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - develop 8 | pull_request: 9 | branches: 10 | - main 11 | - develop 12 | 13 | # Allows you to run this workflow manually from the Actions tab 14 | workflow_dispatch: 15 | 16 | jobs: 17 | pre-commit: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v4 21 | - uses: actions/setup-python@v5 22 | with: 23 | python-version: "3.13" 24 | - name: Install dependencies 25 | run: | 26 | pip install pip --upgrade 27 | if grep version pyproject.toml | grep -q "dev"; 28 | then pip install https://github.com/fiduswriter/fiduswriter/archive/develop.zip; 29 | else pip install https://github.com/fiduswriter/fiduswriter/archive/main.zip; 30 | fi 31 | - uses: pre-commit/action@v3.0.1 32 | test: 33 | name: Run tests 34 | runs-on: ubuntu-latest 35 | 36 | steps: 37 | - name: Check out Git repository 38 | uses: actions/checkout@v3 39 | - name: Set up Python 40 | uses: actions/setup-python@v4 41 | with: 42 | python-version: "3.11" 43 | - name: Set up Node 44 | uses: actions/setup-node@v3 45 | with: 46 | node-version: lts/* 47 | - name: Install Python dependencies 48 | run: | 49 | pip install wheel 50 | pip install pip --upgrade 51 | if grep version pyproject.toml | grep -q "dev"; 52 | then pip install https://github.com/fiduswriter/fiduswriter/archive/develop.zip; 53 | else pip install https://github.com/fiduswriter/fiduswriter/archive/main.zip; 54 | fi 55 | cd fiduswriter 56 | mv ../ci/configuration.py ./ 57 | mv ../ci/.coveragerc ./ 58 | pip install requests[security] 59 | pip install coverage 60 | pip install coveralls 61 | pip install packaging 62 | pip install webdriver-manager 63 | pip install selenium 64 | coverage run $(which fiduswriter) setup --no-static 65 | - name: Run tests 66 | uses: nick-invision/retry@v2 67 | with: 68 | timeout_minutes: 8 69 | max_attempts: 3 70 | retry_on: error 71 | command: | 72 | cd fiduswriter 73 | coverage run $(which fiduswriter) test website 74 | - name: Upload failed test screenshots 75 | if: ${{ failure() }} 76 | uses: actions/upload-artifact@v4 77 | with: 78 | name: failure-artifacts 79 | path: ${{ github.workspace }}/fiduswriter/screenshots/ 80 | - name: Coveralls 81 | run: | 82 | cd fiduswriter 83 | coverage combine 84 | coveralls --service=github 85 | env: 86 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 87 | -------------------------------------------------------------------------------- /fiduswriter/website/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2022-05-27 17:05 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | initial = True 10 | 11 | dependencies = [ 12 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 13 | ("document", "0018_fidus_3_4"), 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name="Publication", 19 | fields=[ 20 | ( 21 | "id", 22 | models.BigAutoField( 23 | auto_created=True, 24 | primary_key=True, 25 | serialize=False, 26 | verbose_name="ID", 27 | ), 28 | ), 29 | ( 30 | "status", 31 | models.CharField( 32 | choices=[ 33 | ("unsubmitted", "Unsubmitted"), 34 | ("submitted", "Submitted"), 35 | ("published", "Published"), 36 | ("resubmitted", "Resubmitted"), 37 | ], 38 | default="unsubmitted", 39 | max_length=11, 40 | ), 41 | ), 42 | ("message_to_editor", models.TextField(default="")), 43 | ( 44 | "document", 45 | models.OneToOneField( 46 | on_delete=django.db.models.deletion.CASCADE, 47 | to="document.document", 48 | ), 49 | ), 50 | ( 51 | "submitter", 52 | models.ForeignKey( 53 | on_delete=django.db.models.deletion.CASCADE, 54 | to=settings.AUTH_USER_MODEL, 55 | ), 56 | ), 57 | ], 58 | ), 59 | migrations.CreateModel( 60 | name="Editor", 61 | fields=[ 62 | ( 63 | "id", 64 | models.BigAutoField( 65 | auto_created=True, 66 | primary_key=True, 67 | serialize=False, 68 | verbose_name="ID", 69 | ), 70 | ), 71 | ( 72 | "user", 73 | models.ForeignKey( 74 | blank=True, 75 | null=True, 76 | on_delete=django.db.models.deletion.CASCADE, 77 | to=settings.AUTH_USER_MODEL, 78 | ), 79 | ), 80 | ], 81 | ), 82 | ] 83 | -------------------------------------------------------------------------------- /fiduswriter/website/static/js/modules/website/website/article.js: -------------------------------------------------------------------------------- 1 | import {ensureCSS, getJson, setDocTitle, whenReady} from "../../common" 2 | import {articleBodyTemplate} from "./templates" 3 | 4 | export class WebsiteArticle { 5 | constructor({app, user}, id) { 6 | this.app = app 7 | this.user = user 8 | this.id = id 9 | 10 | this.siteName = "" // Name of site as stored in database. 11 | 12 | this.publication = {} 13 | this.popUp = false 14 | } 15 | 16 | init() { 17 | return this.getPublication() 18 | .then(() => whenReady()) 19 | .then(() => this.render()) 20 | .then(() => this.bind()) 21 | } 22 | 23 | getPublication() { 24 | return getJson(`/api/website/get_publication/${this.id}/`).then( 25 | json => { 26 | this.publication = json.publication 27 | this.siteName = json.site_name 28 | } 29 | ) 30 | } 31 | 32 | render() { 33 | this.dom = document.createElement("body") 34 | this.dom.classList.add("article") 35 | this.dom.innerHTML = articleBodyTemplate({ 36 | user: this.user, 37 | siteName: this.siteName, 38 | publication: this.publication 39 | }) 40 | ensureCSS([staticUrl("css/document.css")]) 41 | document.body = this.dom 42 | setDocTitle(this.publication.title, this.app) 43 | } 44 | 45 | bind() { 46 | this.dom.addEventListener("click", event => { 47 | const target = event.target 48 | if (this.popUp && !this.popUp.contains(target)) { 49 | this.dom.removeChild(this.popUp) 50 | this.popUp = false 51 | } 52 | const link = target.closest("a") 53 | if (!link) { 54 | return 55 | } 56 | const href = link.getAttribute("href") 57 | if (!href || href[0] !== "#") { 58 | return 59 | } 60 | event.preventDefault() 61 | event.stopPropagation() 62 | const linkRef = this.dom.querySelector(href) 63 | if (linkRef) { 64 | if (this.popUp) { 65 | if ( 66 | this.popUp.firstElementChild !== 67 | this.popUp.lastElementChild 68 | ) { 69 | this.popUp.removeChild(this.popUp.lastElementChild) 70 | } 71 | } else { 72 | this.popUp = document.createElement("div") 73 | this.popUp.classList.add("popup") 74 | this.popUp.style.position = "absolute" 75 | this.popUp.style.top = `${ 76 | event.clientY + this.dom.scrollTop + 10 77 | }px` 78 | this.popUp.style.left = `${event.clientX + 10}px` 79 | } 80 | this.popUp.innerHTML += linkRef.outerHTML 81 | this.dom.appendChild(this.popUp) 82 | } 83 | }) 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /fiduswriter/website/static/js/modules/website/templates.js: -------------------------------------------------------------------------------- 1 | import {escapeText, localizeDate} from "../common" 2 | 3 | const EVENT_TYPES = { 4 | submit: gettext("Submitted"), 5 | publish: gettext("Published"), 6 | review: gettext("Reviewed"), 7 | reject: gettext("Rejected") 8 | } 9 | 10 | const STATUS_TYPES = { 11 | unknown: gettext("Unknown"), 12 | submitted: gettext("Submitted"), 13 | published: gettext("Published"), 14 | rejected: gettext("Rejected"), 15 | unsubmitted: gettext("Unsubmitted"), 16 | resubmitted: gettext("Resubmitted") 17 | } 18 | 19 | const messageTr = ({messages}) => { 20 | if (!messages.length) { 21 | return "" 22 | } 23 | return ` 24 | 25 |

${gettext("Log")}

26 | 27 | ${messages 28 | .slice() 29 | .reverse() 30 | .map( 31 | event => 32 | `
33 | ${localizeDate(event.time * 1000)} 34 |   35 | ${EVENT_TYPES[event.type]} 36 |  ${gettext("by")}  37 | ${event.user} 38 | ${ 39 | event.message.length 40 | ? `: ${escapeText(event.message)}` 41 | : "" 42 | } 43 |
` 44 | ) 45 | .join("")} 46 | 47 | ` 48 | } 49 | 50 | export const submitDialogTemplate = ({messages, status}) => 51 | ` 52 | 53 | 54 | 55 | 56 | 57 | ${messageTr({messages})} 58 | 59 | 60 | 63 | 64 | 65 |

${gettext("Status")}

${STATUS_TYPES[status]}

${gettext("Message")}

61 | 62 |
` 66 | 67 | export const htmlExportTemplate = ({body, back, settings}) => 68 | `${body}${back}${ 69 | settings.copyright && settings.copyright.holder 70 | ? `
© ${ 71 | settings.copyright.year 72 | ? settings.copyright.year 73 | : new Date().getFullYear() 74 | } ${settings.copyright.holder}
` 75 | : "" 76 | }${ 77 | settings.copyright && settings.copyright.licenses.length 78 | ? `
${settings.copyright.licenses 79 | .map( 80 | license => 81 | `${escapeText(license.title)}${ 84 | license.start ? ` (${license.start})` : "" 85 | }` 86 | ) 87 | .join("
")}
` 88 | : "" 89 | }` 90 | -------------------------------------------------------------------------------- /fiduswriter/website/static/css/website.css: -------------------------------------------------------------------------------- 1 | :root { 2 | overflow: hidden; 3 | } 4 | 5 | body { 6 | background-color: white; 7 | font-size: 12pt; 8 | min-width: initial; 9 | overflow: hidden auto; 10 | max-height: 100vh; 11 | width: initial; 12 | height: initial; 13 | line-height: 1.6em; 14 | position: relative; 15 | } 16 | 17 | nav.header { 18 | background-color: #b73717; 19 | width: 100%; 20 | left: 0; 21 | padding: 5px 20px; 22 | font-size: smaller; 23 | color: #ffffff; 24 | } 25 | 26 | nav.header a { 27 | color: #ffffff; 28 | text-decoration: underline; 29 | } 30 | 31 | nav.header * + * { 32 | border-left: 1px solid #ffffff; 33 | padding-left: 15px; 34 | margin-left: 15px; 35 | } 36 | 37 | nav.header + div#body { 38 | margin-top: 28px; 39 | } 40 | 41 | div.article-title { 42 | font-size: 25pt; 43 | } 44 | 45 | h1, 46 | h2, 47 | h3, 48 | h4, 49 | h5, 50 | h6 { 51 | padding-top: 20px; 52 | } 53 | 54 | p { 55 | padding-top: 10px; 56 | } 57 | 58 | h1 { 59 | font-size: 20pt; 60 | } 61 | 62 | h2 { 63 | font-size: 18pt; 64 | } 65 | 66 | h3 { 67 | font-size: 16pt; 68 | } 69 | 70 | h4 { 71 | font-size: 14pt; 72 | } 73 | 74 | h5 { 75 | font-size: 12pt; 76 | } 77 | 78 | h6 { 79 | font-size: 10pt; 80 | } 81 | 82 | div.headers h1.site-name { 83 | font-family: Roboto, sans-serif; 84 | font-size: 65px; 85 | font-weight: 650; 86 | text-align: center; 87 | } 88 | 89 | div.articles { 90 | width: calc(80vw - 30px); 91 | max-width: 940px; 92 | background-color: white; 93 | display: inline-block; 94 | margin-bottom: 40px; 95 | } 96 | 97 | nav.header + h1.site-name, 98 | nav.header + div.articles { 99 | margin-top: 36px; 100 | } 101 | 102 | div.content { 103 | margin-top: 42px; 104 | max-width: calc(15vw + 980px); 105 | width: calc(95vw - 60px); 106 | display: block; 107 | margin-right: auto; 108 | margin-left: auto; 109 | } 110 | 111 | body.article div.articles { 112 | margin-right: auto; 113 | margin-left: auto; 114 | display: block; 115 | } 116 | 117 | div.filters { 118 | width: calc(15vw - 30px); 119 | background-color: white; 120 | display: inline-block; 121 | vertical-align: top; 122 | color: #1f1e1f; 123 | font-size: 16px; 124 | margin-top: 31px; 125 | margin-right: 4vh; 126 | position: sticky; 127 | top: 10px; 128 | } 129 | 130 | div.filters div.filter { 131 | margin-bottom: 16px; 132 | } 133 | 134 | div.filters div.filter h3.filter-title { 135 | font-weight: 650; 136 | border-bottom: 2px dotted #1f1e1f; 137 | } 138 | 139 | div.filters div.filter span.keyword, 140 | div.filters div.filter span.author { 141 | display: block; 142 | padding: 4px 0; 143 | border-bottom: 1px solid #cecece; 144 | cursor: pointer; 145 | } 146 | 147 | div.filters div.filter span.keyword.selected, 148 | div.filters div.filter span.author.selected { 149 | background-color: #1f1e1f; 150 | color: white; 151 | } 152 | 153 | div.articles a.article { 154 | color: black; 155 | border-bottom: 1px dotted #cecece; 156 | padding: 10px; 157 | display: block; 158 | } 159 | 160 | div.articles a.article:hover { 161 | background-color: #cecece; 162 | } 163 | 164 | div.keywords div.keyword { 165 | display: inline-block; 166 | height: 25px; 167 | border-radius: 4px; 168 | background-color: #b73717; 169 | font-family: Roboto, sans-serif; 170 | color: #ffffff; 171 | font-size: 12px; 172 | padding: 2px 10px; 173 | margin-right: 10px; 174 | margin-top: 4px; 175 | font-weight: bold; 176 | } 177 | 178 | h1.article-title, 179 | div.article-title { 180 | font-family: Roboto, sans-serif; 181 | font-weight: bold; 182 | line-height: 1.8em; 183 | } 184 | 185 | div.articles a.article h1.article-title { 186 | font-size: 18px; 187 | } 188 | 189 | div.articles h3.article-updated, 190 | div.articles div.article-authors { 191 | font-family: Roboto, sans-serif; 192 | font-size: 14px; 193 | font-style: italic; 194 | display: inline-block; 195 | } 196 | 197 | div.articles a.article div.article-authors div.author { 198 | display: inline-block; 199 | } 200 | 201 | div.articles a.article div.article-authors div.author + div.author::before { 202 | content: ", "; 203 | } 204 | 205 | div.abstract { 206 | font-size: 12pt; 207 | } 208 | 209 | a.footnote, 210 | a.affiliation { 211 | vertical-align: super; 212 | font-size: 70%; 213 | } 214 | 215 | aside.footnote, 216 | aside.affiliation { 217 | position: relative; 218 | } 219 | 220 | aside.footnote > label, 221 | aside.affiliation > label { 222 | position: absolute; 223 | left: 0; 224 | font-size: 80%; 225 | } 226 | 227 | aside.footnote > label { 228 | top: 10px; 229 | } 230 | 231 | div.popup > * + * { 232 | border-top: 1px black dashed; 233 | } 234 | 235 | aside.footnote > *:not(label), 236 | aside.affiliation > *:not(label) { 237 | margin-left: 30px; 238 | } 239 | 240 | div.popup { 241 | background-color: white; 242 | display: block; 243 | border: 1px solid black; 244 | padding: 0 5px 4px; 245 | border-radius: 4px; 246 | } 247 | 248 | img { 249 | max-width: 100%; 250 | } 251 | -------------------------------------------------------------------------------- /lint/django_import_resolver.js: -------------------------------------------------------------------------------- 1 | const path = require("path") 2 | const fs = require("fs") 3 | const acorn = require("acorn") 4 | const {execSync} = require("child_process") 5 | 6 | const EXCEPTIONS = ["../../../mathlive/opf_includes"] 7 | 8 | function getFidusWriterPath() { 9 | try { 10 | const fwPath = execSync( 11 | "python -c \"import fiduswriter; print(next(filter(lambda path: '/site-packages/' in path, fiduswriter.__path__), ''))\"" 12 | ) 13 | .toString() 14 | .trim() 15 | if (fwPath) { 16 | return fwPath 17 | } 18 | throw new Error("Fidus Writer not found") 19 | } catch (error) { 20 | console.error( 21 | "Failed to find Fidus Writer installation:", 22 | error.message 23 | ) 24 | process.exit(1) 25 | } 26 | } 27 | 28 | function isFile(file) { 29 | let stat 30 | try { 31 | stat = fs.statSync(file) 32 | } catch (e) { 33 | if (e && (e.code === "ENOENT" || e.code === "ENOTDIR")) { 34 | return false 35 | } 36 | throw e 37 | } 38 | return stat.isFile() || stat.isFIFO() 39 | } 40 | 41 | function getAppsPaths(rootDir) { 42 | const appsPaths = [] 43 | const subdirs = fs.readdirSync(rootDir, {withFileTypes: true}) 44 | subdirs.forEach(subdir => { 45 | if (subdir.isDirectory()) { 46 | const staticPath = path.join(rootDir, subdir.name, "static") 47 | if ( 48 | fs.existsSync(staticPath) && 49 | fs.lstatSync(staticPath).isDirectory() 50 | ) { 51 | appsPaths.push(path.join(rootDir, subdir.name)) 52 | } 53 | } 54 | }) 55 | return appsPaths 56 | } 57 | 58 | function resolveFilelocation(source, file, appsPaths) { 59 | const returnValue = {found: false, path: null} 60 | const fullPath = path.resolve(path.dirname(file), source) 61 | 62 | if (fullPath.includes("/plugins/")) { 63 | returnValue.found = true 64 | returnValue.path = null 65 | return returnValue 66 | } 67 | 68 | // Check in plugin and fidus writer apps 69 | appsPaths.find(appPath => { 70 | const resolvedPath = fullPath.replace( 71 | /.*\/static\/js\//g, 72 | `${appPath}/static/js/` 73 | ) 74 | if (isFile(`${resolvedPath}.js`)) { 75 | returnValue.path = `${resolvedPath}.js` 76 | returnValue.found = true 77 | return true 78 | } 79 | if (isFile(`${resolvedPath}/index.js`)) { 80 | returnValue.path = `${resolvedPath}/index.js` 81 | returnValue.found = true 82 | return true 83 | } 84 | 85 | return false 86 | }) 87 | 88 | return returnValue 89 | } 90 | 91 | function checkExports(filePath, importedNames, sourcePath) { 92 | const content = fs.readFileSync(filePath, "utf-8") 93 | const ast = acorn.parse(content, { 94 | sourceType: "module", 95 | ecmaVersion: "latest" 96 | }) 97 | 98 | const exportedNames = new Set() 99 | 100 | ast.body.forEach(node => { 101 | if (node.type === "ExportNamedDeclaration") { 102 | if (node.declaration) { 103 | if (node.declaration.id) { 104 | exportedNames.add(node.declaration.id.name) 105 | } else if (node.declaration.declarations) { 106 | node.declaration.declarations.forEach(decl => { 107 | if (decl.id && decl.id.name) { 108 | exportedNames.add(decl.id.name) 109 | } 110 | }) 111 | } 112 | } 113 | if (node.specifiers) { 114 | node.specifiers.forEach(spec => { 115 | exportedNames.add(spec.exported.name) 116 | }) 117 | } 118 | } else if (node.type === "ExportDefaultDeclaration") { 119 | exportedNames.add("default") 120 | } 121 | }) 122 | 123 | importedNames.forEach(name => { 124 | if (!exportedNames.has(name)) { 125 | console.error( 126 | `Unresolved export: ${name} not found in ${filePath}, imported in ${sourcePath}` 127 | ) 128 | process.exit(1) 129 | } 130 | }) 131 | } 132 | 133 | function checkImports(file, appsPaths) { 134 | const content = fs.readFileSync(file, "utf-8") 135 | const importRegex = 136 | /import\s+(?:(\*\s+as\s+\w+)|(\w+)|(\{[^}]+\}))\s+from\s+['"](.*)['"]/g 137 | let match 138 | while ((match = importRegex.exec(content)) !== null) { 139 | const source = match[4] 140 | // Skip non-relative imports 141 | if (!source.startsWith(".") && !source.startsWith("..")) { 142 | continue 143 | } 144 | if (EXCEPTIONS.includes(source)) { 145 | continue 146 | } 147 | const result = resolveFilelocation(source, file, appsPaths) 148 | if (!result.found) { 149 | console.error(`Unresolved import: ${source} in file ${file}`) 150 | process.exit(1) 151 | } 152 | 153 | const importedNames = [] 154 | if (match[1]) { 155 | // import * as name 156 | importedNames.push("*") 157 | } else if (match[2]) { 158 | // import name 159 | importedNames.push("default") 160 | } else if (match[3]) { 161 | // import { name1, name2 } 162 | const names = match[3] 163 | .replace(/[{}]/g, "") 164 | .split(",") 165 | .map(name => name.trim()) 166 | importedNames.push(...names) 167 | } 168 | if (!result.path) { 169 | // Plugin - final path cannot be checked yet. 170 | return 171 | } 172 | checkExports(result.path, importedNames, file) 173 | } 174 | } 175 | 176 | const pluginPath = path.resolve(__dirname, "../fiduswriter") 177 | const pluginAppsPaths = getAppsPaths(pluginPath) 178 | 179 | const fidusWriterPath = getFidusWriterPath() 180 | const fidusWriterAppsPaths = getAppsPaths(fidusWriterPath) 181 | 182 | const appsPaths = pluginAppsPaths.concat(fidusWriterAppsPaths) 183 | 184 | const files = process.argv.slice(2) 185 | files.forEach(file => checkImports(file, appsPaths)) 186 | -------------------------------------------------------------------------------- /biome.json: -------------------------------------------------------------------------------- 1 | { 2 | "formatter": { 3 | "enabled": true, 4 | "useEditorconfig": true, 5 | "formatWithErrors": false, 6 | "indentStyle": "space", 7 | "indentWidth": 4, 8 | "lineEnding": "lf", 9 | "lineWidth": 80, 10 | "attributePosition": "auto", 11 | "bracketSpacing": true, 12 | "ignore": [ 13 | "**/.transpile-cache/", 14 | "**/venv/", 15 | "**/static-transpile/", 16 | "**/static-libs/", 17 | "**/static-collected/", 18 | "**/node-modules/", 19 | "**/testing/", 20 | "**/.eslintrc.mjs", 21 | "**/*.json", 22 | "**/*.html", 23 | "**/.direnv", 24 | "**/venv", 25 | "**/.transpile", 26 | "**/.babelrc", 27 | "**/sw-template.js" 28 | ] 29 | }, 30 | "linter": { 31 | "enabled": true, 32 | "rules": { 33 | "recommended": false, 34 | "complexity": { 35 | "noExtraBooleanCast": "error", 36 | "noMultipleSpacesInRegularExpressionLiterals": "error", 37 | "noUselessCatch": "off", 38 | "noUselessConstructor": "off", 39 | "noUselessLabel": "error", 40 | "noUselessLoneBlockStatements": "error", 41 | "noUselessRename": "error", 42 | "noUselessStringConcat": "error", 43 | "noUselessTernary": "off", 44 | "noUselessUndefinedInitialization": "error", 45 | "noVoid": "error", 46 | "noWith": "error", 47 | "useLiteralKeys": "off" 48 | }, 49 | "correctness": { 50 | "noConstAssign": "error", 51 | "noConstantCondition": "error", 52 | "noEmptyCharacterClassInRegex": "error", 53 | "noEmptyPattern": "error", 54 | "noGlobalObjectCalls": "error", 55 | "noInnerDeclarations": "error", 56 | "noInvalidConstructorSuper": "error", 57 | "noInvalidUseBeforeDeclaration": "off", 58 | "noNewSymbol": "error", 59 | "noNonoctalDecimalEscape": "error", 60 | "noPrecisionLoss": "error", 61 | "noSelfAssign": "error", 62 | "noSetterReturn": "error", 63 | "noSwitchDeclarations": "error", 64 | "noUndeclaredVariables": "error", 65 | "noUnreachable": "error", 66 | "noUnreachableSuper": "error", 67 | "noUnsafeFinally": "error", 68 | "noUnsafeOptionalChaining": "error", 69 | "noUnusedLabels": "error", 70 | "noUnusedVariables": "error", 71 | "useArrayLiterals": "error", 72 | "useIsNan": "error", 73 | "useValidForDirection": "error", 74 | "useYield": "error" 75 | }, 76 | "security": { "noGlobalEval": "error" }, 77 | "style": { 78 | "noArguments": "off", 79 | "noCommaOperator": "error", 80 | "noNegationElse": "off", 81 | "noParameterAssign": "off", 82 | "noRestrictedGlobals": { "level": "error", "options": {} }, 83 | "noVar": "error", 84 | "noYodaExpression": "off", 85 | "useBlockStatements": "error", 86 | "useCollapsedElseIf": "off", 87 | "useConsistentBuiltinInstantiation": "error", 88 | "useConst": "warn", 89 | "useDefaultSwitchClause": "off", 90 | "useNumericLiterals": "error", 91 | "useShorthandAssign": "off", 92 | "useSingleVarDeclarator": "off", 93 | "useTemplate": "off" 94 | }, 95 | "suspicious": { 96 | "noAsyncPromiseExecutor": "error", 97 | "noCatchAssign": "error", 98 | "noClassAssign": "error", 99 | "noCompareNegZero": "error", 100 | "noControlCharactersInRegex": "off", 101 | "noDebugger": "error", 102 | "noDoubleEquals": "off", 103 | "noDuplicateCase": "error", 104 | "noDuplicateClassMembers": "error", 105 | "noDuplicateObjectKeys": "error", 106 | "noDuplicateParameters": "error", 107 | "noEmptyBlockStatements": "off", 108 | "noFallthroughSwitchClause": "error", 109 | "noFunctionAssign": "error", 110 | "noGlobalAssign": "error", 111 | "noImportAssign": "error", 112 | "noLabelVar": "error", 113 | "noMisleadingCharacterClass": "error", 114 | "noPrototypeBuiltins": "off", 115 | "noRedeclare": "error", 116 | "noSelfCompare": "error", 117 | "noShadowRestrictedNames": "error", 118 | "noSparseArray": "error", 119 | "noUnsafeNegation": "error", 120 | "useAwait": "error", 121 | "useGetterReturn": "error", 122 | "useValidTypeof": "error" 123 | } 124 | }, 125 | "ignore": [ 126 | "**/.transpile-cache/", 127 | "**/venv/", 128 | "**/static-transpile/", 129 | "**/static-libs/", 130 | "**/static-collected/", 131 | "**/testing/", 132 | "**/manifest.json", 133 | "**/sw-template.js" 134 | ] 135 | }, 136 | "javascript": { 137 | "formatter": { 138 | "jsxQuoteStyle": "double", 139 | "quoteProperties": "asNeeded", 140 | "trailingCommas": "none", 141 | "semicolons": "asNeeded", 142 | "indentWidth": 4, 143 | "arrowParentheses": "asNeeded", 144 | "bracketSameLine": true, 145 | "quoteStyle": "double", 146 | "attributePosition": "auto", 147 | "bracketSpacing": false 148 | }, 149 | "globals": [ 150 | "settings_MEDIA_MAX_SIZE", 151 | "settings_SOCIALACCOUNT_OPEN", 152 | "settings_REGISTRATION_OPEN", 153 | "gettext", 154 | "interpolate", 155 | "settings_USE_SERVICE_WORKER", 156 | "transpile_VERSION", 157 | "settings_TEST_SERVER", 158 | "settings_DEBUG", 159 | "settings_SOURCE_MAPS", 160 | "settings_STATIC_URL", 161 | "settings_PASSWORD_LOGIN", 162 | "process", 163 | "staticUrl", 164 | "settings_CONTACT_EMAIL", 165 | "settings_IS_FREE", 166 | "settings_FOOTER_LINKS", 167 | "settings_BRANDING_LOGO" 168 | ] 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /fiduswriter/website/static/js/modules/website/website/overview.js: -------------------------------------------------------------------------------- 1 | import {getJson, setDocTitle, whenReady} from "../../common" 2 | import {overviewBodyTemplate, overviewContentTemplate} from "./templates" 3 | 4 | export class WebsiteOverview { 5 | constructor({app, user}) { 6 | this.app = app 7 | this.user = user 8 | 9 | this.siteName = "" // Name of site as stored in database. 10 | this.publications = [] // Publications as they come from the server 11 | 12 | this.authors = [] // Name of every author used in at least one publication 13 | this.keywords = [] // Every keyword used in at least one publication 14 | 15 | this.filters = {} // current applied filters 16 | this.filteredPublications = [] // Shortened publication list after applying filters. 17 | this.postsPerPage = false 18 | this.numPages = false 19 | this.downloadedPage = 0 20 | } 21 | 22 | init() { 23 | return this.getCSS() 24 | .then(() => whenReady()) 25 | .then(() => this.readSettingsFromCSS()) 26 | .then(() => this.getPublications()) 27 | .then(() => this.render()) 28 | .then(() => this.bind()) 29 | .then(() => this.loadMore()) 30 | } 31 | 32 | getCSS() { 33 | return getJson("/api/website/get_style/").then(json => { 34 | if (json.style) { 35 | const style = document.createElement("style") 36 | style.innerHTML = json.style 37 | document.head.appendChild(style) 38 | } 39 | }) 40 | } 41 | 42 | readSettingsFromCSS() { 43 | const postsPerPage = parseInt( 44 | getComputedStyle(document.documentElement).getPropertyValue( 45 | "--posts_per_page" 46 | ) 47 | ) 48 | if (!isNaN(postsPerPage)) { 49 | this.postsPerPage = postsPerPage 50 | } 51 | } 52 | 53 | getPublications() { 54 | if (this.currentlyDownloadingPublications) { 55 | return false 56 | } 57 | this.currentlyDownloadingPublications = true 58 | const url = this.postsPerPage 59 | ? `/api/website/list_publications/${this.postsPerPage}/${ 60 | this.downloadedPage + 1 61 | }/` 62 | : "/api/website/list_publications/" 63 | return getJson(url).then(json => { 64 | if (!this.downloadedPage) { 65 | this.siteName = json.site_name 66 | if (json.num_pages) { 67 | this.numPages = json.num_pages 68 | } 69 | } 70 | let keywords = [...this.keywords] 71 | let authors = [...this.authors] 72 | json.publications.forEach(publication => { 73 | keywords = keywords.concat(publication.keywords) 74 | authors = authors.concat( 75 | publication.authors.map( 76 | author => 77 | `${author.firstname}${ 78 | author.lastname ? ` ${author.lastname}` : "" 79 | }` 80 | ) 81 | ) 82 | }) 83 | this.publications = this.filteredPublications = 84 | this.publications.concat(json.publications) 85 | this.keywords = [...new Set(keywords)] 86 | this.authors = [...new Set(authors)] 87 | this.downloadedPage += 1 88 | this.currentlyDownloadingPublications = false 89 | }) 90 | } 91 | 92 | render() { 93 | this.dom = document.createElement("body") 94 | this.dom.classList.add("overview") 95 | this.renderBody() 96 | document.body = this.dom 97 | setDocTitle(this.siteName, this.app) 98 | } 99 | 100 | renderBody() { 101 | this.dom.innerHTML = overviewBodyTemplate({ 102 | user: this.user, 103 | siteName: this.siteName, 104 | authors: this.authors, 105 | keywords: this.keywords, 106 | publications: this.filteredPublications, 107 | filters: this.filters 108 | }) 109 | } 110 | 111 | rerenderContent() { 112 | const contentDOM = this.dom.querySelector("div.content") 113 | contentDOM.innerHTML = overviewContentTemplate({ 114 | keywords: this.keywords, 115 | authors: this.authors, 116 | publications: this.filteredPublications, 117 | filters: this.filters 118 | }) 119 | } 120 | 121 | bind() { 122 | this.dom.addEventListener("click", event => { 123 | const authorEl = event.target.closest("span.author") 124 | const keywordEl = event.target.closest("span.keyword") 125 | if (!authorEl && !keywordEl) { 126 | return 127 | } 128 | event.preventDefault() 129 | if (authorEl) { 130 | if (authorEl.classList.contains("selected")) { 131 | delete this.filters.author 132 | } else { 133 | const index = parseInt(authorEl.dataset.index) 134 | this.filters.author = this.authors[index] 135 | } 136 | } else { 137 | if (keywordEl.classList.contains("selected")) { 138 | delete this.filters.keyword 139 | } else { 140 | const index = parseInt(keywordEl.dataset.index) 141 | this.filters.keyword = this.keywords[index] 142 | } 143 | } 144 | this.applyFilters() 145 | this.renderBody() 146 | }) 147 | this.dom.addEventListener("scroll", () => { 148 | this.loadMore() 149 | }) 150 | } 151 | 152 | loadMore() { 153 | if ( 154 | this.dom.scrollTop + this.dom.clientHeight >= 155 | this.dom.scrollHeight 156 | ) { 157 | if (this.numPages && this.numPages > this.downloadedPage) { 158 | this.getPublications() 159 | .then(() => this.rerenderContent()) 160 | .then(() => this.loadMore()) 161 | } 162 | } 163 | } 164 | 165 | applyFilters() { 166 | this.filteredPublications = this.publications.filter(publication => { 167 | if ( 168 | this.filters.author && 169 | !publication.authors.find( 170 | author => 171 | `${author.firstname}${ 172 | author.lastname ? ` ${author.lastname}` : "" 173 | }` === this.filters.author 174 | ) 175 | ) { 176 | return false 177 | } 178 | if ( 179 | this.filters.keyword && 180 | !publication.keywords.includes(this.filters.keyword) 181 | ) { 182 | return false 183 | } 184 | return true 185 | }) 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /fiduswriter/website/emails.py: -------------------------------------------------------------------------------- 1 | from base.html_email import html_email 2 | from django.conf import settings 3 | from django.core.mail import send_mail 4 | from django.utils.html import escape 5 | from django.utils.translation import gettext as _ 6 | 7 | 8 | def send_submit_notification( 9 | document_title, 10 | link, 11 | message, 12 | editor_name, 13 | editor_email, 14 | ): 15 | if len(document_title) == 0: 16 | document_title = _("Untitled") 17 | message_text = _( 18 | f"Hey {editor_name}, the document '{document_title}' has " 19 | "been submitted to be published. You or another editor need to " 20 | "approve it before it will be made accessible to the general " 21 | "public." 22 | f"\nOpen the document: {link}", 23 | ) 24 | body_html_intro = _( 25 | f"

Hey {escape(editor_name)}
the document '{escape(document_title)}' has " 26 | "been submitted to be published. You or another editor need to " 27 | "approve it before it will be made accessible to the general " 28 | "public.

", 29 | ) 30 | if len(message): 31 | message_text += _(f"\nMessage from the author: {message}") 32 | body_html_intro += _( 33 | f"

Message from the author: {escape(message)}

", 34 | ) 35 | review_document_str = _(f"Review {escape(document_title)}") 36 | access_the_document_str = _("Access the Document") 37 | document_str = _("Document") 38 | body_html = ( 39 | f"

{review_document_str}

" 40 | f"{body_html_intro}" 41 | "" 42 | f"" 45 | "
{document_str}" 43 | f"{document_title}" 44 | "
" 46 | f'" 49 | ) 50 | send_mail( 51 | _(f"Document shared: {escape(document_title)}"), 52 | message_text, 53 | settings.DEFAULT_FROM_EMAIL, 54 | [editor_email], 55 | fail_silently=True, 56 | html_message=html_email(body_html), 57 | ) 58 | 59 | 60 | def send_review_notification( 61 | document_title, 62 | link, 63 | message, 64 | author_name, 65 | author_email, 66 | ): 67 | if len(document_title) == 0: 68 | document_title = _("Untitled") 69 | message_text = _( 70 | f"Hey {author_name}, the document '{document_title}' has " 71 | "been reviewed. You or another author need to change some things " 72 | "before it can be published. Please resubmit it once you are done. " 73 | f"\nOpen the document: {link}", 74 | ) 75 | body_html_intro = _( 76 | f"

Hey {escape(author_name)}
the document '{escape(document_title)}' has " 77 | "been reviewed. You or another author need to change some things " 78 | "before it can be published. Please resubmit it once you are done.

", 79 | ) 80 | if len(message): 81 | message_text += _(f"\nMessage from the editor: {message}") 82 | body_html_intro += _( 83 | f"

Message from the editor: {escape(message)}

", 84 | ) 85 | review_document_str = _(f"{escape(document_title)} reviewed") 86 | access_the_document_str = _("Access the Document") 87 | document_str = _("Document") 88 | body_html = ( 89 | f"

{review_document_str}

" 90 | f"{body_html_intro}" 91 | "" 92 | f"" 95 | "
{document_str}" 93 | f"{document_title}" 94 | "
" 96 | f'" 99 | ) 100 | send_mail( 101 | _(f"Document: {escape(document_title)}"), 102 | message_text, 103 | settings.DEFAULT_FROM_EMAIL, 104 | [author_email], 105 | fail_silently=True, 106 | html_message=html_email(body_html), 107 | ) 108 | 109 | 110 | def send_reject_notification( 111 | document_title, 112 | link, 113 | message, 114 | author_name, 115 | author_email, 116 | ): 117 | if len(document_title) == 0: 118 | document_title = _("Untitled") 119 | message_text = _( 120 | f"Hey {author_name}, the document '{document_title}' has " 121 | "been reviewed and rejected. " 122 | f"\nOpen the document: {link}", 123 | ) 124 | body_html_intro = _( 125 | f"

Hey {escape(author_name)}
the document '{escape(document_title)}' has " 126 | "been reviewed and rejected.

", 127 | ) 128 | if len(message): 129 | message_text += _(f"\nMessage from the editor: {message}") 130 | body_html_intro += _( 131 | f"

Message from the editor: {escape(message)}

", 132 | ) 133 | review_document_str = _(f"{escape(document_title)} rejected") 134 | access_the_document_str = _("Access the Document") 135 | document_str = _("Document") 136 | body_html = ( 137 | f"

{review_document_str}

" 138 | f"{body_html_intro}" 139 | "" 140 | f"" 143 | "
{document_str}" 141 | f"{document_title}" 142 | "
" 144 | f'" 147 | ) 148 | send_mail( 149 | _(f"Document: {escape(document_title)}"), 150 | message_text, 151 | settings.DEFAULT_FROM_EMAIL, 152 | [author_email], 153 | fail_silently=True, 154 | html_message=html_email(body_html), 155 | ) 156 | 157 | 158 | def send_publish_notification( 159 | document_title, 160 | link, 161 | message, 162 | author_name, 163 | author_email, 164 | ): 165 | if len(document_title) == 0: 166 | document_title = _("Untitled") 167 | message_text = _( 168 | f"Hey {author_name}, the document '{document_title}' has " 169 | "been reviewed and published. " 170 | f"\nOpen the document: {link}", 171 | ) 172 | body_html_intro = _( 173 | f"

Hey {escape(author_name)}
the document '{escape(document_title)}' has " 174 | "been reviewed and published.

", 175 | ) 176 | if len(message): 177 | message_text += _(f"\nMessage from the editor: {message}") 178 | body_html_intro += _( 179 | f"

Message from the editor: {escape(message)}

", 180 | ) 181 | review_document_str = _(f"{escape(document_title)} published") 182 | access_the_document_str = _("Access the Document") 183 | document_str = _("Document") 184 | body_html = ( 185 | f"

{review_document_str}

" 186 | f"{body_html_intro}" 187 | "" 188 | f"" 191 | "
{document_str}" 189 | f"{document_title}" 190 | "
" 192 | f'" 195 | ) 196 | send_mail( 197 | _(f"Document: {escape(document_title)}"), 198 | message_text, 199 | settings.DEFAULT_FROM_EMAIL, 200 | [author_email], 201 | fail_silently=True, 202 | html_message=html_email(body_html), 203 | ) 204 | -------------------------------------------------------------------------------- /fiduswriter/website/static/js/modules/website/website/templates.js: -------------------------------------------------------------------------------- 1 | import {escapeText} from "../../common" 2 | 3 | const publicationOverviewTemplate = ({ 4 | title, 5 | keywords, 6 | authors, 7 | updated, 8 | _added, 9 | abstract, 10 | id 11 | }) => 12 | ` 13 |
${keywords 14 | .map(keyword => `
${escapeText(keyword)}
`) 15 | .join("")}
16 |

${escapeText(title)}

17 |

${updated.slice(0, 10)}

18 |
${authors 19 | .map( 20 | author => 21 | `
${escapeText(author.firstname)}${ 22 | author.lastname ? ` ${author.lastname}` : "" 23 | }
` 24 | ) 25 | .join("")}
26 |
${abstract 27 | .slice(0, 250) 28 | .split("\n") 29 | .map(part => `

${escapeText(part)}

`) 30 | .join("")}
31 |
` 32 | 33 | export const articleBodyTemplate = ({_user, publication, siteName}) => { 34 | const affiliations = {} 35 | let affCounter = 0 36 | let counter = 0 37 | const authorsOutputs = [] 38 | publication.authors.forEach(author => { 39 | let output = "" 40 | if (author.firstname || author.lastname) { 41 | output += `` 42 | const nameParts = [] 43 | if (author.firstname) { 44 | nameParts.push( 45 | `${escapeText( 46 | author.firstname 47 | )}` 48 | ) 49 | } 50 | if (author.lastname) { 51 | nameParts.push( 52 | `${escapeText( 53 | author.lastname 54 | )}` 55 | ) 56 | } 57 | if (nameParts.length) { 58 | output += `${nameParts.join(" ")}` 59 | } 60 | if (author.institution) { 61 | let affNumber 62 | if (affiliations[author.institution]) { 63 | affNumber = affiliations[author.institution] 64 | } else { 65 | affNumber = ++affCounter 66 | affiliations[author.institution] = affNumber 67 | } 68 | output += `${affNumber}` 69 | } 70 | output += "" 71 | } else if (author.institution) { 72 | // There is an affiliation but no first/last name. We take this 73 | // as a group collaboration. 74 | output += `` 75 | output += `${escapeText( 76 | author.institution 77 | )}` 78 | output += "" 79 | } 80 | authorsOutputs.push(output) 81 | }) 82 | const authors = authorsOutputs.join(", ") 83 | return ` 84 | 95 |
96 |
${publication.keywords 97 | .map( 98 | keyword => 99 | `
${escapeText(keyword)}
` 100 | ) 101 | .join("")}
102 |

${publication.updated.slice(0, 10)}

103 |

${escapeText(publication.title)}

104 | 105 | ${ 106 | Object.keys(affiliations).length 107 | ? `
${Object.entries(affiliations) 108 | .map( 109 | ([name, id]) => 110 | `` 113 | ) 114 | .join("")}
` 115 | : "" 116 | } 117 | ${publication.content} 118 |
` 119 | } 120 | 121 | export const overviewContentTemplate = ({ 122 | keywords, 123 | authors, 124 | publications, 125 | filters 126 | }) => 127 | `
128 |
129 |

${gettext("Keywords")}

130 |
131 | ${keywords 132 | .map( 133 | (keyword, index) => 134 | `${escapeText( 137 | keyword 138 | )}` 139 | ) 140 | .join("")} 141 |
142 |
143 |
144 |

${gettext("Authors")}

145 |
146 | ${authors 147 | .map( 148 | (author, index) => 149 | `${escapeText( 152 | author 153 | )}` 154 | ) 155 | .join("")} 156 |
157 |
158 |
159 |
${publications 160 | .map(publication => publicationOverviewTemplate(publication)) 161 | .join("")}
` 162 | 163 | export const overviewBodyTemplate = ({ 164 | user, 165 | siteName, 166 | publications, 167 | authors, 168 | keywords, 169 | filters 170 | }) => ` 171 | 172 |
173 | ${ 174 | user.is_authenticated 175 | ? `` 178 | : "" 179 | } 180 |

${escapeText(siteName)}

181 |
182 |
183 | ${overviewContentTemplate({keywords, authors, publications, filters})} 184 |
185 | ` 186 | -------------------------------------------------------------------------------- /fiduswriter/website/static/js/modules/website/editor.js: -------------------------------------------------------------------------------- 1 | import {Dialog, addAlert, postJson} from "../common" 2 | import {COMMENT_ONLY_ROLES, READ_ONLY_ROLES} from "../editor" 3 | 4 | import {PublishDoc} from "./publish_doc" 5 | import {submitDialogTemplate} from "./templates" 6 | import {getTextContent} from "./tools" 7 | 8 | import * as plugins from "../../plugins/website" 9 | 10 | // Adds functions for Publishing to the editor 11 | export class EditorWebsite { 12 | constructor(editor) { 13 | this.editor = editor 14 | this.publishUrl = "/api/website/publish_doc/" 15 | this.submission = { 16 | status: "unknown" 17 | } 18 | } 19 | 20 | init() { 21 | this.activateFidusPlugins() 22 | const docData = { 23 | doc_id: this.editor.docInfo.id 24 | } 25 | postJson("/api/website/get_doc_info/", docData) 26 | .then(({json}) => { 27 | this.submission = json["submission"] 28 | this.setupUI() 29 | }) 30 | .catch(error => { 31 | addAlert("error", gettext("Could not obtain submission info.")) 32 | throw error 33 | }) 34 | } 35 | 36 | activateFidusPlugins() { 37 | // Add plugins. 38 | this.plugins = {} 39 | 40 | Object.keys(plugins).forEach(plugin => { 41 | if (typeof plugins[plugin] === "function") { 42 | this.plugins[plugin] = new plugins[plugin](this) 43 | this.plugins[plugin].init() 44 | } 45 | }) 46 | } 47 | 48 | setupUI() { 49 | const websiteMenu = { 50 | title: gettext("Website"), 51 | id: "website", 52 | type: "menu", 53 | tooltip: gettext("Publish to website"), 54 | order: 10, 55 | disabled: editor => editor.docInfo.access_rights !== "write", 56 | content: [ 57 | { 58 | title: 59 | this.submission.user_role === "editor" 60 | ? gettext("Publish") 61 | : gettext("Submit"), 62 | type: "action", 63 | tooltip: 64 | this.submission.user_role === "editor" 65 | ? gettext("Publish, reject or request changes") 66 | : gettext("Submit for publishing to website"), 67 | action: () => { 68 | if (this.submission.user_role === "editor") { 69 | this.publishDialog() 70 | } else { 71 | this.submitDialog() 72 | } 73 | }, 74 | disabled: editor => { 75 | if ( 76 | READ_ONLY_ROLES.includes( 77 | editor.docInfo.access_rights 78 | ) || 79 | COMMENT_ONLY_ROLES.includes( 80 | editor.docInfo.access_rights 81 | ) 82 | ) { 83 | return true 84 | } else { 85 | return false 86 | } 87 | } 88 | } 89 | ] 90 | } 91 | this.addArticleLinkUI(websiteMenu) 92 | this.editor.menu.headerbarModel.content.push(websiteMenu) 93 | if (this.editor.menu.headerView) { 94 | this.editor.menu.headerView.update() 95 | } 96 | return Promise.resolve() 97 | } 98 | 99 | addArticleLinkUI(websiteMenu) { 100 | if ( 101 | this.submission.id && 102 | ["resubmitted", "published"].includes(this.submission.status) && 103 | websiteMenu.content.length < 2 104 | ) { 105 | websiteMenu.content.push({ 106 | title: gettext("View on website"), 107 | type: "action", 108 | tooltip: gettext( 109 | "Go to the last published version on the website." 110 | ), 111 | action: () => { 112 | this.editor.app.goTo(`/article/${this.submission.id}/`) 113 | } 114 | }) 115 | } 116 | } 117 | 118 | submitDialog() { 119 | const buttons = [ 120 | { 121 | text: gettext("Submit"), 122 | classes: "fw-dark", 123 | click: () => { 124 | const message = document 125 | .getElementById("submission-message") 126 | .value.trim() 127 | this.submitDoc({message}).then(() => dialog.close()) 128 | } 129 | }, 130 | { 131 | type: "cancel" 132 | } 133 | ] 134 | 135 | const dialog = new Dialog({ 136 | width: 750, 137 | id: "submission-dialog", 138 | buttons, 139 | title: gettext("Submit document to be published on website"), 140 | body: submitDialogTemplate({ 141 | messages: this.submission.messages, 142 | status: this.submission.status 143 | }) 144 | }) 145 | dialog.open() 146 | } 147 | 148 | submitDoc({message}) { 149 | const docData = { 150 | doc_id: this.editor.docInfo.id, 151 | message 152 | } 153 | return postJson("/api/website/submit_doc/", docData).then(({json}) => { 154 | this.submission.status = json.status 155 | this.submission.messages.push(json.message) 156 | addAlert("info", gettext("Submitted document for publication.")) 157 | }) 158 | } 159 | 160 | // The dialog for a document reviewer. 161 | publishDialog() { 162 | const buttons = [ 163 | { 164 | text: gettext("Publish"), 165 | click: () => { 166 | const message = document 167 | .getElementById("submission-message") 168 | .value.trim() 169 | this.publish(message).then(() => dialog.close()) 170 | }, 171 | classes: "fw-dark" 172 | }, 173 | { 174 | text: gettext("Ask for changes"), 175 | click: () => { 176 | const message = document 177 | .getElementById("submission-message") 178 | .value.trim() 179 | this.review(message).then(() => dialog.close()) 180 | }, 181 | classes: "fw-dark" 182 | }, 183 | { 184 | text: gettext("Reject"), 185 | click: () => { 186 | const message = document 187 | .getElementById("submission-message") 188 | .value.trim() 189 | this.reject(message).then(() => dialog.close()) 190 | }, 191 | classes: "fw-dark" 192 | }, 193 | { 194 | type: "cancel" 195 | } 196 | ], 197 | dialog = new Dialog({ 198 | width: 750, 199 | id: "submission-dialog", 200 | title: gettext("Publish, reject or ask for changes"), 201 | body: submitDialogTemplate({ 202 | messages: this.submission.messages, 203 | status: this.submission.status 204 | }), 205 | buttons 206 | }) 207 | 208 | dialog.open() 209 | } 210 | 211 | publish(message) { 212 | const doc = this.editor.getDoc({changes: "acceptAllNoInsertions"}) 213 | doc.path = "" 214 | const article = doc.content 215 | // remove title 216 | article.content.shift() 217 | // Author field is only used on frontpage. We leave it in to be used on main article page. 218 | const authors = article.content 219 | .filter( 220 | part => part.attrs.metadata === "authors" && !part.attrs.hidden 221 | ) 222 | .map(authorPart => 223 | authorPart.content 224 | ? authorPart.content 225 | .filter( 226 | author => 227 | !author.marks || 228 | !author.marks.find( 229 | mark => mark.type === "deletion" 230 | ) 231 | ) 232 | .map(author => author.attrs) 233 | : [] 234 | ) 235 | .flat() 236 | if (authors.length) { 237 | // remove authors from document 238 | article.content = article.content.filter( 239 | part => part.attrs.metadata !== "authors" 240 | ) 241 | } else { 242 | if (this.submission.submitter) { 243 | authors.push(this.submission.submitter) 244 | } else { 245 | const author = { 246 | firstname: 247 | this.editor.user.first_name || this.editor.user.name 248 | } 249 | if (this.editor.user.last_name.length) { 250 | author.lastname = this.editor.user.last_name 251 | } 252 | const email = this.editor.user.emails.find( 253 | email => email.primary 254 | )?.address 255 | if (email) { 256 | author.email = email 257 | } 258 | authors.push(author) 259 | } 260 | } 261 | const keywords = article.content 262 | .filter( 263 | part => part.attrs.metadata === "keywords" && !part.attrs.hidden 264 | ) 265 | .map(keywordPart => 266 | keywordPart.content 267 | ? keywordPart.content 268 | .filter( 269 | keyword => 270 | !keyword.marks || 271 | !keyword.marks.find( 272 | mark => mark.type === "deletion" 273 | ) 274 | ) 275 | .map(keyword => keyword.attrs.tag) 276 | : [] 277 | ) 278 | .flat() 279 | 280 | // remove keywords 281 | article.content = article.content.filter( 282 | part => part.attrs.metadata !== "keywords" 283 | ) 284 | 285 | // Abstract field is only used on front page. We leave it in to be used on the main article page. 286 | let abstract = article.content 287 | .filter( 288 | part => part.attrs.metadata === "abstract" && !part.attrs.hidden 289 | ) 290 | .map(part => getTextContent(part)) 291 | .join("") 292 | .replace(/(^\s*)|(\s*$)/gi, "") 293 | .replace(/[ ]{2,}/gi, " ") 294 | .replace(/\n /, "\n") 295 | .replace(/\n{2,}/gi, "\n") 296 | .trim() 297 | 298 | if (!abstract.length) { 299 | // There was no usable abstract text included. Use instead 500 chars 300 | // of other content, except for the title. 301 | abstract = article.content 302 | .slice(1) 303 | .map(part => getTextContent(part)) 304 | .join("") 305 | .replace(/(^\s*)|(\s*$)/gi, "") 306 | .replace(/[ ]{2,}/gi, " ") 307 | .replace(/\n /, "\n") 308 | .replace(/\n{2,}/gi, "\n") 309 | .trim() 310 | abstract = abstract.slice(0, 500) 311 | } 312 | 313 | const publisher = new PublishDoc( 314 | this.publishUrl, 315 | this.editor.user, 316 | message, 317 | authors, 318 | keywords, 319 | abstract, 320 | doc, 321 | this.editor.mod.db.bibDB, 322 | this.editor.mod.db.imageDB, 323 | this.editor.app.csl, 324 | this.editor.docInfo.updated, 325 | this.editor.mod.documentTemplate.documentStyles 326 | ) 327 | return publisher.init().then(({json}) => { 328 | this.submission.status = json.status 329 | this.submission.id = json.id 330 | this.submission.messages.push(json.message) 331 | addAlert("info", gettext("Published document.")) 332 | const websiteMenu = this.editor.menu.headerbarModel.content.find( 333 | menu => menu.id === "website" 334 | ) 335 | if (websiteMenu) { 336 | this.addArticleLinkUI(websiteMenu) 337 | } 338 | }) 339 | } 340 | 341 | reject(message) { 342 | return postJson("/api/website/reject_doc/", { 343 | doc_id: this.editor.docInfo.id, 344 | message 345 | }).then(({json}) => { 346 | this.submission.status = json.status 347 | this.submission.messages.push(json.message) 348 | addAlert( 349 | "info", 350 | gettext("Publication of document has been rejected.") 351 | ) 352 | }) 353 | } 354 | 355 | review(message) { 356 | return postJson("/api/website/review_doc/", { 357 | doc_id: this.editor.docInfo.id, 358 | message 359 | }).then(({json}) => { 360 | this.submission.messages.push(json.message) 361 | addAlert( 362 | "info", 363 | gettext( 364 | "Document has been reviewed. Request for changes has been sent." 365 | ) 366 | ) 367 | }) 368 | } 369 | } 370 | -------------------------------------------------------------------------------- /fiduswriter/website/tests/test_website.py: -------------------------------------------------------------------------------- 1 | import time 2 | import os 3 | import sys 4 | from tempfile import mkdtemp 5 | 6 | from selenium.webdriver.common.by import By 7 | from selenium.webdriver.support.wait import WebDriverWait 8 | from selenium.webdriver.support import expected_conditions as EC 9 | from channels.testing import ChannelsLiveServerTestCase 10 | from testing.selenium_helper import SeleniumHelper 11 | from testing.mail import get_outbox, empty_outbox, delete_outbox 12 | 13 | from django.contrib.auth.models import Group 14 | from django.test import override_settings 15 | 16 | 17 | MAIL_STORAGE_NAME = "website" 18 | 19 | 20 | @override_settings(MAIL_STORAGE_NAME=MAIL_STORAGE_NAME) 21 | @override_settings(EMAIL_BACKEND="testing.mail.EmailBackend") 22 | class WebsiteTest(SeleniumHelper, ChannelsLiveServerTestCase): 23 | fixtures = [ 24 | "initial_documenttemplates.json", 25 | "initial_styles.json", 26 | ] 27 | login_page = "/documents/" 28 | 29 | @classmethod 30 | def setUpClass(cls): 31 | super().setUpClass() 32 | cls.base_url = cls.live_server_url 33 | cls.download_dir = mkdtemp() 34 | driver_data = cls.get_drivers(1, cls.download_dir) 35 | cls.driver = driver_data["drivers"][0] 36 | cls.client = driver_data["clients"][0] 37 | cls.driver.implicitly_wait(driver_data["wait_time"]) 38 | cls.wait_time = driver_data["wait_time"] 39 | 40 | @classmethod 41 | def tearDownClass(cls): 42 | cls.driver.quit() 43 | os.rmdir(cls.download_dir) 44 | delete_outbox(MAIL_STORAGE_NAME) 45 | super().tearDownClass() 46 | 47 | def setUp(self): 48 | self.user = self.create_user( 49 | username="user", 50 | email="user@sciencenewsportal.com", 51 | passtext="otter1", 52 | ) 53 | self.editor = self.create_user( 54 | username="editor", 55 | email="editor@sciencenewsportal.com", 56 | passtext="otter1", 57 | ) 58 | editor_group = Group.objects.get(name="Website Editors") 59 | self.editor.groups.add(editor_group) 60 | 61 | def tearDown(self): 62 | self.driver.execute_script("window.localStorage.clear()") 63 | self.driver.execute_script("window.sessionStorage.clear()") 64 | super().tearDown() 65 | empty_outbox(MAIL_STORAGE_NAME) 66 | if "coverage" in sys.modules.keys(): 67 | # Cool down 68 | time.sleep(self.wait_time / 3) 69 | 70 | def outbox(self): 71 | return get_outbox(MAIL_STORAGE_NAME) 72 | 73 | def test_website(self): 74 | self.login_user(self.user, self.driver, self.client) 75 | self.driver.get(self.base_url + "/documents/") 76 | # Create news article 1 77 | WebDriverWait(self.driver, self.wait_time).until( 78 | EC.element_to_be_clickable( 79 | (By.CSS_SELECTOR, ".new_document button") 80 | ) 81 | ).click() 82 | WebDriverWait(self.driver, self.wait_time).until( 83 | EC.presence_of_element_located((By.CLASS_NAME, "editor-toolbar")) 84 | ) 85 | self.driver.find_element(By.CSS_SELECTOR, ".doc-title").click() 86 | self.driver.find_element(By.CSS_SELECTOR, ".doc-title").send_keys( 87 | "News article 1" 88 | ) 89 | self.driver.find_element( 90 | By.CSS_SELECTOR, "span.header-nav-item[title='Publish to website']" 91 | ).click() 92 | self.driver.find_element( 93 | By.CSS_SELECTOR, 94 | "span.fw-pulldown-item[title='Submit for publishing to website']", 95 | ).click() 96 | self.driver.find_element( 97 | By.CSS_SELECTOR, "textarea#submission-message" 98 | ).click() 99 | submission_message = "This article is ready for publication." 100 | self.driver.find_element( 101 | By.CSS_SELECTOR, "textarea#submission-message" 102 | ).send_keys(submission_message) 103 | emails_before_submission = len(self.outbox()) 104 | self.driver.find_element(By.CSS_SELECTOR, "button.fw-dark").click() 105 | time.sleep(1) 106 | # Check that email has been sent to editor 107 | emails_after_submission = len(self.outbox()) 108 | self.assertEqual( 109 | emails_after_submission, (emails_before_submission + 1) 110 | ) 111 | notify_editor_email = self.outbox()[-1] 112 | assert self.editor.email in notify_editor_email.to 113 | assert submission_message in notify_editor_email.body 114 | assert "submitted to be published" in notify_editor_email.body 115 | 116 | # Log in as editor and ask for changes. 117 | self.login_user(self.editor, self.driver, self.client) 118 | document_link = self.find_urls(notify_editor_email.body)[0] 119 | self.driver.get(document_link) 120 | self.driver.find_element( 121 | By.CSS_SELECTOR, "span.header-nav-item[title='Publish to website']" 122 | ).click() 123 | self.driver.find_element( 124 | By.CSS_SELECTOR, 125 | "span.fw-pulldown-item[title='Publish, reject or request changes']", 126 | ).click() 127 | review_message = self.driver.find_element( 128 | By.CSS_SELECTOR, "#submission-dialog" 129 | ) 130 | assert submission_message in review_message.text 131 | self.driver.find_element( 132 | By.CSS_SELECTOR, "textarea#submission-message" 133 | ).click() 134 | editor_message = "It's good, but not quite good enough." 135 | self.driver.find_element( 136 | By.CSS_SELECTOR, "textarea#submission-message" 137 | ).send_keys(editor_message) 138 | emails_before_ask_for_changes = len(self.outbox()) 139 | self.driver.find_elements(By.CSS_SELECTOR, "button.fw-dark")[1].click() 140 | time.sleep(1) 141 | # Check that email has been sent to user 142 | emails_after_ask_for_changes = len(self.outbox()) 143 | assert emails_after_ask_for_changes == ( 144 | emails_before_ask_for_changes + 1 145 | ) 146 | notify_user_email = self.outbox()[-1] 147 | assert self.user.email in notify_user_email.to 148 | assert editor_message in notify_user_email.body 149 | assert "need to change some things" in notify_user_email.body 150 | 151 | # Log in as user, make changes and resubmit. 152 | self.login_user(self.user, self.driver, self.client) 153 | document_link = self.find_urls(notify_user_email.body)[0] 154 | self.driver.get(document_link) 155 | self.driver.find_element(By.CSS_SELECTOR, ".doc-body").click() 156 | self.driver.find_element(By.CSS_SELECTOR, ".doc-body").send_keys( 157 | "An updated body." 158 | ) 159 | self.driver.find_element( 160 | By.CSS_SELECTOR, "span.header-nav-item[title='Publish to website']" 161 | ).click() 162 | self.driver.find_element( 163 | By.CSS_SELECTOR, 164 | "span.fw-pulldown-item[title='Submit for publishing to website']", 165 | ).click() 166 | review_message = self.driver.find_element( 167 | By.CSS_SELECTOR, "#submission-dialog" 168 | ) 169 | assert submission_message in review_message.text 170 | assert editor_message in review_message.text 171 | self.driver.find_element( 172 | By.CSS_SELECTOR, "textarea#submission-message" 173 | ).click() 174 | resubmission_message = "I've made substantial changes. Please review." 175 | self.driver.find_element( 176 | By.CSS_SELECTOR, "textarea#submission-message" 177 | ).send_keys(resubmission_message) 178 | emails_before_resubmission = len(self.outbox()) 179 | self.driver.find_element(By.CSS_SELECTOR, "button.fw-dark").click() 180 | time.sleep(1) 181 | # Check that email has been sent to editor 182 | emails_after_resubmission = len(self.outbox()) 183 | assert emails_after_resubmission == (emails_before_resubmission + 1) 184 | notify_editor_again_email = self.outbox()[-1] 185 | assert self.editor.email in notify_editor_again_email.to 186 | assert resubmission_message in notify_editor_again_email.body 187 | assert "submitted to be published" in notify_editor_again_email.body 188 | 189 | # Log in as editor and reject. 190 | self.login_user(self.editor, self.driver, self.client) 191 | document_link = self.find_urls(notify_editor_email.body)[0] 192 | self.driver.get(document_link) 193 | self.driver.find_element( 194 | By.CSS_SELECTOR, "span.header-nav-item[title='Publish to website']" 195 | ).click() 196 | self.driver.find_element( 197 | By.CSS_SELECTOR, 198 | "span.fw-pulldown-item[title='Publish, reject or request changes']", 199 | ).click() 200 | review_message = self.driver.find_element( 201 | By.CSS_SELECTOR, "#submission-dialog" 202 | ) 203 | assert submission_message in review_message.text 204 | assert editor_message in review_message.text 205 | assert resubmission_message in review_message.text 206 | self.driver.find_element( 207 | By.CSS_SELECTOR, "textarea#submission-message" 208 | ).click() 209 | rejection_message = "I don't think you realize what a serious we are. This submission has been rejected." 210 | self.driver.find_element( 211 | By.CSS_SELECTOR, "textarea#submission-message" 212 | ).send_keys(rejection_message) 213 | emails_before_rejection = len(self.outbox()) 214 | self.driver.find_elements(By.CSS_SELECTOR, "button.fw-dark")[2].click() 215 | time.sleep(1) 216 | # Check that email has been sent to editor 217 | emails_after_rejection = len(self.outbox()) 218 | assert emails_after_rejection == (emails_before_rejection + 1) 219 | notify_user_again_email = self.outbox()[-1] 220 | assert self.user.email in notify_user_again_email.to 221 | assert rejection_message in notify_user_again_email.body 222 | assert "reviewed and rejected" in notify_user_again_email.body 223 | 224 | # Check that article does not show on front page 225 | self.logout_user(self.driver, self.client) 226 | self.driver.get(self.base_url + "/") 227 | articles_shown = self.driver.find_elements( 228 | By.CSS_SELECTOR, "div.articles a.article" 229 | ) 230 | assert len(articles_shown) == 0 231 | 232 | # Write a second article. 233 | self.login_user(self.user, self.driver, self.client) 234 | self.driver.get(self.base_url + "/documents/") 235 | # Create news article 2 236 | WebDriverWait(self.driver, self.wait_time).until( 237 | EC.element_to_be_clickable( 238 | (By.CSS_SELECTOR, ".new_document button") 239 | ) 240 | ).click() 241 | WebDriverWait(self.driver, self.wait_time).until( 242 | EC.presence_of_element_located((By.CLASS_NAME, "editor-toolbar")) 243 | ) 244 | self.driver.find_element(By.CSS_SELECTOR, ".doc-title").click() 245 | self.driver.find_element(By.CSS_SELECTOR, ".doc-title").send_keys( 246 | "News article 2" 247 | ) 248 | self.driver.find_element(By.CSS_SELECTOR, ".doc-body").click() 249 | self.driver.find_element(By.CSS_SELECTOR, ".doc-body").send_keys( 250 | "This article has a real body." 251 | ) 252 | self.driver.find_element( 253 | By.CSS_SELECTOR, "span.header-nav-item[title='Publish to website']" 254 | ).click() 255 | self.driver.find_element( 256 | By.CSS_SELECTOR, 257 | "span.fw-pulldown-item[title='Submit for publishing to website']", 258 | ).click() 259 | self.driver.find_element( 260 | By.CSS_SELECTOR, "textarea#submission-message" 261 | ).click() 262 | submission_message = "This article is ready for publication and much better than the previous one." 263 | self.driver.find_element( 264 | By.CSS_SELECTOR, "textarea#submission-message" 265 | ).send_keys(submission_message) 266 | emails_before_submission = len(self.outbox()) 267 | self.driver.find_element(By.CSS_SELECTOR, "button.fw-dark").click() 268 | time.sleep(1) 269 | # Check that email has been sent to editor 270 | emails_after_submission = len(self.outbox()) 271 | assert emails_after_submission == (emails_before_submission + 1) 272 | notify_editor_email = self.outbox()[-1] 273 | assert self.editor.email in notify_editor_email.to 274 | assert submission_message in notify_editor_email.body 275 | assert "submitted to be published" in notify_editor_email.body 276 | 277 | # Log in as editor and publish. 278 | self.login_user(self.editor, self.driver, self.client) 279 | document_link = self.find_urls(notify_editor_email.body)[0] 280 | self.driver.get(document_link) 281 | self.driver.find_element( 282 | By.CSS_SELECTOR, "span.header-nav-item[title='Publish to website']" 283 | ).click() 284 | self.driver.find_element( 285 | By.CSS_SELECTOR, 286 | "span.fw-pulldown-item[title='Publish, reject or request changes']", 287 | ).click() 288 | review_message = self.driver.find_element( 289 | By.CSS_SELECTOR, "#submission-dialog" 290 | ) 291 | assert submission_message in review_message.text 292 | self.driver.find_element( 293 | By.CSS_SELECTOR, "textarea#submission-message" 294 | ).click() 295 | editor_message = "It's good, really good. I'll publish it right away." 296 | self.driver.find_element( 297 | By.CSS_SELECTOR, "textarea#submission-message" 298 | ).send_keys(editor_message) 299 | emails_before_publishing = len(self.outbox()) 300 | self.driver.find_elements(By.CSS_SELECTOR, "button.fw-dark")[0].click() 301 | time.sleep(1) 302 | # Check that email has been sent to user 303 | emails_after_publishing = len(self.outbox()) 304 | assert emails_after_publishing == (emails_before_publishing + 1) 305 | notify_user_email = self.outbox()[-1] 306 | assert self.user.email in notify_user_email.to 307 | assert editor_message in notify_user_email.body 308 | 309 | # Check that article does show on front page 310 | self.logout_user(self.driver, self.client) 311 | self.driver.get(self.base_url + "/") 312 | articles_shown = self.driver.find_elements( 313 | By.CSS_SELECTOR, "div.articles a.article" 314 | ) 315 | assert len(articles_shown) == 1 316 | 317 | # Log in as editor and publish directly. 318 | self.login_user(self.editor, self.driver, self.client) 319 | self.driver.get(self.base_url + "/documents/") 320 | # Create news article 1 321 | WebDriverWait(self.driver, self.wait_time).until( 322 | EC.element_to_be_clickable( 323 | (By.CSS_SELECTOR, ".new_document button") 324 | ) 325 | ).click() 326 | WebDriverWait(self.driver, self.wait_time).until( 327 | EC.presence_of_element_located((By.CLASS_NAME, "editor-toolbar")) 328 | ) 329 | self.driver.find_element(By.CSS_SELECTOR, ".doc-title").click() 330 | self.driver.find_element(By.CSS_SELECTOR, ".doc-title").send_keys( 331 | "News article 3" 332 | ) 333 | self.driver.find_element( 334 | By.CSS_SELECTOR, "span.header-nav-item[title='Publish to website']" 335 | ).click() 336 | self.driver.find_element( 337 | By.CSS_SELECTOR, 338 | "span.fw-pulldown-item[title='Publish, reject or request changes']", 339 | ).click() 340 | emails_before_publishing = len(self.outbox()) 341 | self.driver.find_elements(By.CSS_SELECTOR, "button.fw-dark")[0].click() 342 | time.sleep(1) 343 | # Check that no email has been sent to user 344 | emails_after_publishing = len(self.outbox()) 345 | assert emails_after_publishing == emails_before_publishing 346 | 347 | # Check that article does show on front page 348 | self.logout_user(self.driver, self.client) 349 | self.driver.get(self.base_url + "/") 350 | articles_shown = self.driver.find_elements( 351 | By.CSS_SELECTOR, "div.articles a.article" 352 | ) 353 | assert len(articles_shown) == 2 354 | -------------------------------------------------------------------------------- /fiduswriter/website/views.py: -------------------------------------------------------------------------------- 1 | import json 2 | import time 3 | import zipfile 4 | 5 | from django.contrib.auth.decorators import login_required 6 | from django.db.models import Q 7 | from django.contrib.auth.models import Permission 8 | from django.contrib.contenttypes.models import ContentType 9 | from django.contrib.sites.shortcuts import get_current_site 10 | from django.core.files.base import ContentFile 11 | from django.http import HttpRequest 12 | from django.http import HttpResponse 13 | from django.http import JsonResponse 14 | from django.views.decorators.http import require_POST 15 | from document.models import AccessRight 16 | from document.models import Document 17 | from django.core.paginator import Paginator 18 | 19 | from user.models import User 20 | from . import emails 21 | from . import models 22 | 23 | 24 | @login_required 25 | @require_POST 26 | def get_doc_info(request): 27 | response = {} 28 | document_id = int(request.POST.get("doc_id")) 29 | document = Document.objects.filter(id=document_id).first() 30 | if not document: 31 | return HttpResponse("Not found", status=404) 32 | if ( 33 | document.owner != request.user 34 | and not AccessRight.objects.filter( 35 | document=document, 36 | user=request.user, 37 | ).first() 38 | ): 39 | # Access forbidden 40 | return HttpResponse("Missing access rights", status=403) 41 | response["submission"] = {} 42 | publication = models.Publication.objects.filter( 43 | document_id=document_id, 44 | ).first() 45 | if publication: 46 | response["submission"]["status"] = publication.status 47 | submitter = { 48 | "email": publication.submitter.email, 49 | } 50 | if len(publication.submitter.first_name) > 0: 51 | submitter["firstname"] = publication.submitter.first_name 52 | else: 53 | submitter["firstname"] = publication.submitter.username 54 | if len(publication.submitter.last_name) > 0: 55 | submitter["lastname"] = publication.submitter.last_name 56 | response["submission"]["submitter"] = submitter 57 | response["submission"]["messages"] = publication.messages 58 | response["submission"]["id"] = publication.id 59 | else: 60 | response["submission"]["status"] = "unsubmitted" 61 | response["submission"]["messages"] = [] 62 | if request.user.has_perm( 63 | "website.add_publication", 64 | ): 65 | user_role = "editor" 66 | else: 67 | user_role = "author" 68 | response["submission"]["user_role"] = user_role 69 | status = 200 70 | return JsonResponse(response, status=status) 71 | 72 | 73 | @login_required 74 | @require_POST 75 | def submit_doc(request): 76 | response = {} 77 | document_id = int(request.POST.get("doc_id")) 78 | status = 200 79 | document = Document.objects.filter(id=document_id).first() 80 | if not document: 81 | return HttpResponse("Not found", status=404) 82 | if ( 83 | document.owner != request.user 84 | and not AccessRight.objects.filter( 85 | document=document, 86 | user=request.user, 87 | ).first() 88 | ): 89 | # Access forbidden 90 | return HttpResponse("Missing document access rights", status=403) 91 | publication, created = models.Publication.objects.get_or_create( 92 | document_id=document_id, 93 | defaults={"submitter": request.user, "status": "submitted"}, 94 | ) 95 | if ( 96 | publication.status == "published" 97 | and not created 98 | and request.user.has_perm("website.change_publication") 99 | ): 100 | # The user has permission to publish the document immediately. 101 | publication.title = request.POST.get("title") 102 | publication.abstract = request.POST.get("abstract") 103 | publication.authors = json.loads(request.POST.get("authors")) 104 | publication.keywords = request.POST.getlist("keywords[]") 105 | # Delete all existing assets 106 | models.PublicationAsset.objects.filter( 107 | publication=publication, 108 | ).delete() 109 | html_zip = zipfile.ZipFile(request.FILES.get("html.zip")) 110 | body_html = html_zip.open("document.html").read().decode("utf-8") 111 | publication.html_src = body_html 112 | publication.status = "published" 113 | message = { 114 | "type": "publish", 115 | "message": request.POST.get("message"), 116 | "user": request.user.readable_name, 117 | "time": time.time(), 118 | } 119 | publication.messages.append(message) 120 | response["message"] = message 121 | publication.save() 122 | response["status"] = publication.status 123 | return JsonResponse(response, status=status) 124 | message = { 125 | "type": "submit", 126 | "message": request.POST.get("message"), 127 | "user": request.user.readable_name, 128 | "time": time.time(), 129 | } 130 | publication.messages.append(message) 131 | response["message"] = message 132 | if created: 133 | codename = "add_publication" 134 | else: 135 | if publication.status in ["published", "resubmitted"]: 136 | publication.status = "resubmitted" 137 | codename = "change_publication" 138 | else: 139 | publication.status = "submitted" 140 | codename = "add_publication" 141 | publication.save() 142 | link = HttpRequest.build_absolute_uri(request, document.get_absolute_url()) 143 | user_ct = ContentType.objects.get(app_label="user", model="user") 144 | perm = Permission.objects.filter( 145 | content_type__app_label="website", codename=codename 146 | ).first() 147 | for editor in User.objects.filter( 148 | Q(user_permissions=perm) 149 | | Q(groups__permissions=perm) 150 | | Q(is_superuser=True) 151 | ): 152 | if editor == document.owner or editor == request.user: 153 | continue 154 | access_right, created = AccessRight.objects.get_or_create( 155 | document_id=document_id, 156 | holder_id=editor.id, 157 | holder_type=user_ct, 158 | defaults={ 159 | "rights": "write", 160 | }, 161 | ) 162 | if not created and access_right.rights != "write": 163 | access_right.rights = "write" 164 | access_right.save() 165 | emails.send_submit_notification( 166 | document.title, 167 | link, 168 | request.POST.get("message"), 169 | editor.readable_name, 170 | editor.email, 171 | ) 172 | response["status"] = publication.status 173 | return JsonResponse(response, status=status) 174 | 175 | 176 | @login_required 177 | @require_POST 178 | def reject_doc(request): 179 | response = {} 180 | if not ( 181 | request.user.has_perm("website.add_publication") 182 | or request.user.has_perm("website.change_publication") 183 | ): 184 | # Access forbidden 185 | return HttpResponse("Missing access rights", status=403) 186 | document_id = int(request.POST.get("doc_id")) 187 | document = Document.objects.filter(id=document_id).first() 188 | if not document: 189 | return HttpResponse("Not found", status=404) 190 | if ( 191 | document.owner != request.user 192 | and not AccessRight.objects.filter( 193 | document=document, 194 | user=request.user, 195 | ).first() 196 | ): 197 | # Access forbidden 198 | return HttpResponse("Missing document access rights", status=403) 199 | status = 200 200 | if request.user.has_perm("website.add_publication"): 201 | publication, created = models.Publication.objects.get_or_create( 202 | document_id=document_id, 203 | defaults={"submitter": request.user, "status": "rejected"}, 204 | ) 205 | else: 206 | publication = models.Publication.objects.filter( 207 | document_id=document_id, 208 | ).first() 209 | if not publication: 210 | # Access forbidden 211 | return HttpResponse("Missing document access rights", status=403) 212 | created = False 213 | if not created: 214 | publication.status = "rejected" 215 | message = { 216 | "type": "reject", 217 | "message": request.POST.get("message"), 218 | "user": request.user.readable_name, 219 | "time": time.time(), 220 | } 221 | publication.messages.append(message) 222 | publication.save() 223 | response["message"] = message 224 | response["status"] = publication.status 225 | if document.owner != request.user: 226 | emails.send_reject_notification( 227 | document.title, 228 | HttpRequest.build_absolute_uri( 229 | request, document.get_absolute_url() 230 | ), 231 | request.POST.get("message"), 232 | document.owner.readable_name, 233 | document.owner.email, 234 | ) 235 | return JsonResponse(response, status=status) 236 | 237 | 238 | @login_required 239 | @require_POST 240 | def review_doc(request): 241 | response = {} 242 | if not ( 243 | request.user.has_perm("website.add_publication") 244 | or request.user.has_perm("website.change_publication") 245 | ): 246 | # Access forbidden 247 | return HttpResponse("Missing access rights", status=403) 248 | document_id = int(request.POST.get("doc_id")) 249 | document = Document.objects.filter(id=document_id).first() 250 | if not document: 251 | return HttpResponse("Not found", status=404) 252 | if ( 253 | document.owner != request.user 254 | and not AccessRight.objects.filter( 255 | document=document, 256 | user=request.user, 257 | ).first() 258 | ): 259 | # Access forbidden 260 | return HttpResponse("Missing access rights", status=403) 261 | status = 200 262 | if request.user.has_perm("website.add_publication"): 263 | publication, _created = models.Publication.objects.get_or_create( 264 | document_id=document_id, 265 | defaults={"submitter": request.user, "status": "unsubmitted"}, 266 | ) 267 | else: 268 | publication = models.Publication.objects.filter( 269 | document_id=document_id, 270 | ).first() 271 | if not publication: 272 | # Access forbidden 273 | return HttpResponse("Missing access rights", status=403) 274 | message = { 275 | "type": "review", 276 | "message": request.POST.get("message"), 277 | "user": request.user.readable_name, 278 | "time": time.time(), 279 | } 280 | publication.messages.append(message) 281 | publication.save() 282 | response["message"] = message 283 | if document.owner != request.user: 284 | emails.send_review_notification( 285 | document.title, 286 | HttpRequest.build_absolute_uri( 287 | request, document.get_absolute_url() 288 | ), 289 | request.POST.get("message"), 290 | document.owner.readable_name, 291 | document.owner.email, 292 | ) 293 | return JsonResponse(response, status=status) 294 | 295 | 296 | @login_required 297 | @require_POST 298 | def publish_doc(request): 299 | response = {} 300 | if not ( 301 | request.user.has_perm("website.add_publication") 302 | or request.user.has_perm("website.change_publication") 303 | ): 304 | # Access forbidden 305 | return HttpResponse("Missing access rights", status=403) 306 | document_id = int(request.POST.get("doc_id")) 307 | document = Document.objects.filter(id=document_id).first() 308 | if not document: 309 | return HttpResponse("Not found", status=404) 310 | if ( 311 | document.owner != request.user 312 | and not AccessRight.objects.filter( 313 | document=document, 314 | user=request.user, 315 | rights="write", 316 | ).first() 317 | ): 318 | # Access forbidden 319 | return HttpResponse("Missing document access rights", status=403) 320 | if request.user.has_perm("website.add_publication"): 321 | publication, created = models.Publication.objects.get_or_create( 322 | document_id=document_id, 323 | defaults={"submitter_id": request.user.id}, 324 | ) 325 | else: 326 | publication = models.Publication.objects.filter( 327 | document_id=document_id, 328 | ) 329 | if not publication: 330 | # Access forbidden 331 | return HttpResponse("Missing access rights", status=403) 332 | publication.title = request.POST.get("title") 333 | publication.abstract = request.POST.get("abstract") 334 | publication.authors = json.loads(request.POST.get("authors")) 335 | publication.keywords = request.POST.getlist("keywords[]") 336 | # Delete all existing assets 337 | models.PublicationAsset.objects.filter(publication=publication).delete() 338 | html_zip = zipfile.ZipFile(request.FILES.get("html.zip")) 339 | body_html = html_zip.open("document.html").read().decode("utf-8") 340 | publication.html_src = body_html 341 | publication.status = "published" 342 | message = { 343 | "type": "publish", 344 | "message": request.POST.get("message"), 345 | "user": request.user.readable_name, 346 | "time": time.time(), 347 | } 348 | publication.messages.append(message) 349 | response["message"] = message 350 | publication.save() 351 | 352 | # Iterate over document files 353 | for filepath in html_zip.namelist(): 354 | if ( 355 | filepath.endswith("/") 356 | or filepath == "document.html" 357 | or filepath not in body_html 358 | ): 359 | continue 360 | file = ContentFile( 361 | html_zip.open(filepath).read(), 362 | name=filepath.split("/")[-1], 363 | ) 364 | asset = models.PublicationAsset.objects.create( 365 | publication=publication, 366 | file=file, 367 | filepath=filepath, 368 | ) 369 | body_html = body_html.replace(filepath, asset.file.url) 370 | 371 | # Save html with adjusted links to media files with publication. 372 | publication.html_output = body_html 373 | publication.save() 374 | 375 | response["status"] = publication.status 376 | response["id"] = publication.id 377 | status = 200 378 | if document.owner != request.user: 379 | emails.send_publish_notification( 380 | document.title, 381 | HttpRequest.build_absolute_uri( 382 | request, document.get_absolute_url() 383 | ), 384 | request.POST.get("message"), 385 | document.owner.readable_name, 386 | document.owner.email, 387 | ) 388 | return JsonResponse(response, status=status) 389 | 390 | 391 | def list_publications(request, per_page=False, page_number=1): 392 | publications = models.Publication.objects.filter( 393 | status="published", 394 | ).order_by( 395 | "-added", 396 | ) 397 | response = {} 398 | if per_page: 399 | paginator = Paginator(publications, per_page) 400 | page = paginator.get_page(page_number) 401 | publications = page.object_list 402 | response["num_pages"] = paginator.num_pages 403 | 404 | response["publications"] = [ 405 | { 406 | "title": pub.title, 407 | "abstract": pub.abstract, 408 | "keywords": pub.keywords, 409 | "authors": pub.authors, 410 | "id": pub.id, 411 | "doc_id": pub.document_id, 412 | "added": pub.added, 413 | "updated": pub.updated, 414 | } 415 | for pub in publications 416 | ] 417 | response["site_name"] = get_current_site(request).name 418 | return JsonResponse(response, status=200) 419 | 420 | 421 | def get_publication(request, id): 422 | pub = models.Publication.objects.filter(id=id).first() 423 | response = {} 424 | response["site_name"] = get_current_site(request).name 425 | if pub: 426 | publication = { 427 | "title": pub.title, 428 | "authors": pub.authors, 429 | "keywords": pub.keywords, 430 | "added": pub.added, 431 | "updated": pub.updated, 432 | "content": pub.html_output, 433 | } 434 | 435 | document = pub.document 436 | if not request.user.is_anonymous and ( 437 | document.owner == request.user 438 | or AccessRight.objects.filter( 439 | document=document, 440 | user=request.user, 441 | ).first() 442 | ): 443 | # Has access right 444 | publication["can_edit"] = True 445 | else: 446 | publication["can_edit"] = False 447 | publication["doc_id"] = pub.document_id 448 | response["publication"] = publication 449 | return JsonResponse(response, status=200) 450 | 451 | 452 | def get_style(request): 453 | response = {} 454 | design = models.Design.objects.filter( 455 | site__id=get_current_site(request).id 456 | ).first() 457 | if design: 458 | response["style"] = design.style 459 | return JsonResponse(response, status=200) 460 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published by 637 | the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | --------------------------------------------------------------------------------