summaryrefslogtreecommitdiff
path: root/python-django-pagedown.spec
blob: 74d92870910263bc5ccfb7892e237e525f839f31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
%global _empty_manifest_terminate_build 0
Name:		python-django-pagedown
Version:	2.2.1
Release:	1
Summary:	A Django app that allows the easy addition of Stack Overflow's 'PageDown' markdown editor to a django form field
License:	LICENSE.txt
URL:		https://github.com/timmyomahony/django-pagedown
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/c5/7f/2f12e1ac2a50ba7d2a82ca10efd2c127345bb93af68d65b1b9808b257f29/django-pagedown-2.2.1.tar.gz
BuildArch:	noarch

Requires:	python3-Django
Requires:	python3-Pillow

%description
Add [Stack Overflow's "Pagedown" Markdown editor](https://github.com/StackExchange/pagedown/) to your Django Admin or custom form.
![Screenshot of Django Admin with Pagedown initialised](https://github.com/timmyomahony/django-pagedown/blob/master/screenshot.png?raw=true "A screenshot of Pagedown in Django's admin")
## Requirements
Version >= 2.0.0 of `django-pagedown` requires Django 2.1.0 or above (previous versions should support Django all the way back to around 1.1).
## Installation
1. Get the code: `pip install django-pagedown`
2. Add `pagedown.apps.PagedownConfig` to your `INSTALLED_APPS` in `settings.py`
3. [Configure and collect](https://docs.djangoproject.com/en/dev/howto/static-files/#configuring-static-files) the static files: `python manage.py collectstatic`
## Usage
The widget can be used both inside the django admin or independendly. 
### Inside the Django Admin:
If you want to use the pagedown editor in a django admin field, there are numerous possible approaches:
- To use it in **all** `TextField`'s in your admin form:
    ```python
    from django.contrib import admin
    from django.db import models
    from pagedown.widgets import AdminPagedownWidget
    class AlbumAdmin(admin.ModelAdmin):
        formfield_overrides = {
            models.TextField: {'widget': AdminPagedownWidget },
        }
    ```
- To only use it on **particular fields**, first create a form (in `forms.py`):
    ```python
    from django import forms
    from pagedown.widgets import AdminPagedownWidget
    from music.models import Album
    class AlbumForm(forms.ModelForm):
        name = forms.CharField(widget=AdminPagedownWidget())
        description = forms.CharField(widget=AdminPagedownWidget())
        class Meta:
            model = Album
            fields = "__all__"
    ```
    and in your `admin.py`:
    ```python
    from django.contrib import admin
    from forms import FooModelForm
    from models import FooModel
    @admin.register(FooModel)
    class FooModelAdmin(admin.ModelAdmin):
        form = FooModelForm
        fields = "__all__"
    ```
### Outside the Django Admin:
To use the widget outside of the django admin, first create a form similar to the above but using the basic `PagedownWidget`:
```python
from django import forms
from pagedown.widgets import PagedownWidget
from music.models import Album
class AlbumForm(forms.ModelForm):
    name = forms.CharField(widget=PagedownWidget())
    description = forms.CharField(widget=PagedownWidget())
    class Meta:
        model = Album
        fields = ["name", "description"]
```
Then define your urls/views:
```py
from django.views.generic import FormView
from django.conf.urls import patterns, url
from music.forms import AlbumForm
urlpatterns = patterns('',
    url(r'^$', FormView.as_view(template_name="baz.html",
                                form_class=AlbumForm)),)
```
then create the template and load the javascipt and css required to create the editor:
```html
<html>
    <head>
        {{ form.media }}
    </head>
    <body>
        <form ...>
            {{ form }}
        </form>
    </body>
</html>
```
## Customizing the Widget
If you want to customize the widget, the easiest way is to simply extend it:
```py
from pagedown.widgets import PagedownWidget
class MyNewWidget(PagedownWidget):
    template_name = '/custom/template.html'
    class Media:
        css = {
            'all': ('custom/stylesheets.css',)
        }
        js = ('custom/javascript.js',)
```
## Rendering Markdown
`contrib.markdown` was [deprecated in Django 1.5](https://code.djangoproject.com/ticket/18054) meaning you can no longer use the `markdown` filter in your template by default.
[@wkcd has a good example](https://github.com/timmyomahony/django-pagedown/issues/18#issuecomment-37535535) of how to overcome by installing `django-markdown-deux`:
```py
{% extends 'base.html' %}
{% load markdown_deux_tags %}
<p>{{ entry.body|markdown }}</p>
```
## Image Uploads
You can enable image uploads, allowing your users to upload new images to the server and have them automatically inserted into the Pagedown widget (instead of just adding image URLs):
![Screenshot of Django Admin with image upload enabled](https://github.com/timmyomahony/django-pagedown/blob/develop/image-upload.png?raw=true "Screenshot of Django Admin with image upload enabled")
To do so:
1. Make sure you have set a `MEDIA_URL` and `MEDIA_ROOT` so that uploads will be propertly saved
2. Add `PAGEDOWN_IMAGE_UPLOAD_ENABLED=True` to your settings
3. Include the pagedown paths in your `urls.py` so that the upload endpoint is available
```py
 # ...
 urlpatterns = [
     path('', include('pagedown.urls')),
     # ...
 ]
```
This will add the URL `/pagedown/image-upload/` endpoint to your project. You can [see the default view that handles the upload here](https://github.com/timmyomahony/django-pagedown/blob/develop/pagedown/views.py)
The following options are available via your settings to tweak how the image upload works:
- `PAGEDOWN_IMAGE_UPLOAD_PATH` can be used to change the path within your media root (default is `pagedown-uploads`)
- `PAGEDOWN_IMAGE_UPLOAD_EXTENSIONS` can be used to limit the extensions allowed for upload (default is `jpg`, `jpeg`, `png`, `webp`)
- `PAGEDOWN_IMAGE_UPLOAD_UNIQUE` can be used to ensure all uploads are stored in a uniquely named subfolder, e.g. `f748e009-c3cb-40f3-abf2-d103ab0ad259/my-file.png` (default is `False`)
Check out the `pagedown_init.js` script to [see how the upload is being performed on the client side](https://github.com/timmyomahony/django-pagedown/blob/develop/pagedown/static/pagedown_init.js).
## Example
You can see a fully-fledged example of the widget in [`django-pagedown-example`](https://github.com/timmyomahony/django-pagedown-example)

%package -n python3-django-pagedown
Summary:	A Django app that allows the easy addition of Stack Overflow's 'PageDown' markdown editor to a django form field
Provides:	python-django-pagedown
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-django-pagedown
Add [Stack Overflow&#39;s &quot;Pagedown&quot; Markdown editor](https://github.com/StackExchange/pagedown/) to your Django Admin or custom form.
![Screenshot of Django Admin with Pagedown initialised](https://github.com/timmyomahony/django-pagedown/blob/master/screenshot.png?raw=true "A screenshot of Pagedown in Django's admin")
## Requirements
Version >= 2.0.0 of `django-pagedown` requires Django 2.1.0 or above (previous versions should support Django all the way back to around 1.1).
## Installation
1. Get the code: `pip install django-pagedown`
2. Add `pagedown.apps.PagedownConfig` to your `INSTALLED_APPS` in `settings.py`
3. [Configure and collect](https://docs.djangoproject.com/en/dev/howto/static-files/#configuring-static-files) the static files: `python manage.py collectstatic`
## Usage
The widget can be used both inside the django admin or independendly. 
### Inside the Django Admin:
If you want to use the pagedown editor in a django admin field, there are numerous possible approaches:
- To use it in **all** `TextField`'s in your admin form:
    ```python
    from django.contrib import admin
    from django.db import models
    from pagedown.widgets import AdminPagedownWidget
    class AlbumAdmin(admin.ModelAdmin):
        formfield_overrides = {
            models.TextField: {'widget': AdminPagedownWidget },
        }
    ```
- To only use it on **particular fields**, first create a form (in `forms.py`):
    ```python
    from django import forms
    from pagedown.widgets import AdminPagedownWidget
    from music.models import Album
    class AlbumForm(forms.ModelForm):
        name = forms.CharField(widget=AdminPagedownWidget())
        description = forms.CharField(widget=AdminPagedownWidget())
        class Meta:
            model = Album
            fields = "__all__"
    ```
    and in your `admin.py`:
    ```python
    from django.contrib import admin
    from forms import FooModelForm
    from models import FooModel
    @admin.register(FooModel)
    class FooModelAdmin(admin.ModelAdmin):
        form = FooModelForm
        fields = "__all__"
    ```
### Outside the Django Admin:
To use the widget outside of the django admin, first create a form similar to the above but using the basic `PagedownWidget`:
```python
from django import forms
from pagedown.widgets import PagedownWidget
from music.models import Album
class AlbumForm(forms.ModelForm):
    name = forms.CharField(widget=PagedownWidget())
    description = forms.CharField(widget=PagedownWidget())
    class Meta:
        model = Album
        fields = ["name", "description"]
```
Then define your urls/views:
```py
from django.views.generic import FormView
from django.conf.urls import patterns, url
from music.forms import AlbumForm
urlpatterns = patterns('',
    url(r'^$', FormView.as_view(template_name="baz.html",
                                form_class=AlbumForm)),)
```
then create the template and load the javascipt and css required to create the editor:
```html
<html>
    <head>
        {{ form.media }}
    </head>
    <body>
        <form ...>
            {{ form }}
        </form>
    </body>
</html>
```
## Customizing the Widget
If you want to customize the widget, the easiest way is to simply extend it:
```py
from pagedown.widgets import PagedownWidget
class MyNewWidget(PagedownWidget):
    template_name = '/custom/template.html'
    class Media:
        css = {
            'all': ('custom/stylesheets.css',)
        }
        js = ('custom/javascript.js',)
```
## Rendering Markdown
`contrib.markdown` was [deprecated in Django 1.5](https://code.djangoproject.com/ticket/18054) meaning you can no longer use the `markdown` filter in your template by default.
[@wkcd has a good example](https://github.com/timmyomahony/django-pagedown/issues/18#issuecomment-37535535) of how to overcome by installing `django-markdown-deux`:
```py
{% extends 'base.html' %}
{% load markdown_deux_tags %}
<p>{{ entry.body|markdown }}</p>
```
## Image Uploads
You can enable image uploads, allowing your users to upload new images to the server and have them automatically inserted into the Pagedown widget (instead of just adding image URLs):
![Screenshot of Django Admin with image upload enabled](https://github.com/timmyomahony/django-pagedown/blob/develop/image-upload.png?raw=true "Screenshot of Django Admin with image upload enabled")
To do so:
1. Make sure you have set a `MEDIA_URL` and `MEDIA_ROOT` so that uploads will be propertly saved
2. Add `PAGEDOWN_IMAGE_UPLOAD_ENABLED=True` to your settings
3. Include the pagedown paths in your `urls.py` so that the upload endpoint is available
```py
 # ...
 urlpatterns = [
     path('', include('pagedown.urls')),
     # ...
 ]
```
This will add the URL `/pagedown/image-upload/` endpoint to your project. You can [see the default view that handles the upload here](https://github.com/timmyomahony/django-pagedown/blob/develop/pagedown/views.py)
The following options are available via your settings to tweak how the image upload works:
- `PAGEDOWN_IMAGE_UPLOAD_PATH` can be used to change the path within your media root (default is `pagedown-uploads`)
- `PAGEDOWN_IMAGE_UPLOAD_EXTENSIONS` can be used to limit the extensions allowed for upload (default is `jpg`, `jpeg`, `png`, `webp`)
- `PAGEDOWN_IMAGE_UPLOAD_UNIQUE` can be used to ensure all uploads are stored in a uniquely named subfolder, e.g. `f748e009-c3cb-40f3-abf2-d103ab0ad259/my-file.png` (default is `False`)
Check out the `pagedown_init.js` script to [see how the upload is being performed on the client side](https://github.com/timmyomahony/django-pagedown/blob/develop/pagedown/static/pagedown_init.js).
## Example
You can see a fully-fledged example of the widget in [`django-pagedown-example`](https://github.com/timmyomahony/django-pagedown-example)

%package help
Summary:	Development documents and examples for django-pagedown
Provides:	python3-django-pagedown-doc
%description help
Add [Stack Overflow&#39;s &quot;Pagedown&quot; Markdown editor](https://github.com/StackExchange/pagedown/) to your Django Admin or custom form.
![Screenshot of Django Admin with Pagedown initialised](https://github.com/timmyomahony/django-pagedown/blob/master/screenshot.png?raw=true "A screenshot of Pagedown in Django's admin")
## Requirements
Version >= 2.0.0 of `django-pagedown` requires Django 2.1.0 or above (previous versions should support Django all the way back to around 1.1).
## Installation
1. Get the code: `pip install django-pagedown`
2. Add `pagedown.apps.PagedownConfig` to your `INSTALLED_APPS` in `settings.py`
3. [Configure and collect](https://docs.djangoproject.com/en/dev/howto/static-files/#configuring-static-files) the static files: `python manage.py collectstatic`
## Usage
The widget can be used both inside the django admin or independendly. 
### Inside the Django Admin:
If you want to use the pagedown editor in a django admin field, there are numerous possible approaches:
- To use it in **all** `TextField`'s in your admin form:
    ```python
    from django.contrib import admin
    from django.db import models
    from pagedown.widgets import AdminPagedownWidget
    class AlbumAdmin(admin.ModelAdmin):
        formfield_overrides = {
            models.TextField: {'widget': AdminPagedownWidget },
        }
    ```
- To only use it on **particular fields**, first create a form (in `forms.py`):
    ```python
    from django import forms
    from pagedown.widgets import AdminPagedownWidget
    from music.models import Album
    class AlbumForm(forms.ModelForm):
        name = forms.CharField(widget=AdminPagedownWidget())
        description = forms.CharField(widget=AdminPagedownWidget())
        class Meta:
            model = Album
            fields = "__all__"
    ```
    and in your `admin.py`:
    ```python
    from django.contrib import admin
    from forms import FooModelForm
    from models import FooModel
    @admin.register(FooModel)
    class FooModelAdmin(admin.ModelAdmin):
        form = FooModelForm
        fields = "__all__"
    ```
### Outside the Django Admin:
To use the widget outside of the django admin, first create a form similar to the above but using the basic `PagedownWidget`:
```python
from django import forms
from pagedown.widgets import PagedownWidget
from music.models import Album
class AlbumForm(forms.ModelForm):
    name = forms.CharField(widget=PagedownWidget())
    description = forms.CharField(widget=PagedownWidget())
    class Meta:
        model = Album
        fields = ["name", "description"]
```
Then define your urls/views:
```py
from django.views.generic import FormView
from django.conf.urls import patterns, url
from music.forms import AlbumForm
urlpatterns = patterns('',
    url(r'^$', FormView.as_view(template_name="baz.html",
                                form_class=AlbumForm)),)
```
then create the template and load the javascipt and css required to create the editor:
```html
<html>
    <head>
        {{ form.media }}
    </head>
    <body>
        <form ...>
            {{ form }}
        </form>
    </body>
</html>
```
## Customizing the Widget
If you want to customize the widget, the easiest way is to simply extend it:
```py
from pagedown.widgets import PagedownWidget
class MyNewWidget(PagedownWidget):
    template_name = '/custom/template.html'
    class Media:
        css = {
            'all': ('custom/stylesheets.css',)
        }
        js = ('custom/javascript.js',)
```
## Rendering Markdown
`contrib.markdown` was [deprecated in Django 1.5](https://code.djangoproject.com/ticket/18054) meaning you can no longer use the `markdown` filter in your template by default.
[@wkcd has a good example](https://github.com/timmyomahony/django-pagedown/issues/18#issuecomment-37535535) of how to overcome by installing `django-markdown-deux`:
```py
{% extends 'base.html' %}
{% load markdown_deux_tags %}
<p>{{ entry.body|markdown }}</p>
```
## Image Uploads
You can enable image uploads, allowing your users to upload new images to the server and have them automatically inserted into the Pagedown widget (instead of just adding image URLs):
![Screenshot of Django Admin with image upload enabled](https://github.com/timmyomahony/django-pagedown/blob/develop/image-upload.png?raw=true "Screenshot of Django Admin with image upload enabled")
To do so:
1. Make sure you have set a `MEDIA_URL` and `MEDIA_ROOT` so that uploads will be propertly saved
2. Add `PAGEDOWN_IMAGE_UPLOAD_ENABLED=True` to your settings
3. Include the pagedown paths in your `urls.py` so that the upload endpoint is available
```py
 # ...
 urlpatterns = [
     path('', include('pagedown.urls')),
     # ...
 ]
```
This will add the URL `/pagedown/image-upload/` endpoint to your project. You can [see the default view that handles the upload here](https://github.com/timmyomahony/django-pagedown/blob/develop/pagedown/views.py)
The following options are available via your settings to tweak how the image upload works:
- `PAGEDOWN_IMAGE_UPLOAD_PATH` can be used to change the path within your media root (default is `pagedown-uploads`)
- `PAGEDOWN_IMAGE_UPLOAD_EXTENSIONS` can be used to limit the extensions allowed for upload (default is `jpg`, `jpeg`, `png`, `webp`)
- `PAGEDOWN_IMAGE_UPLOAD_UNIQUE` can be used to ensure all uploads are stored in a uniquely named subfolder, e.g. `f748e009-c3cb-40f3-abf2-d103ab0ad259/my-file.png` (default is `False`)
Check out the `pagedown_init.js` script to [see how the upload is being performed on the client side](https://github.com/timmyomahony/django-pagedown/blob/develop/pagedown/static/pagedown_init.js).
## Example
You can see a fully-fledged example of the widget in [`django-pagedown-example`](https://github.com/timmyomahony/django-pagedown-example)

%prep
%autosetup -n django-pagedown-2.2.1

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-django-pagedown -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Sun Apr 23 2023 Python_Bot <Python_Bot@openeuler.org> - 2.2.1-1
- Package Spec generated