-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nigel van Keulen | Goodadvice-IT
committed
Feb 20, 2024
0 parents
commit cd5ff3a
Showing
36 changed files
with
1,228 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"workbench.colorTheme": "One Dark Modern" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include LICENSE | ||
include README.md | ||
recursive-include wagtail_word/static * | ||
recursive-include wagtail_word/templates * | ||
recursive-include wagtail_word/locale * | ||
recursive-include wagtail_word/migrations * | ||
recursive-include wagtail_word/templatetags * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
wagtail_word | ||
============ | ||
|
||
A Wagtail module to display Word documents in the frontend. | ||
Converts your word documents to richtext for easy editing in the Wagtail admin. | ||
|
||
**Currently supported filetypes:** | ||
- .docx | ||
- .doc | ||
|
||
**Currently supported content:** | ||
- Text (Bold, underlines, italic, strikethrough) | ||
- Text suports colors with allow_styling=True | ||
- Colors get reset after saving the page in Wagtail admin for a second time. | ||
- Images | ||
- Tables | ||
- Hyperlinks | ||
- Lists | ||
- All will be converted to bullet points | ||
- Single level lists only | ||
|
||
Quick start | ||
----------- | ||
|
||
1. Add 'wagtail_word' to your INSTALLED_APPS setting like this: | ||
|
||
``` | ||
INSTALLED_APPS = [ | ||
..., | ||
'wagtail_word', | ||
] | ||
``` | ||
2. Simply go to your Wagtail Admin. | ||
3. Create a new Word Page. | ||
4. Upload a file in the File field. | ||
5. Save or publish the page and see the magic! | ||
|
||
Base Class | ||
----------- | ||
We provide a base class to extend from. This class will provide you a predefined FieldPanel for the File, has the allow_styling attribute and a custom method to set the content to the right field for you to override. | ||
|
||
```python | ||
# Example class | ||
class WordDocumentPage(BaseWordDocumentPage): | ||
template = 'wagtail_word/page.html' | ||
|
||
content = RichTextField( | ||
blank=True, | ||
null=True, | ||
features=[ | ||
# Minimal required features for richtext | ||
"h1", "h2", "h3", "h4", "h5", "h6", | ||
"bold", "italic", "ol", "ul", "link" "image", "embed", | ||
"blockquote", | ||
] | ||
) | ||
|
||
edit_panels = [ | ||
FieldPanel('content'), | ||
] | ||
|
||
edit_handler = TabbedInterface([ | ||
ObjectList(BaseWordDocumentPage.content_panels, heading=_('Upload')), | ||
ObjectList(edit_panels, heading=_('Edit')), | ||
... | ||
]) | ||
|
||
# Override this method to set the content to the right field | ||
def set_content(self, content: str): | ||
self.content = content | ||
|
||
``` |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
$ProjectName = "wagtail_word" | ||
|
||
Function _PYPI_DistName { | ||
param ( | ||
[string]$Version, | ||
[string]$Append = ".tar.gz" | ||
) | ||
|
||
return "$ProjectName-$Version$Append" | ||
} | ||
|
||
Function PYPI_Build { | ||
py .\setup.py sdist | ||
} | ||
|
||
Function PYPI_Check { | ||
param ( | ||
[string]$Version | ||
) | ||
|
||
$distFile = _PYPI_DistName -Version $Version | ||
py -m twine check "./dist/${distFile}" | ||
} | ||
|
||
Function PYPI_Upload { | ||
param ( | ||
[string]$Version | ||
) | ||
|
||
$distFile = _PYPI_DistName -Version $Version | ||
py -m twine upload "./dist/${distFile}" | ||
} | ||
|
||
function PYPI_NextVersion { | ||
param ( | ||
[string]$ConfigFile = ".\setup.cfg", | ||
[string]$PyVersionFile = ".\${ProjectName}\__init__.py" | ||
) | ||
|
||
# Read file content | ||
$fileContent = Get-Content -Path $ConfigFile | ||
|
||
# Extract the version, increment it, and prepare the updated version string | ||
$versionLine = $fileContent | Where-Object { $_ -match "version\s*=" } | ||
$version = $versionLine -split "=", 2 | ForEach-Object { $_.Trim() } | Select-Object -Last 1 | ||
$versionParts = $version -split "\." | ||
|
||
$major = [int]$versionParts[0] | ||
$minor = [int]$versionParts[1] | ||
$patch = [int]$versionParts[2] + 1 | ||
|
||
if ($patch -gt 9) { | ||
$patch = 0 | ||
$minor += 1 | ||
} | ||
|
||
if ($minor -gt 9) { | ||
$minor = 0 | ||
$major += 1 | ||
} | ||
|
||
$newVersion = "$major.$minor.$patch" | ||
Write-Host "Next version: $newVersion" | ||
|
||
# First update the init file so that in case something goes wrong | ||
# the version doesn't persist in the config file | ||
$initContent = Get-Content -Path $PyVersionFile | ||
$initContent = $initContent -replace "__version__\s*=\s*.+", "__version__ = '$newVersion'" | ||
Set-Content -Path $PyVersionFile -Value $initContent | ||
|
||
# Update the version line in the file content | ||
$updatedContent = $fileContent -replace "version\s*=\s*.+", "version = $newVersion" | ||
|
||
# Write the updated content back to the file | ||
Set-Content -Path $ConfigFile -Value $updatedContent | ||
return $newVersion | ||
} | ||
|
||
$version = PYPI_NextVersion # Increment the package version (setup.cfg) | ||
PYPI_Build # Build the package (python setup.py sdist) | ||
PYPI_Check -Version $version # Check the package (twine check dist/<LATEST>) | ||
PYPI_Upload -Version $version # Upload the package (twine upload dist/<LATEST>) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ['setuptools>=40.8.0'] | ||
build-backend = 'setuptools.build_meta' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[metadata] | ||
name = wagtail_word | ||
version = 1.0.4 | ||
description = Easily upload your word documents to Wagtail as pages | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
author = Nigel | ||
author_email = nigel@goodadvice.it | ||
license = GPL-3.0-only | ||
classifiers = | ||
Environment :: Web Environment | ||
Framework :: Django | ||
Framework :: Django :: 4.2 | ||
Framework :: Wagtail | ||
Framework :: Wagtail :: 5 | ||
Framework :: Wagtail :: 6 | ||
Intended Audience :: Developers | ||
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) | ||
Operating System :: OS Independent | ||
Programming Language :: Python | ||
Programming Language :: Python :: 3 | ||
Programming Language :: Python :: 3 :: Only | ||
Programming Language :: Python :: 3.8 | ||
Programming Language :: Python :: 3.9 | ||
Topic :: Internet :: WWW/HTTP | ||
Topic :: Internet :: WWW/HTTP :: Dynamic Content | ||
|
||
[options] | ||
include_package_data = true | ||
packages = find: | ||
python_requires = >=3.8 | ||
install_requires = | ||
Django >= 4.2 | ||
Wagtail >= 4.2 | ||
python-docx >= 1.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from setuptools import setup | ||
|
||
setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
Metadata-Version: 2.1 | ||
Name: wagtail_word | ||
Version: 1.0.4 | ||
Summary: Easily upload your word documents to Wagtail as pages | ||
Author: Nigel | ||
Author-email: nigel@goodadvice.it | ||
License: GPL-3.0-only | ||
Classifier: Environment :: Web Environment | ||
Classifier: Framework :: Django | ||
Classifier: Framework :: Django :: 4.2 | ||
Classifier: Framework :: Wagtail | ||
Classifier: Framework :: Wagtail :: 5 | ||
Classifier: Framework :: Wagtail :: 6 | ||
Classifier: Intended Audience :: Developers | ||
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) | ||
Classifier: Operating System :: OS Independent | ||
Classifier: Programming Language :: Python | ||
Classifier: Programming Language :: Python :: 3 | ||
Classifier: Programming Language :: Python :: 3 :: Only | ||
Classifier: Programming Language :: Python :: 3.8 | ||
Classifier: Programming Language :: Python :: 3.9 | ||
Classifier: Topic :: Internet :: WWW/HTTP | ||
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content | ||
Requires-Python: >=3.8 | ||
Description-Content-Type: text/markdown | ||
License-File: LICENSE | ||
Requires-Dist: Django>=4.2 | ||
Requires-Dist: Wagtail>=4.2 | ||
Requires-Dist: python-docx>=1.1.0 | ||
|
||
wagtail_word | ||
============ | ||
|
||
A Wagtail module to display Word documents in the frontend. | ||
Converts your word documents to richtext for easy editing in the Wagtail admin. | ||
|
||
**Currently supported filetypes:** | ||
- .docx | ||
- .doc | ||
|
||
**Currently supported content:** | ||
- Text (Bold, underlines, italic, strikethrough) | ||
- Text suports colors with allow_styling=True | ||
- Colors get reset after saving the page in Wagtail admin for a second time. | ||
- Images | ||
- Tables | ||
- Hyperlinks | ||
- Lists | ||
- All will be converted to bullet points | ||
- Single level lists only | ||
|
||
Quick start | ||
----------- | ||
|
||
1. Add 'wagtail_word' to your INSTALLED_APPS setting like this: | ||
|
||
``` | ||
INSTALLED_APPS = [ | ||
..., | ||
'wagtail_word', | ||
] | ||
``` | ||
2. Simply go to your Wagtail Admin. | ||
3. Create a new Word Page. | ||
4. Upload a file in the File field. | ||
5. Save or publish the page and see the magic! | ||
|
||
Base Class | ||
----------- | ||
We provide a base class to extend from. This class will provide you a predefined FieldPanel for the File, has the allow_styling attribute and a custom method to set the content to the right field for you to override. | ||
|
||
```python | ||
# Example class | ||
class WordDocumentPage(BaseWordDocumentPage): | ||
template = 'wagtail_word/page.html' | ||
|
||
content = RichTextField( | ||
blank=True, | ||
null=True, | ||
features=[ | ||
# Minimal required features for richtext | ||
"h1", "h2", "h3", "h4", "h5", "h6", | ||
"bold", "italic", "ol", "ul", "link" "image", "embed", | ||
"blockquote", | ||
] | ||
) | ||
|
||
edit_panels = [ | ||
FieldPanel('content'), | ||
] | ||
|
||
edit_handler = TabbedInterface([ | ||
ObjectList(BaseWordDocumentPage.content_panels, heading=_('Upload')), | ||
ObjectList(edit_panels, heading=_('Edit')), | ||
... | ||
]) | ||
|
||
# Override this method to set the content to the right field | ||
def set_content(self, content: str): | ||
self.content = content | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
LICENSE | ||
MANIFEST.in | ||
README.md | ||
pyproject.toml | ||
setup.cfg | ||
setup.py | ||
wagtail_word/__init__.py | ||
wagtail_word/apps.py | ||
wagtail_word/forms.py | ||
wagtail_word/models.py | ||
wagtail_word/tests.py | ||
wagtail_word.egg-info/PKG-INFO | ||
wagtail_word.egg-info/SOURCES.txt | ||
wagtail_word.egg-info/dependency_links.txt | ||
wagtail_word.egg-info/requires.txt | ||
wagtail_word.egg-info/top_level.txt | ||
wagtail_word/migrations/0001_initial.py | ||
wagtail_word/migrations/__init__.py | ||
wagtail_word/migrations/__pycache__/0001_initial.cpython-311.pyc | ||
wagtail_word/migrations/__pycache__/0002_worddocumentpage_content.cpython-311.pyc | ||
wagtail_word/migrations/__pycache__/0003_alter_worddocumentpage_content.cpython-311.pyc | ||
wagtail_word/migrations/__pycache__/0004_worddocumentembed_worddocumentimage.cpython-311.pyc | ||
wagtail_word/migrations/__pycache__/0005_delete_worddocumentembed_delete_worddocumentimage.cpython-311.pyc | ||
wagtail_word/migrations/__pycache__/__init__.cpython-311.pyc | ||
wagtail_word/static/wagtail_word/css/wagtail_word.css | ||
wagtail_word/templates/wagtail_word/page.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Django>=4.2 | ||
Wagtail>=4.2 | ||
python-docx>=1.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
wagtail_word |
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class WagtailWordConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'wagtail_word' |
Oops, something went wrong.