Skip to content

Commit d67b208

Browse files
committed
fix csrf token and css variables
1 parent c6d45f0 commit d67b208

8 files changed

Lines changed: 50 additions & 25 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Django StreamField
22

33
This is a simple realisation of StreamField's idea of Wagtail CMS for plain Django admin or with Grappelli skin.
4-
Stable version: 2.1.2
5-
Django <= 4.2
4+
Stable version: 2.2.0
5+
Django <= 5.0
66

77
[Major changes (1.4.5 > 2)](changes2.0.md)
88

frontend/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "streamfield_widget.js",
3-
"version": "2.1.2",
3+
"version": "2.2.0",
44
"description": "",
55
"private": true,
66
"scripts": {
@@ -20,7 +20,6 @@
2020
"css-minimizer-webpack-plugin": "^4.2.2",
2121
"file-loader": "^6.2.0",
2222
"html-webpack-plugin": "^5.5.0",
23-
"js-cookie": "^3.0.1",
2423
"mini-css-extract-plugin": "^2.7.5",
2524
"sass": "^1.60.0",
2625
"sass-loader": "^13.2.2",

frontend/src/streamfield_widget.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import "@/style.sass"
22
import axios from 'axios'
3-
import Cookies from 'js-cookie'
43
import { createApp } from 'vue'
54
import App from '@/components/App.vue'
65

76
(function(){
87
function onReady() {
98
let streamfield_app = document.querySelectorAll('.streamfield_app');
109
window.ax = axios.create({
11-
headers: {"X-CSRFToken": Cookies.get('csrftoken')}
10+
headers: {"X-CSRFToken": document.querySelector('[name=csrfmiddlewaretoken]').value}
1211
});
1312
window.streamapps = {};
1413
for (let i = 0; i < streamfield_app.length; i++) {

frontend/src/style.sass

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
max-width: 758px
33
width: 98%
44
margin-top: 5px
5-
float: left
5+
float: left
66

77
textarea
88
display: none
@@ -31,7 +31,7 @@
3131

3232
.stream-model-block
3333
position: relative
34-
color: #333
34+
color: var(--body-fg)
3535

3636
&__inner
3737
box-shadow: 0 0 5px 2px rgba(0,0,0,0.1)
@@ -75,7 +75,7 @@
7575
.streamblock__block__subtitle
7676
font-weight: normal
7777
font-size: 1em
78-
opacity: 0.7
78+
opacity: 0.6
7979
position: relative
8080
margin: 0
8181

@@ -118,12 +118,12 @@
118118
bottom: 0
119119
left: 0
120120
right: 0
121-
border: 1px dashed #AAA
121+
border: 1px dashed var(--border-color)
122122
border-radius: 5px
123123
background: rgba(255,255,255,0.1)
124124

125125
&:before
126-
content: "+"
126+
content: ""
127127
position: absolute
128128
width: 30px
129129
height: 30px
@@ -132,7 +132,11 @@
132132
left: 50%
133133
margin-top: -15px
134134
margin-left: -15px
135-
background: #309bbf
135+
background: var(--secondary)
136+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16.729' height='16.728'%3E%3Cg fill='none' stroke='%23fff' stroke-linecap='round' stroke-width='2'%3E%3Cpath d='M8.364 2v12.728M14.728 8.364H2'/%3E%3C/g%3E%3C/svg%3E")
137+
background-position: 50% 50%
138+
background-repeat: no-repeat
139+
background-size: 18px
136140
display: none
137141
font-size: 28px
138142
line-height: 30px
@@ -145,7 +149,7 @@
145149

146150
&__content
147151
padding: 20px
148-
background: #f5f5f5
152+
background: var(--darkened-bg)
149153

150154
.model-field-content:after
151155
content: "."
@@ -173,7 +177,7 @@
173177
.stream-block__options
174178
padding: 7px
175179
text-align: right
176-
background: #efefef
180+
background: var(--selected-bg)
177181

178182
.stream-block__option
179183
display: inline-block
@@ -194,12 +198,16 @@
194198
& > div
195199
margin-bottom: 0.4em
196200

201+
h1
202+
color: var(--body-fg)
203+
197204
h2
198205
padding: 0
199206
text-shadow: none
200207
border: none
201208
background-image: none
202209
font-size: 1.3em
210+
color: var(--body-fg)
203211

204212
h3
205213
padding: 0
@@ -208,9 +216,11 @@
208216
background-image: none
209217
font-size: 1.1em
210218
margin-bottom: 0.5em
219+
color: var(--body-fg)
211220

212221
h4
213222
font-weight: bold
223+
color: var(--body-fg)
214224

215225
blockquote
216226
font-size: 1.1em
@@ -239,25 +249,26 @@
239249
max-height: 150px
240250

241251
.stream-model-subblock
242-
background: #e0e7eb
252+
background: var(--selected-bg) // #e0e7eb
243253
padding: 10px
244254
display: block
245255
border-radius: 5px
246256
margin-bottom: 10px
247257
position: relative
248258

249259
.stream-btn
250-
background: #78adbf
260+
background: var(--button-bg)
251261
color: white !important
252262
padding: 3px 7px
253263
display: inline-block
254264
border-radius: 2px
255265
margin-top: 5px
256266
font-weight: bold
257267
user-select: none
268+
text-decoration: none
258269

259270
&:hover
260-
background: #309bbf
271+
background: var(--button-hover-bg)
261272

262273
.add-another
263274
margin-left: 10px
@@ -279,7 +290,7 @@
279290
font-weight: bold
280291
text-decoration: underline
281292
cursor: pointer
282-
color: #309bbf
293+
color: var(--link-fg)
283294
user-select: none
284295

285296
/* Help text */
@@ -349,13 +360,26 @@
349360
.stream-model-subblock .subblock-move:hover
350361
background-position: 0 -141px
351362

363+
// grp
364+
:root
365+
--primary: #a9c8d5
366+
--primary-fg: #000
367+
--secondary: #309bbf
368+
--button-bg: #78adbf
369+
--button-hover-bg: #309bbf
370+
--selected-bg: #ececec
371+
--darkened-bg: #f5f5f5
372+
--body-fg: #333
373+
--link-fg: #309bbf
374+
--border-color: #AAA
375+
352376
/* for django skin */
353377
#content-main
354378
.streamfield_app
355379
.stream-model-block
356380
.streamblock__block__title
357-
background: #a9c8d5
358-
color: black
381+
background: var(--primary)
382+
color: var(--primary-fg)
359383
margin: 0
360384
line-height: 20px
361385
font-weight: normal
@@ -383,11 +407,14 @@
383407

384408
.collapse-handlers
385409
.collapse-handler
386-
color: #309bbf
410+
color: var(--link-fg)
387411
font-weight: normal
388412
font-size: 14px
389413

390414
.streamblock__block-handle,
391415
.stream-model-subblock-handle
392416
top: 5px
393417

418+
.grp-button
419+
text-decoration: none
420+

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="django-streamfield",
8-
version="2.1.2",
8+
version="2.2.0",
99
author="Yury Lapshinov",
1010
author_email="y.raagin@gmail.com",
1111
description="StreamField for native Django Admin or with Grappelli",

streamfield/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
name = "streamfield"
2-
VERSION = "2.1.2"
2+
VERSION = "2.2.0"

streamfield/static/streamfield/streamfield_widget.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

streamfield/static/streamfield/streamfield_widget.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)