Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/overcastsoftware/wagtailtables
jspreadsheet tables for Wagtail
https://github.com/overcastsoftware/wagtailtables
django hacktoberfest python wagtail
Last synced: 3 months ago
JSON representation
jspreadsheet tables for Wagtail
- Host: GitHub
- URL: https://github.com/overcastsoftware/wagtailtables
- Owner: overcastsoftware
- License: mit
- Created: 2022-04-26T22:37:31.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-23T12:24:16.000Z (about 1 year ago)
- Last Synced: 2024-07-30T21:01:02.546Z (6 months ago)
- Topics: django, hacktoberfest, python, wagtail
- Language: JavaScript
- Homepage:
- Size: 213 KB
- Stars: 9
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Wagtail Tables
jspreadsheet tables in Wagtail, edited and customised from the Wagtail admin## Getting started
Assuming you have a Wagtail project up and running:
`pip install wagtailtables`
Add `wagtailtables` to your settings.py in the INSTALLED_APPS section, before the core wagtail packages:
```python
INSTALLED_APPS = [
# ...
'wagtailtables',
# ...
]
```Add a wagtailtables TableBlock to one of your StreamFields:
```python
from wagtailtables.blocks import TableBlockclass ContentBlocks(StreamBlock):
table_block = TableBlock()
```Include your streamblock in one of your pages
```python
class HomePage(Page):
body = StreamField(ContentBlocks())content_panels = Page.content_panels + [
StreamFieldPanel('body'),
]
```Simply render your table block as you would render any other block.
```django
{% load wagtailcore_tags %}{% block content %}
{{self.title}}
{{self.excerpt|richtext}}
{% for block in self.body %}
{% include_block block %}
{% endfor %}
{% endblock %}
```## Configuration
### Customized toolbar
`TableBlock` accepts a toolbar argument in addition to the standard `StructBlock` arguments.The toolbar is an array of dicts, this is the default:
```python
TOOLBAR = [
{'type': 'i', 'content': 'format_align_left', 'k': 'text-align', 'v': 'left'},
{'type': 'i', 'content': 'format_align_center', 'k':'text-align', 'v':'center'},
{'type': 'i', 'content': 'format_align_right', 'k': 'text-align', 'v': 'right'},
{'type': 'i', 'content': 'format_bold', 'k': 'font-weight', 'v': '600'},
{'type': 'i', 'content': 'format_italic', 'k': 'font-style', 'v': 'italic'},
{'type': 'i', 'content': 'border_left', 'k': 'border-left', 'v': '1px solid'},
{'type': 'i', 'content': 'border_right', 'k': 'border-right', 'v': '1px solid'},
{'type': 'i', 'content': 'border_top', 'k': 'border-top', 'v': '1px solid'},
]class ContentBlocks(StreamBlock):
table_block = TableBlock(toolbar=TOOLBAR)
````type` should for now always be `i` for icon, we will provide more types later
`content` defines the icon (from material icons) [click here for all possible keys](https://fonts.google.com/icons?selected=Material+Icons)
`k` means the style that should be applied to the cell
`v` means the value of the style should be applied to the cell
## Dependencies
* This project relies on [Jspreadsheet Community Edition](https://bossanova.uk/jspreadsheet/v4/) for data entry and manipulation.# Release notes
## Version 0.2.2
* Added support for Wagtail 5
* Removed support for Wagtail <3## Version 0.2.1
* Added support for a customizable toolbar