main
Jaap Joris Vens 2020-03-22 21:19:12 +01:00
rodzic 66755c1e40
commit 1e503349d6
8 zmienionych plików z 21 dodań i 17 usunięć

Wyświetl plik

@ -43,6 +43,13 @@ Everytime a section needs to be rendered, SimpleCMS will call the
appropriate section view and insert the rendered result into the final
rendered page.
But that's not all! SimpleCMS is easily extendable. You can add custom
fields to your Page and Section models. You can even add one-to-many
fields by defining new models with a foreign key to the Section model,
and the Edit interface will automagically show the user nested
formsets to edit the related instances! For a complete example see the
included `example` app.
## The "Edit" Interface
Somewhat like the Django Admin site, SimpleCMS comes with its own

Wyświetl plik

@ -3,7 +3,8 @@ from sass import compile
from django.conf import settings
def locate(filename):
for path, dirs, files in os.walk(os.getcwd()):
for path, dirs, files in os.walk(os.getcwd(), followlinks=True):
print(dirs)
for f in files:
if f == filename:
return os.path.join(path, filename)

Wyświetl plik

@ -46,7 +46,8 @@ form.cms {
background: $background;
border: 0.5px solid #ccc;
clear: both;
margin: 0.25em 0em;
margin: 0.5em 0;
margin-top: 0.25em;
padding: 0.25em 0.5em;
padding-top: 0;
border-radius: 0.25em;
@ -60,8 +61,7 @@ form.cms {
}
div.formfield {
margin-top: 0.25em;
margin-bottom: 0.25em;
margin: 0.25em 0;
overflow: hidden;
clear: both;
box-sizing: border-box;
@ -131,8 +131,6 @@ form.cms {
vertical-align: middle;
}
textarea {
font-size: 1rem;
height: 15em;
line-height: 1.5;
overflow-y: hidden;
}

Wyświetl plik

@ -34,7 +34,8 @@ form.cms {
background: #fff6;
border: 0.5px solid #ccc;
clear: both;
margin: 0.25em 0em;
margin: 0.5em 0;
margin-top: 0.25em;
padding: 0.25em 0.5em;
padding-top: 0;
border-radius: 0.25em; }
@ -44,8 +45,7 @@ form.cms {
width: 50px;
cursor: pointer; }
form.cms div.formfield {
margin-top: 0.25em;
margin-bottom: 0.25em;
margin: 0.25em 0;
overflow: hidden;
clear: both;
box-sizing: border-box; }
@ -97,8 +97,6 @@ form.cms {
display: inline-block;
vertical-align: middle; }
form.cms textarea {
font-size: 1rem;
height: 15em;
line-height: 1.5;
overflow-y: hidden; }
form.cms select {

Wyświetl plik

@ -5,5 +5,5 @@
"admin.scss"
],
"names": [],
"mappings": "AAEA,AAAA,IAAI,EAAE,IAAI,CAAC;EACT,WAAW,EAHN,YAAY,EAAE,UAAU;EAI7B,WAAW,EAAE,CAAC;EACd,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC,GACX;;AAED,AAAA,GAAG,AAAA,KAAK,CAAC;EACP,QAAQ,EAAE,KAAK;EACf,KAAK,EAAE,GAAG;EACV,MAAM,EAAE,GAAG;EACX,OAAO,EAAE,IAAI,GAYd;EAhBD,AAME,GANC,AAAA,KAAK,CAMN,MAAM,CAAC;IACL,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,IAAI,GACb;EAXH,AAYE,GAZC,AAAA,KAAK,CAYN,GAAG,CAAC;IACF,KAAK,EAAE,eAAe;IACtB,MAAM,EAAE,IAAI,GACb;;AAGH,mBAAmB;AAEnB,AAAA,IAAI,AAAA,IAAI,CAAC;EACP,UAAU,EAAE,IAAI;EAChB,QAAQ,EAAE,MAAM;EAChB,UAAU,EAAE,KAAK;EAEjB,OAAO,EAAE,IAAI;EACb,WAAW,EAAE,MAAM;EACnB,eAAe,EAAE,MAAM,GA2IxB;EAlJD,AASE,IATE,AAAA,IAAI,CASN,GAAG,AAAA,QAAQ,CAAC;IACV,SAAS,EAAE,IAAI;IACf,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,OAAO,GACjB;EAbH,AAeE,IAfE,AAAA,IAAI,CAeN,QAAQ,CAAC;IACP,UAAU,EAZC,KAAK;IAahB,MAAM,EAAE,gBAAgB;IACxB,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,YAAY;IACrB,WAAW,EAAE,CAAC;IACd,aAAa,EAAE,MAAM,GACtB;EAvBH,AAyBE,IAzBE,AAA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GAAG;EAChB,GAAG,EAAE,6BAA6B,CAAC,eAAe"
}

Wyświetl plik

@ -7,7 +7,6 @@
<title>{% block title %}{% endblock %}</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{% static 'cms/cms.scss.css' %}">
<link rel="stylesheet" href="{% static 'cms/admin.scss.css' %}">
{% block extrahead %}{% endblock %}
</head>

Wyświetl plik

@ -98,7 +98,6 @@
function setEventHandlers() {
for (let typefield of document.querySelectorAll('select[name$=-type]')) {
let formId = typefield.name.replace(/-type$/, '');
console.log(formId + 'huh');
let form = document.getElementById(formId);
let type = typefield.value.toLowerCase();
showRelevantFields(form, type);
@ -110,7 +109,9 @@
}
}
setEventHandlers();
resizeTextareas();
document.addEventListener("DOMContentLoaded", function(event) {
setEventHandlers();
resizeTextareas();
});
</script>
{% endblock %}

Wyświetl plik

@ -16,7 +16,7 @@ class Section(BaseSection):
number, content, image, video, href
'''
page = models.ForeignKey(Page, verbose_name=_('page'), related_name='sections', on_delete=models.PROTECT)
page = models.ForeignKey(Page, related_name='sections', on_delete=models.PROTECT)
class SectionImage(models.Model):
section = models.ForeignKey(Section, related_name='images', on_delete=models.CASCADE)