Skip to content

Commit

Permalink
Add quick start
Browse files Browse the repository at this point in the history
* Added a quick start include template
  • Loading branch information
smark-1 authored May 1, 2024
1 parent 142a986 commit 44db90e
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 315 deletions.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
recursive-include wagtailterms/migrations *
recursive-include wagtailterms/static *
recursive-include wagtailterms/static *
recursive-include wagtailterms/templates *
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,18 @@ Rendered HTML of the term in the frontend:
```html
<span style="text-decoration-line: underline; text-decoration-color: green;text-decoration-thickness: 3px;color:green;" data-term="1">term 1</span>
```
ℹ️ Above is the default style but this can be modified in the settings.

The most basic implementation: ([See full example](./example/home/templates/home/basic_page.html))
#### Quick implementation: ([See full example](./example/home/templates/home/quick_start.html))

Include in the template at the bottom of the page template.
```html
...
{% include 'wagtailterms/wagtailterms.html' %}
```
ℹ️ This loads the advanced implementation in page template.

#### The most basic implementation: ([See full example](./example/home/templates/home/basic_page.html))
```javascript
function showterm(e){
const termid = e.target.dataset.term
Expand All @@ -129,7 +139,7 @@ On hover
<img width="50%" src="./example/images/view_basic_2.png">
</p>

A more advanced way would be to use a library like [tippy.js](https://atomiks.github.io/tippyjs/) to
#### A more advanced way would be to use a library like [tippy.js](https://atomiks.github.io/tippyjs/) to
create a tooltip that appears when hovering over the term. ([See full example](./example/home/templates/home/advanced_page.html))
```javascript
function add_tooltips(){
Expand Down Expand Up @@ -214,6 +224,4 @@ On hover

### 0.1.3
- Added setting to change frontend styles

## To Do
- Include a default javascript implementation for frontend
- Added quick start template for default frontend implementation
Empty file.
Empty file.
27 changes: 27 additions & 0 deletions example/home/migrations/0002_quickstart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 5.0.3 on 2024-05-01 03:15

import django.db.models.deletion
import wagtail.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('home', '0001_initial'),
('wagtailcore', '0091_remove_revision_submitted_for_moderation'),
]

operations = [
migrations.CreateModel(
name='QuickStart',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
('content', wagtail.fields.RichTextField()),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]
20 changes: 14 additions & 6 deletions example/home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ class HomePage(Page):
pass


class QuickStart(Page):
content = RichTextField()

content_panels = Page.content_panels + [
FieldPanel("content")
]


class BasicPage(Page):
content = RichTextField()

Expand All @@ -19,12 +27,12 @@ class BasicPage(Page):

class AdvancedPage(Page):
content = StreamField(
[
("heading", blocks.CharBlock(form_classname="title")),
("paragraph", blocks.RichTextBlock()),
],
blank=True,
use_json_field=True,
[
("heading", blocks.CharBlock(form_classname="title")),
("paragraph", blocks.RichTextBlock()),
],
blank=True,
use_json_field=True,
)

content_panels = Page.content_panels + [
Expand Down
184 changes: 0 additions & 184 deletions example/home/static/css/welcome_page.css

This file was deleted.

21 changes: 0 additions & 21 deletions example/home/templates/home/home_page.html

This file was deleted.

15 changes: 15 additions & 0 deletions example/home/templates/home/quick_start.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% load wagtailcore_tags wagtailuserbar %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Basic Terms</title>
</head>
<body>
{% wagtailuserbar %}
<main id="content">
{{ page.content|richtext }}
</main>
{% include 'wagtailterms/wagtailterms.html' %}
</body>
</html>
52 changes: 0 additions & 52 deletions example/home/templates/home/welcome_page.html

This file was deleted.

Loading

0 comments on commit 44db90e

Please sign in to comment.