From 2048f27d5872c612bfaf515a08cfa368bb8fb469 Mon Sep 17 00:00:00 2001 From: Krophil Date: Thu, 27 Apr 2017 22:57:21 +0200 Subject: [PATCH 01/10] New temporary design --- core/static/core/temporary_design.scss | 689 +++++++++++++++++++++++++ core/templates/core/base.jinja | 2 +- requirements.txt | 4 +- sith/settings.py | 15 + 4 files changed, 708 insertions(+), 2 deletions(-) create mode 100644 core/static/core/temporary_design.scss diff --git a/core/static/core/temporary_design.scss b/core/static/core/temporary_design.scss new file mode 100644 index 00000000..4b008c81 --- /dev/null +++ b/core/static/core/temporary_design.scss @@ -0,0 +1,689 @@ +$first-color: hsl(220, 100%, 50%); +$second-color: hsl(40, 100%, 50%); +$primary-color: hsl(219.9, 53.7%, 50%); +$secondary-color: hsl(40.1, 78.0%, 50%); +$primary-color-text: hsl(0, 0%, 100%); +$secondary-color-text: hsla(0, 0%, 0%, 0.87); + +$primary-light-color: hsl(219.8, 46.4%, 64.9%); +$primary-dark-color: hsl(219.8, 46.4%, 35.1%); + +$secondary-light-color: hsl(40, 68%, 65%); +$secondary-dark-color: hsl(40, 68%, 35%); + + +$primary-neutral-color: hsl(219.6, 20.8%, 50%); +$primary-neutral-light-color: hsl(219.6, 20.8%, 83%); +$primary-neutral-dark-color: hsl(219.6, 20.8%, 17%); + +$secondary-neutral-color: hsl(40, 57.6%, 50%); +$secondary-neutral-light-color: hsl(40, 57.6%, 83%); +$secondary-neutral-dark-color: hsl(40, 57.6%, 17%); + +$white-color: hsl(219.6, 20.8%, 98%); +$black-color: hsl(40.0, 0%, 17%); + + + + +/*--------------------------------GENERAL------------------------------*/ + +body { + background-color: $primary-neutral-light-color; + position: relative; + width: 100%; + font-family: sans-serif; +} + +a { + text-decoration: none; + color: $primary-dark-color; + &:hover { + color: $primary-light-color; + } + &:active { + color: $primary-color; + } +} + +.ib { + display: inline-block; + padding: 2px; + margin: 2px; +} + +.w_big { + width: 75%; +} + +.w_medium { + width: 45%; +} + +.w_small { + width: 20%; +} + +/*--------------------------------HEADER-------------------------------*/ + +#logo { + margin-left: 5%; + display: inline-block; +} + +header { + display: block; + position: absolute; + top: 0px; + right: 2%; + background-color: $secondary-light-color; + margin: 0 10px; + padding: 0 10px; + border-radius: 0 0 10px 10px; + ul { + display: inline-block; + list-style-type: none; + margin: 0px; + padding-right: 3px; + vertical-align: middle; + } + a { + display: inline-block; + color: inherit; + text-decoration: none; + padding: 1em; + &:hover { + color: $primary-dark-color; + } + } + form { + display: inline-block; + padding: 1em; + width: 150px; + } +} + +#popupheader { + width: 88%; + margin: 0px auto; + padding: 0.3em 1%; +} + +#language_chooser { + position: absolute; + text-align: center; + left: 5px; + top: 5px; + input { + margin: 2px; + width: 3em; + height: 2em; + } +} + +#notif { + display: none; + position: absolute; + background: lightgrey; + text-align: center; + overflow: scroll; + max-height: 400px; + li:hover { + background: #bcc; + } +} + +#alert_box p, #info_box p { + margin: 0px; + padding: 0px; +} + +#alert_box { + font-size: smaller; + display: inline-block; + border: solid 1px grey; + vertical-align: top; + padding: 2px; + margin: 4px; + margin-top: 60px; + min-width: 10%; + max-width: 30%; + min-height: 20px; +} + +#info_box { + font-size: smaller; + display: inline-block; + border: solid 1px $primary-neutral-light-color; + vertical-align: top; + padding: 2px; + margin: 4px; + margin-top: 60px; + min-width: 10%; + max-width: 30%; + min-height: 20px; + background: $white-color; +} + +#alert_box { + background: gold; +} + +/*---------------------------------NAV---------------------------------*/ + +nav { + display: block; + width: 90%; + margin: 0px auto; + background: $primary-color; + color: $white-color; + a { + color: $white-color; + font-style: normal; + font-weight: bolder; + text-decoration: none; + display: inline-block; + padding: 20px; + &:hover { + background: $primary-dark-color; + color: $white-color; + } + } +} + +/*--------------------------------CONTENT------------------------------*/ + +#quick_notif { + width: 90%; + margin: 0px auto; + list-style-type: none; + background: $primary-neutral-light-color; + li { + padding: 10px; + } +} + +#content { + width: 88%; + margin: 0px auto; + padding: 1em 1%; + background: $white-color; + overflow: auto; +} + +h1, h2, h3, h4, h5, h6 { + font-weight: bold; + margin-top: 0.5em; +} + +h1 { + font-size: 160%; + margin-left: 50px; +} + +h2 { + font-size: 150%; + margin-left: 40px; +} + +h3 { + font-size: 140%; + margin-left: 30px; +} + +h4 { + font-size: 130%; + margin-left: 20px; +} + +h5 { + font-size: 120%; + margin-left: 10px; +} + +h6 { + font-size: 110%; + margin-left: 0px; +} + +p, pre { + margin-top: 1em; + margin-left: 0px; +} + +ul, ol { + margin-top: 1em; + margin-bottom: 1em; + list-style-type: disc; + margin-left: 25px; +} + +code { + font-family: monospace; +} + +blockquote { + margin: 10px; + padding: 5px; + border: solid 1px $black-color; +} + +.edit-bar { + display: block; + margin: 4px; + a { + display: inline-block; + margin: 4px; + } +} + +.important { + font-size: 1.2em; + font-weight: bold; + color: red; +} + +table { + width: 100%; + font-size: 0.90em; +} + +td { + padding: 4px; + margin: 5px; + border: solid 1px $primary-neutral-color; + border-collapse: collapse; + vertical-align: top; + overflow: hidden; + text-overflow: ellipsis; + > ul { + margin-top: 0px; + } +} + +thead { + font-weight: bold; +} + +tbody > tr { + &:nth-child(even) { + background: $primary-neutral-light-color; + } + &:hover { + background: $secondary-neutral-light-color; + width: 100%; + } +} + +em { + font-style: italic; +} + +.highlight { + background: $second-color; + font-weight: bold; +} + +.underline { + text-decoration: underline; +} + +.tool-bar { + overflow: auto; + padding: 4px; +} + +.tools { + float: right; + border: 1px solid $primary-neutral-light-color; + a { + padding: 10px; + display: inline-block; + } +} + +.selected_tab { + background: $primary-neutral-light-color; +} + +#basket { + width: 40%; + background: $primary-neutral-light-color; + float: right; + padding: 10px; +} + +#products { + width: 90%; + margin: 0px auto; + overflow: auto; +} + +#bar_ui { + float: left; + min-width: 57%; +} + +#user_info_container {} + +#user_info { + float: right; + padding: 5px; + width: 40%; + margin: 0px auto; + background: $secondary-neutral-light-color; +} + +/*-----------------------------USER PROFILE----------------------------*/ + +#user_profile_container { + width: 80%; + margin: 0px auto; +} + +#user_profile { + width: 100%; + margin: 0px auto; + padding: 10px; + overflow: auto; + h4 { + border-bottom: 1px solid $primary-light-color; + max-width: 60%; + } + #left_column { + width: 59%; + } + #right_column { + width: 40%; + float: right; + font-style: italic; + } + #pictures { + max-width: 250px; + max-height: 300px; + margin: 0px auto; + } + #nickname { + font-style: italic; + } + #pictures img { + max-width: 96%; + max-height: 96%; + } + .promo_pict { + height: 45px; + } +} + +.mini_profile_link { + display: block; + text-decoration: none; + span { + display: inline-block; + width: 50px; + vertical-align: middle; + } + em { + vertical-align: middle; + } + img { + max-width: 40px; + max-height: 60px; + margin: 2px auto; + display: block; + } +} + +#notifications li { + padding: 5px; + margin: 2px; + list-style: none; +} + +#moderation { + div { + margin: 2px; + padding: 2px; + border: solid 1px red; + text-align: center; + } + img { + width: 500px; + } +} + +#pict { + display: inline-block; + width: 80%; + background: #333; + border: solid #333 2px; +} + +/*---------------------------------PAGE--------------------------------*/ + +.page_content { + display: block; + margin: 10px; + padding: 10px; + background: $white-color; + code { + font-family: monospace; + color: $white-color; + background: $black-color; + display: inline-block; + padding: 4px; + line-height: 120%; + } +} + +textarea { + white-space: pre; + width: 98%; + margin-top: 10px; +} + +/*---------------------------LAUNDERETTE-------------------------------*/ + +#token_form label { + display: inline; +} + +/*------------------------------FORUM----------------------------------*/ + +.topic a, .forum a, .category a { + color: $black-color; +} + +.topic a:hover, .forum a:hover, .category a:hover { + color: #424242; + text-decoration: underline; +} + +.topic { + border: solid $secondary-color 1px; + padding: 2px; + margin: 2px; +} + +.forum { + background: $secondary-light-color; + padding: 2px; + margin: 2px; +} + +.category { + background: $second-color; +} + +.message { + padding: 2px; + margin: 2px; + background: $white-color; + &:nth-child(odd) { + background: $secondary-neutral-light-color; + } + h5 { + font-size: 100%; + } + &.unread { + background: #d8e7f3; + } +} + +.msg_author.deleted { + background: #ffcfcf; +} + +.msg_content { + &.deleted { + background: #ffefef; + } + display: inline-block; + width: 80%; + vertical-align: top; +} + +.msg_author { + display: inline-block; + width: 19%; + text-align: center; + background: $secondary-neutral-light-color; + img { + max-width: 70%; + margin: 0px auto; + } +} + +.msg_meta { + font-size: small; + list-style-type: none; + li { + padding: 2px; + margin: 2px; + } +} + +.forum_signature { + color: #C0C0C0; + border-top: 1px solid #C0C0C0; + a { + color: #C0C0C0; + &:hover { + text-decoration: underline; + } + } +} + +/*------------------------------SAS------------------------------------*/ + +.album { + display: inline-block; + border: solid 1px $black-color; + text-align: center; + padding: 5px; + width: 200px; + height: 140px; + background: #eee; + box-shadow: black 2px 2px 10px; + margin: 10px; + vertical-align: top; + img { + max-height: 100px; + } +} + +.picture { + display: inline-block; + border: solid 1px $black-color; + width: 150px; + height: 100px; + margin: 5px; + background: #eee; + box-shadow: grey 2px 2px 5px; + padding: 2px; + vertical-align: middle; + img { + max-width: 100%; + max-height: 100px; + display: block; + margin: auto; + } +} + +.not_moderated { + border: solid 1px red; + box-shadow: red 2px 2px 10px; +} + +/*--------------------------------FOOTER-------------------------------*/ + +footer { + text-align: center; + div { + margin-top: 25px; + margin-bottom: 15px; + } + a { + margin: 1px 20px; + } +} + +/*---------------------------------FORMS-------------------------------*/ + +form { + margin: 0px auto; + width: 60%; +} + +label { + display: block; +} + +.choose_file_widget { + display: none; +} + +.ui-dialog .ui-dialog-buttonpane { + bottom: 0px; + position: absolute; + width: 97%; +} + +#user_edit { + * { + text-align: center; + } + img { + width: 100px; + } +} + +#cash_summary_form label, .inline { + display: inline; +} + +.form_button { + width: 150px; + height: 120px; + padding: 2px; + display: inline-block; + font-size: 0.8em; + span { + width: 70px; + float: right; + } + img { + max-width: 50px; + max-height: 50px; + float: left; + } + strong { + font-weight: bold; + font-size: 1.2em; + } + button { + width: 100%; + height: 100%; + vertical-align: middle; + } +} \ No newline at end of file diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja index 7dd1c37d..1144b7cd 100644 --- a/core/templates/core/base.jinja +++ b/core/templates/core/base.jinja @@ -8,7 +8,7 @@ - + {% endblock %} diff --git a/requirements.txt b/requirements.txt index 88ba05c1..0660033b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,5 +12,7 @@ reportlab django-haystack whoosh django-debug-toolbar +libsass +django-compressor +django-sass-processor # mysqlclient - diff --git a/sith/settings.py b/sith/settings.py index 04cc00d2..93e06ceb 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -72,6 +72,7 @@ INSTALLED_APPS = ( 'rest_framework', 'ajax_select', 'haystack', + 'sass_processor', 'core', 'club', 'subscription', @@ -133,6 +134,7 @@ TEMPLATES = [ "django_jinja.builtins.extensions.UrlsExtension", "django_jinja.builtins.extensions.StaticFilesExtension", "django_jinja.builtins.extensions.DjangoFiltersExtension", + "sass_processor.jinja2.ext.SassSrc", ], "filters": { "markdown": "core.templatetags.renderer.markdown", @@ -182,6 +184,12 @@ HAYSTACK_CONNECTIONS = { HAYSTACK_SIGNAL_PROCESSOR = 'core.search_indexes.UserOnlySignalProcessor' +SASS_PRECISION = 8 + +SASS_OUTPUT_STYLE = 'compact' + +SASS_TEMPLATE_EXTS = ['.html','.jinja'] + WSGI_APPLICATION = 'sith.wsgi.application' @@ -230,6 +238,13 @@ MEDIA_URL = '/data/' STATIC_URL = '/static/' STATIC_ROOT = './static/' +# Static files finders which allow to see static folder in all apps +STATICFILES_FINDERS = [ + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', + 'sass_processor.finders.CssFinder', +] + # Auth configuration AUTH_USER_MODEL = 'core.User' AUTH_ANONYMOUS_MODEL = 'core.models.AnonymousUser' From ee7fd1c423c1f0ae0240b8ba02ec476704245a0c Mon Sep 17 00:00:00 2001 From: klmp200 Date: Mon, 1 May 2017 15:46:40 +0200 Subject: [PATCH 02/10] Rename temporary_design --- core/static/core/style.css | 583 ------------------ .../{temporary_design.scss => style.scss} | 0 core/templates/core/base.jinja | 2 +- 3 files changed, 1 insertion(+), 584 deletions(-) delete mode 100644 core/static/core/style.css rename core/static/core/{temporary_design.scss => style.scss} (100%) diff --git a/core/static/core/style.css b/core/static/core/style.css deleted file mode 100644 index 8d841061..00000000 --- a/core/static/core/style.css +++ /dev/null @@ -1,583 +0,0 @@ -/*--------------------------------GENERAL------------------------------*/ -body{ - background-color:#EEE; - position: relative; - width: 100%; - font-family: sans-serif; -} -a { - text-decoration: none; - color: #265C83; -} -a:hover { color: #7FDBFF; } -a:active { color: #007BE6; } -.ib { - display: inline-block; - padding: 2px; - margin: 2px; -} -.w_big { - width: 75%; -} -.w_medium { - width: 45%; -} -.w_small { - width: 20%; -} -/*--------------------------------HEADER-------------------------------*/ -#logo { - margin-left: 5%; - display: inline-block; -} -header { - display: block; - position: absolute; - top : 0px; - right : 2%; - background-color:#DDD; - margin: 0 10px; - padding: 0 10px; - border-radius: 0 0 10px 10px; -} -header ul { - display: inline-block; - list-style-type: none; - margin: 0px; - padding-right: 3px; - vertical-align: middle; -} -header a { - display: inline-block; - color: inherit; - text-decoration: none; - padding: 1em; -} -header a:hover { - color: #265C83; -} -header form { - display: inline-block; - padding: 1em; - width: 150px; -} -#popupheader { - width: 88%; - margin: 0px auto; - padding: 0.3em 1%; -} -#language_chooser { - position: absolute; - text-align: center; - left: 5px; - top: 5px; -} - -#language_chooser input { - margin: 2px; - width: 3em; - height: 2em; -} -#notif { - display: none; - position: absolute; - background: lightgrey; - text-align: center; - overflow: scroll; - max-height: 400px; -} -#notif li:hover { - background: #bcc; -} - -#alert_box p, #info_box p { - margin: 0px; - padding: 0px; -} -#alert_box, #info_box { - font-size: smaller; - display: inline-block; - border: solid 1px grey; - vertical-align: top; - padding: 2px; - margin: 4px; - margin-top: 60px; - min-width: 10%; - max-width: 30%; - min-height: 20px; -} -#info_box { - background: cornsilk -} -#alert_box { - background: gold; -} - -/*---------------------------------NAV---------------------------------*/ -nav { - display: block; - width: 90%; - margin: 0px auto; - background: grey; - color: white; -} - -nav a { - color: white; - font-style: normal; - font-weight: bolder; - text-decoration: none; - display: inline-block; - padding: 20px; -} -nav a:hover { - background: #535353; - color: white; -} - -/*--------------------------------CONTENT------------------------------*/ -#quick_notif { - width: 90%; - margin: 0px auto; - list-style-type: none; - background: lightblue; -} -#quick_notif li { - padding: 10px; -} -#content { - width: 88%; - margin: 0px auto; - padding: 1em 1%; - background: white; - overflow: auto; -} - -h1, h2, h3, h4, h5, h6 { - font-weight: bold; - margin-top: 0.5em; -} - -h1 { - font-size: 160%; - margin-left: 50px; -} - -h2 { - font-size: 150%; - margin-left: 40px; -} - -h3 { - font-size: 140%; - margin-left: 30px; -} - -h4 { - font-size: 130%; - margin-left: 20px; -} - -h5 { - font-size: 120%; - margin-left: 10px; -} - -h6 { - font-size: 110%; - margin-left: 0px; -} - -p, pre { - margin-top: 1em; - margin-left: 0px; -} - -ul, ol { - margin-top: 1em; - margin-bottom: 1em; - list-style-type: disc; - margin-left: 25px; -} - -code { - font-family: monospace; -} -blockquote { - margin: 10px; - padding: 5px; - border: solid 1px black; -} -.edit-bar { - display: block; - margin: 4px; -} -.edit-bar a { - display: inline-block; - margin: 4px; -} -.important { - font-size: 1.2em; - font-weight: bold; - color: red; -} -table { - width: 100%; - font-size: 0.90em; -} -td { - padding: 4px; - margin: 5px; - border: solid 1px darkgrey; - border-collapse: collapse; - vertical-align: top; - overflow: hidden; - text-overflow: ellipsis; -} -td>ul { - margin-top: 0px; -} -thead { - font-weight: bold; -} -tbody>tr:nth-child(even) { - background: lightgrey; -} -tbody>tr:hover { - background: darkgrey; - width: 100%; -} -em { - font-style: italic; -} -.highlight { - background: orange; - font-weight: bold; -} -.underline { - text-decoration: underline; -} -.tool-bar { - overflow: auto; - padding: 4px; -} -.tools { - float: right; - border: 1px solid grey; -} -.tools a { - padding: 10px; - display: inline-block; -} -.selected_tab { - background: lightgrey; -} -#basket { - width: 40%; - background: lightgrey; - float: right; - padding: 10px; -} -#products { - width: 90%; - margin: 0px auto; - overflow: auto; -} -#bar_ui { - float: left; - min-width: 57%; -} -#user_info_container { -} -#user_info { - float: right; - padding: 5px; - width: 40%; - margin: 0px auto; - background: lightgrey; -} - -/*-----------------------------USER PROFILE----------------------------*/ -#user_profile_container { - width: 80%; - margin: 0px auto; -} -#user_profile { - width: 100%; - margin: 0px auto; - padding: 10px; - overflow: auto; -} -#user_profile h4 { border-bottom: 1px solid grey; max-width: 60%; } -#user_profile #left_column { - width: 59%; -} -#user_profile #right_column { - width: 40%; - float: right; - font-style: italic; -} -#user_profile #pictures { - max-width: 250px; - max-height: 300px; - margin: 0px auto; -} -#user_profile #nickname { - font-style: italic; -} -#user_profile #pictures img { - max-width: 96%; - max-height: 96%; -} -#user_profile .promo_pict { - height: 45px; -} -.mini_profile_link { - display: block; - text-decoration: none; -} -.mini_profile_link span { - display: inline-block; - width: 50px; - vertical-align: middle; -} -.mini_profile_link em { - vertical-align: middle; -} -.mini_profile_link img { - max-width: 40px; - max-height: 60px; - margin: 2px auto; - display: block; -} -#notifications li { - padding: 5px; - margin: 2px; - list-style: none; -} -#moderation div { - margin: 2px; - padding: 2px; - border: solid 1px red; - text-align: center -} -#moderation img { - width: 500px; -} -#pict { - display: inline-block; - width: 80%; - background: #333; - border: solid #333 2px; -} -/*---------------------------------PAGE--------------------------------*/ -.page_content { - display: block; - margin: 10px; - padding: 10px; - background: white; -} - -.page_content code { - font-family: monospace; - color: white; - background: black; - display: inline-block; - padding: 4px; - line-height: 120%; -} -textarea { - white-space: pre; - width: 98%; - margin-top: 10px; -} -/*---------------------------LAUNDERETTE-------------------------------*/ -#token_form label { - display: inline; -} - -/*------------------------------FORUM----------------------------------*/ -.topic a, .forum a, .category a { - color: black; -} -.topic a:hover, .forum a:hover, .category a:hover { - color: #424242; - text-decoration: underline; -} -.topic { - border: solid skyblue 1px; - padding: 2px; - margin: 2px; -} -.forum { - background: lightblue; - padding: 2px; - margin: 2px; -} -.category { - background: skyblue; -} -.message { - padding: 2px; - margin: 2px; - background: #eff7ff; -} -.message:nth-child(odd) { - background: #fff; -} -.message h5 { - font-size: 100%; -} -.message.unread { - background: #d8e7f3; -} -.msg_author.deleted { - background: #ffcfcf; -} -.msg_content.deleted { - background: #ffefef; -} -.msg_content { - display: inline-block; - width: 80%; - vertical-align: top; -} -.msg_author { - display: inline-block; - width: 19%; - text-align: center; - background: #d8e7f3; -} -.msg_author img { - max-width: 70%; - margin: 0px auto; -} -.msg_meta { - font-size: small; - list-style-type: none; -} -.msg_meta li { - padding: 2px; - margin: 2px; -} -.forum_signature { - color: #C0C0C0; - border-top: 1px solid #C0C0C0; -} -.forum_signature a { - color: #C0C0C0; -} -.forum_signature a:hover { - text-decoration: underline; -} -/*------------------------------SAS------------------------------------*/ -.album { - display: inline-block; - border: solid 1px black; - text-align: center; - padding: 5px; - width: 200px; - height: 140px; - background: #eee; - box-shadow: black 2px 2px 10px; - margin: 10px; - vertical-align: top; -} - -.album img { - max-height: 100px; -} - -.picture { - display: inline-block; - border: solid 1px black; - width: 150px; - height: 100px; - margin: 5px; - background: #eee; - box-shadow: grey 2px 2px 5px; - padding: 2px; - vertical-align: middle; -} - -.picture img { - max-width: 100%; - max-height: 100px; - display: block; - margin: auto; -} -.not_moderated { - border: solid 1px red; - box-shadow: red 2px 2px 10px; -} - -/*--------------------------------FOOTER-------------------------------*/ -footer{ - text-align: center; -} - -footer div{ - margin-top: 25px; - margin-bottom: 15px; -} - -footer a{ - margin: 1px 20px; -} - -/*---------------------------------FORMS-------------------------------*/ -form { - margin: 0px auto; - width: 60%; -} -label { - display: block; -} -.choose_file_widget { - display: none; -} -.ui-dialog .ui-dialog-buttonpane { - bottom: 0px; - position: absolute; - width: 97%; -} -#user_edit * { - text-align: center; - -} -#user_edit img { - width: 100px; -} -#cash_summary_form label { - display: inline; -} -.inline { - display: inline; -} -.form_button { - width: 150px; - height: 120px; - padding: 2px; - display: inline-block; - font-size: 0.8em; -} -.form_button span { - width: 70px; - float: right; -} -.form_button img { - max-width: 50px; - max-height: 50px; - float: left; -} -.form_button strong { - font-weight: bold; - font-size: 1.2em; -} -.form_button button { - width: 100%; - height: 100%; - vertical-align: middle; -} - - diff --git a/core/static/core/temporary_design.scss b/core/static/core/style.scss similarity index 100% rename from core/static/core/temporary_design.scss rename to core/static/core/style.scss diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja index 1144b7cd..33842017 100644 --- a/core/templates/core/base.jinja +++ b/core/templates/core/base.jinja @@ -8,7 +8,7 @@ - + {% endblock %} From b23d322a29a88f402a061d98f1d4f9e20ac98bc6 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Mon, 1 May 2017 15:48:45 +0200 Subject: [PATCH 03/10] Instruction for prod with scss --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index d1cbea94..efa83cea 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,12 @@ sudo apt install libmysqlclient-dev libssl-dev libjpeg-dev zlib1g-dev python3-de The development is done with sqlite, but it is advised to set a more robust DBMS for production (Postgresql for example) +### Collecting statics for production: + +``` +./manage.py collectstatic --ignore=.scss +./manage.py compilescss +``` ### Misc about development From 79c769351d46ac587aba5a4b68146dcf48b793f7 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Tue, 2 May 2017 00:31:21 +0200 Subject: [PATCH 04/10] Add simple way to compile scss files --- README.md | 4 +- core/management/commands/compilestatic.py | 72 +++++++++++++++++++++++ sith/settings.py | 2 +- 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 core/management/commands/compilestatic.py diff --git a/README.md b/README.md index efa83cea..3b0c2b1d 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,8 @@ The development is done with sqlite, but it is advised to set a more robust DBMS ### Collecting statics for production: ``` -./manage.py collectstatic --ignore=.scss -./manage.py compilescss +./manage.py collectstatic +./manage.py compilestatic ``` ### Misc about development diff --git a/core/management/commands/compilestatic.py b/core/management/commands/compilestatic.py new file mode 100644 index 00000000..a4fd89df --- /dev/null +++ b/core/management/commands/compilestatic.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +# -*- coding:utf-8 -* +# +# Copyright 2016,2017 +# - Sli +# +# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, +# http://ae.utbm.fr. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License a published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple +# Place - Suite 330, Boston, MA 02111-1307, USA. +# +# + +import os +import sass +from django.core.management.base import BaseCommand + +class Command(BaseCommand): + help = "Comile scss files from static folder" + + def compilescss(self, folder): + to_compile = [] + for file in os.listdir(folder): + file = os.path.join(folder, file) + if os.path.isdir(file): + self.compilescss(file) + else: + path, ext = os.path.splitext(file) + if ext == ".scss": + to_compile.append(file) + + for f in to_compile: + print("compilling %s" % f) + with open(f, "r") as oldfile: + with open(f.replace('.scss', '.css'), "w") as newfile: + newfile.write(sass.compile(string=oldfile.read())) + + def removescss(self, folder): + to_remove = [] + for file in os.listdir(folder): + file = os.path.join(folder, file) + if os.path.isdir(file): + self.removescss(file) + else: + path, ext = os.path.splitext(file) + if ext == ".scss": + to_remove.append(file) + for f in to_remove: + print("removing %s" % f) + os.remove(f) + + def handle(self, *args, **options): + + if 'static' in os.listdir(): + print("---- Compilling scss files ---") + self.compilescss('static') + print("---- Removing scss files ----") + self.removescss('static') + else: + print("No static folder avaliable, please use collectstatic before compilling scss") \ No newline at end of file diff --git a/sith/settings.py b/sith/settings.py index 93e06ceb..d4eb721d 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -188,7 +188,7 @@ SASS_PRECISION = 8 SASS_OUTPUT_STYLE = 'compact' -SASS_TEMPLATE_EXTS = ['.html','.jinja'] +SASS_TEMPLATE_EXTS = ['.jinja'] WSGI_APPLICATION = 'sith.wsgi.application' From 630fdf93a4c2ae4bc1a6317dcbc3dad023cc04ee Mon Sep 17 00:00:00 2001 From: klmp200 Date: Tue, 2 May 2017 00:51:43 +0200 Subject: [PATCH 05/10] Refactoring for compilestatic --- core/management/commands/compilestatic.py | 55 +++++++++++------------ sith/toolbar_debug.py | 2 +- 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/core/management/commands/compilestatic.py b/core/management/commands/compilestatic.py index a4fd89df..46e7596e 100644 --- a/core/management/commands/compilestatic.py +++ b/core/management/commands/compilestatic.py @@ -28,45 +28,40 @@ import sass from django.core.management.base import BaseCommand class Command(BaseCommand): - help = "Comile scss files from static folder" + help = "Compile scss files from static folder" - def compilescss(self, folder): - to_compile = [] + def is_compilable(self, file, ext_list): + path, ext = os.path.splitext(file) + return ext in ext_list + + def exec_on_folder(self, folder, func): + to_exec = [] for file in os.listdir(folder): file = os.path.join(folder, file) if os.path.isdir(file): - self.compilescss(file) - else: - path, ext = os.path.splitext(file) - if ext == ".scss": - to_compile.append(file) + self.exec_on_folder(file, func) + elif self.is_compilable(file, ['.scss']): + to_exec.append(file) - for f in to_compile: - print("compilling %s" % f) - with open(f, "r") as oldfile: - with open(f.replace('.scss', '.css'), "w") as newfile: - newfile.write(sass.compile(string=oldfile.read())) + for file in to_exec: + func(file) - def removescss(self, folder): - to_remove = [] - for file in os.listdir(folder): - file = os.path.join(folder, file) - if os.path.isdir(file): - self.removescss(file) - else: - path, ext = os.path.splitext(file) - if ext == ".scss": - to_remove.append(file) - for f in to_remove: - print("removing %s" % f) - os.remove(f) + def compilescss(self, file): + print("compiling %s" % file) + with open(file, "r") as oldfile: + with open(file.replace('.scss', '.css'), "w") as newfile: + newfile.write(sass.compile(string=oldfile.read())) + + def removescss(self, file): + print("removing %s" % file) + os.remove(file) def handle(self, *args, **options): if 'static' in os.listdir(): - print("---- Compilling scss files ---") - self.compilescss('static') + print("---- Compiling scss files ---") + self.exec_on_folder('static', self.compilescss) print("---- Removing scss files ----") - self.removescss('static') + self.exec_on_folder('static', self.removescss) else: - print("No static folder avaliable, please use collectstatic before compilling scss") \ No newline at end of file + print("No static folder avalaible, please use collectstatic before compiling scss") \ No newline at end of file diff --git a/sith/toolbar_debug.py b/sith/toolbar_debug.py index f30c74c2..feae0669 100644 --- a/sith/toolbar_debug.py +++ b/sith/toolbar_debug.py @@ -1,7 +1,7 @@ # -*- coding:utf-8 -* # # Copyright 2016,2017 -# - Skia +# - Sli # # Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, # http://ae.utbm.fr. From acef5be8b39975f4d591ddcd7d3ba8337419ada5 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Fri, 5 May 2017 14:26:46 +0200 Subject: [PATCH 06/10] New lite home made scss processor --- core/management/commands/compilestatic.py | 25 +++++--- core/scss/finder.py | 54 ++++++++++++++++ core/scss/processor.py | 76 +++++++++++++++++++++++ core/scss/storage.py | 44 +++++++++++++ core/templates/core/base.jinja | 3 +- core/templatetags/scss.py | 35 +++++++++++ requirements.txt | 2 - sith/settings.py | 12 ++-- 8 files changed, 234 insertions(+), 17 deletions(-) create mode 100644 core/scss/finder.py create mode 100644 core/scss/processor.py create mode 100644 core/scss/storage.py create mode 100644 core/templatetags/scss.py diff --git a/core/management/commands/compilestatic.py b/core/management/commands/compilestatic.py index 46e7596e..88436fd9 100644 --- a/core/management/commands/compilestatic.py +++ b/core/management/commands/compilestatic.py @@ -26,10 +26,22 @@ import os import sass from django.core.management.base import BaseCommand +from django.conf import settings + class Command(BaseCommand): help = "Compile scss files from static folder" + def compile(self, filename): + args = { + "filename": filename, + "include_paths": settings.STATIC_ROOT, + } + if settings.SASS_PRECISION: + args['precision'] = settings.SASS_PRECISION + return sass.compile(**args) + + def is_compilable(self, file, ext_list): path, ext = os.path.splitext(file) return ext in ext_list @@ -48,9 +60,8 @@ class Command(BaseCommand): def compilescss(self, file): print("compiling %s" % file) - with open(file, "r") as oldfile: - with open(file.replace('.scss', '.css'), "w") as newfile: - newfile.write(sass.compile(string=oldfile.read())) + with(open(file.replace('.scss', '.css'), "w")) as newfile: + newfile.write(self.compile(file)) def removescss(self, file): print("removing %s" % file) @@ -58,10 +69,10 @@ class Command(BaseCommand): def handle(self, *args, **options): - if 'static' in os.listdir(): + if os.path.isdir(settings.STATIC_ROOT): print("---- Compiling scss files ---") - self.exec_on_folder('static', self.compilescss) + self.exec_on_folder(settings.STATIC_ROOT, self.compilescss) print("---- Removing scss files ----") - self.exec_on_folder('static', self.removescss) + self.exec_on_folder(settings.STATIC_ROOT, self.removescss) else: - print("No static folder avalaible, please use collectstatic before compiling scss") \ No newline at end of file + print("No static folder avalaible, please use collectstatic before compiling scss") diff --git a/core/scss/finder.py b/core/scss/finder.py new file mode 100644 index 00000000..c9ef0859 --- /dev/null +++ b/core/scss/finder.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +# -*- coding:utf-8 -* +# +# Copyright 2016,2017 +# - Sli +# +# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, +# http://ae.utbm.fr. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License a published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple +# Place - Suite 330, Boston, MA 02111-1307, USA. +# +# + +import os +from collections import OrderedDict +from django.conf import settings +from django.contrib.staticfiles.finders import FileSystemFinder +from django.core.files.storage import FileSystemStorage + + +class ScssFinder(FileSystemFinder): + """ + Find static *.css files compiled on the fly + """ + locations = [] + + def __init__(self, apps=None, *args, **kwargs): + location = settings.STATIC_ROOT + if not os.path.isdir(location): + return + self.locations = [ + ('', location), + ] + self.storages = OrderedDict() + filesystem_storage = FileSystemStorage(location=location) + filesystem_storage.prefix = self.locations[0][0] + self.storages[location] = filesystem_storage + + def find(self, path, all=False): + if path.endswith('.css'): + return super(ScssFinder, self).find(path, all) + return [] diff --git a/core/scss/processor.py b/core/scss/processor.py new file mode 100644 index 00000000..a4109759 --- /dev/null +++ b/core/scss/processor.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 +# -*- coding:utf-8 -* +# +# Copyright 2016,2017 +# - Sli +# +# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, +# http://ae.utbm.fr. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License a published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple +# Place - Suite 330, Boston, MA 02111-1307, USA. +# +# + +import os +import sass +from django.utils.encoding import force_bytes, iri_to_uri +from django.core.files.base import ContentFile +from django.utils.six.moves.urllib.parse import urljoin +from django.templatetags.static import static +from django.conf import settings +from .storage import ScssFileStorage, find_file + + +class ScssProcessor(object): + prefix = iri_to_uri(getattr(settings, 'STATIC_URL', '/static/')) + storage = ScssFileStorage() + scss_extensions = [".scss"] + + def __init__(self, path=None): + self.path = path + + def _convert_scss(self): + basename, ext = os.path.splitext(self.path) + css_filename = self.path.replace(".scss", ".css") + url = urljoin(self.prefix, css_filename) + + if not settings.DEBUG: + return url + + if ext not in self.scss_extensions: + return static(self.path) + + # Compilation on the fly + compile_args = { + "filename": find_file(self.path), + "include_paths": settings.SASS_INCLUDE_FOLDERS, + } + if settings.SASS_PRECISION: + compile_args['precision'] = settings.SASS_PRECISION + content = sass.compile(**compile_args) + content = force_bytes(content) + + if self.storage.exists(css_filename): + self.storage.delete(css_filename) + self.storage.save(css_filename, ContentFile(content)) + print("saved") + + return url + + def get_converted_scss(self): + if self.path: + return self._convert_scss() + else: + return "" diff --git a/core/scss/storage.py b/core/scss/storage.py new file mode 100644 index 00000000..242e8ff4 --- /dev/null +++ b/core/scss/storage.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +# -*- coding:utf-8 -* +# +# Copyright 2016,2017 +# - Sli +# +# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, +# http://ae.utbm.fr. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License a published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple +# Place - Suite 330, Boston, MA 02111-1307, USA. +# +# + +from django.conf import settings +from django.contrib.staticfiles.finders import get_finders +from django.core.files.storage import FileSystemStorage + + +class ScssFileStorage(FileSystemStorage): + def __init__(self, location=None, base_url=None, *args, **kwargs): + if location is None: + location = settings.STATIC_ROOT + if base_url is None: + base_url = settings.STATIC_URL + super(ScssFileStorage, self).__init__(location, base_url, *args, **kwargs) + + +def find_file(path): + for finder in get_finders(): + result = finder.find(path) + if result: + return result diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja index 33842017..a07a0257 100644 --- a/core/templates/core/base.jinja +++ b/core/templates/core/base.jinja @@ -8,7 +8,8 @@ - + {# #} + {% endblock %} diff --git a/core/templatetags/scss.py b/core/templatetags/scss.py new file mode 100644 index 00000000..da929983 --- /dev/null +++ b/core/templatetags/scss.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# -*- coding:utf-8 -* +# +# Copyright 2016,2017 +# - Sli +# +# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, +# http://ae.utbm.fr. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License a published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple +# Place - Suite 330, Boston, MA 02111-1307, USA. +# +# + +from django import template +from core.scss.processor import ScssProcessor + +register = template.Library() + + +@register.simple_tag() +def scss(path): + processor = ScssProcessor(path) + return processor.get_converted_scss() diff --git a/requirements.txt b/requirements.txt index 0660033b..53648d48 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,6 +13,4 @@ django-haystack whoosh django-debug-toolbar libsass -django-compressor -django-sass-processor # mysqlclient diff --git a/sith/settings.py b/sith/settings.py index d4eb721d..43ab6dd3 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -72,7 +72,6 @@ INSTALLED_APPS = ( 'rest_framework', 'ajax_select', 'haystack', - 'sass_processor', 'core', 'club', 'subscription', @@ -134,7 +133,6 @@ TEMPLATES = [ "django_jinja.builtins.extensions.UrlsExtension", "django_jinja.builtins.extensions.StaticFilesExtension", "django_jinja.builtins.extensions.DjangoFiltersExtension", - "sass_processor.jinja2.ext.SassSrc", ], "filters": { "markdown": "core.templatetags.renderer.markdown", @@ -149,6 +147,7 @@ TEMPLATES = [ "ProductType": "counter.models.ProductType", "timezone": "django.utils.timezone", "get_sith": "com.views.sith", + "scss": "core.templatetags.scss.scss", }, "bytecode_cache": { "name": "default", @@ -186,10 +185,6 @@ HAYSTACK_SIGNAL_PROCESSOR = 'core.search_indexes.UserOnlySignalProcessor' SASS_PRECISION = 8 -SASS_OUTPUT_STYLE = 'compact' - -SASS_TEMPLATE_EXTS = ['.jinja'] - WSGI_APPLICATION = 'sith.wsgi.application' @@ -242,7 +237,7 @@ STATIC_ROOT = './static/' STATICFILES_FINDERS = [ 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', - 'sass_processor.finders.CssFinder', + 'core.scss.finder.ScssFinder', ] # Auth configuration @@ -567,3 +562,6 @@ if DEBUG: 'debug_toolbar.panels.logging.LoggingPanel', 'debug_toolbar.panels.redirects.RedirectsPanel', ] + SASS_INCLUDE_FOLDERS = [ + 'core/static/', + ] From d083a67725d81b42bae04a775a3d2a94efebb377 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Fri, 5 May 2017 14:59:39 +0200 Subject: [PATCH 07/10] Change year of license on some files --- core/management/commands/compilestatic.py | 2 +- core/scss/processor.py | 3 +-- core/scss/storage.py | 2 +- core/templatetags/scss.py | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/core/management/commands/compilestatic.py b/core/management/commands/compilestatic.py index 88436fd9..45e84576 100644 --- a/core/management/commands/compilestatic.py +++ b/core/management/commands/compilestatic.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding:utf-8 -* # -# Copyright 2016,2017 +# Copyright 2017 # - Sli # # Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, diff --git a/core/scss/processor.py b/core/scss/processor.py index a4109759..2624825a 100644 --- a/core/scss/processor.py +++ b/core/scss/processor.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding:utf-8 -* # -# Copyright 2016,2017 +# Copyright 2017 # - Sli # # Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, @@ -65,7 +65,6 @@ class ScssProcessor(object): if self.storage.exists(css_filename): self.storage.delete(css_filename) self.storage.save(css_filename, ContentFile(content)) - print("saved") return url diff --git a/core/scss/storage.py b/core/scss/storage.py index 242e8ff4..e24fd406 100644 --- a/core/scss/storage.py +++ b/core/scss/storage.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding:utf-8 -* # -# Copyright 2016,2017 +# Copyright 2017 # - Sli # # Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, diff --git a/core/templatetags/scss.py b/core/templatetags/scss.py index da929983..6e546186 100644 --- a/core/templatetags/scss.py +++ b/core/templatetags/scss.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding:utf-8 -* # -# Copyright 2016,2017 +# Copyright 2017 # - Sli # # Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, From f87ec1e3952692210c5cba4f29a0e6ff61d44aca Mon Sep 17 00:00:00 2001 From: klmp200 Date: Mon, 8 May 2017 02:30:13 +0200 Subject: [PATCH 08/10] Better lisibility for scss --- core/scss/processor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/scss/processor.py b/core/scss/processor.py index 2624825a..54b82b4b 100644 --- a/core/scss/processor.py +++ b/core/scss/processor.py @@ -30,7 +30,7 @@ from django.core.files.base import ContentFile from django.utils.six.moves.urllib.parse import urljoin from django.templatetags.static import static from django.conf import settings -from .storage import ScssFileStorage, find_file +from core.scss.storage import ScssFileStorage, find_file class ScssProcessor(object): From 200af57971684d2c8060ca1eaebec7e8260e962f Mon Sep 17 00:00:00 2001 From: klmp200 Date: Tue, 9 May 2017 14:25:25 +0200 Subject: [PATCH 09/10] Put scss in renderer --- core/templates/core/base.jinja | 1 - core/templatetags/renderer.py | 7 ++++++- core/templatetags/scss.py | 35 ---------------------------------- sith/settings.py | 2 +- 4 files changed, 7 insertions(+), 38 deletions(-) delete mode 100644 core/templatetags/scss.py diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja index a07a0257..fc3f6ea3 100644 --- a/core/templates/core/base.jinja +++ b/core/templates/core/base.jinja @@ -8,7 +8,6 @@ - {# #} {% endblock %} diff --git a/core/templatetags/renderer.py b/core/templatetags/renderer.py index af75d54d..5fc63458 100644 --- a/core/templatetags/renderer.py +++ b/core/templatetags/renderer.py @@ -2,6 +2,7 @@ # # Copyright 2016,2017 # - Skia +# - Sli # # Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, # http://ae.utbm.fr. @@ -25,6 +26,7 @@ from django import template from django.template.defaultfilters import stringfilter from django.utils.safestring import mark_safe +from core.scss.processor import ScssProcessor from django.utils.html import escape from core.markdown import markdown as md @@ -49,4 +51,7 @@ def datetime_format_python_to_PHP(python_format_string): php_format_string = php_format_string.replace(py, php) return php_format_string - +@register.simple_tag() +def scss(path): + processor = ScssProcessor(path) + return processor.get_converted_scss() \ No newline at end of file diff --git a/core/templatetags/scss.py b/core/templatetags/scss.py deleted file mode 100644 index 6e546186..00000000 --- a/core/templatetags/scss.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding:utf-8 -* -# -# Copyright 2017 -# - Sli -# -# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, -# http://ae.utbm.fr. -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License a published by the Free Software -# Foundation; either version 3 of the License, or (at your option) any later -# version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple -# Place - Suite 330, Boston, MA 02111-1307, USA. -# -# - -from django import template -from core.scss.processor import ScssProcessor - -register = template.Library() - - -@register.simple_tag() -def scss(path): - processor = ScssProcessor(path) - return processor.get_converted_scss() diff --git a/sith/settings.py b/sith/settings.py index 43ab6dd3..9a5422a1 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -147,7 +147,7 @@ TEMPLATES = [ "ProductType": "counter.models.ProductType", "timezone": "django.utils.timezone", "get_sith": "com.views.sith", - "scss": "core.templatetags.scss.scss", + "scss": "core.templatetags.renderer.scss", }, "bytecode_cache": { "name": "default", From e59d769daca1307e3a75101603f121b211d1b370 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Wed, 10 May 2017 10:58:51 +0200 Subject: [PATCH 10/10] Doc for scss --- README.md | 6 ++++-- core/management/commands/compilestatic.py | 3 +++ core/scss/processor.py | 5 +++++ core/templatetags/renderer.py | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3b0c2b1d..654d37d7 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,11 @@ The development is done with sqlite, but it is advised to set a more robust DBMS ### Collecting statics for production: +We use scss in the project. In development environment (DEBUG=True), scss is compiled every time the file is needed. For production, it assumes you have already compiled every files and to do so, you need to use the following commands : + ``` -./manage.py collectstatic -./manage.py compilestatic +./manage.py collectstatic # To collect statics +./manage.py compilestatic # To compile scss in those statics ``` ### Misc about development diff --git a/core/management/commands/compilestatic.py b/core/management/commands/compilestatic.py index 45e84576..0d96c8ea 100644 --- a/core/management/commands/compilestatic.py +++ b/core/management/commands/compilestatic.py @@ -30,6 +30,9 @@ from django.conf import settings class Command(BaseCommand): + """ + Compiles scss in static folder for production + """ help = "Compile scss files from static folder" def compile(self, filename): diff --git a/core/scss/processor.py b/core/scss/processor.py index 54b82b4b..dab0de4c 100644 --- a/core/scss/processor.py +++ b/core/scss/processor.py @@ -34,6 +34,11 @@ from core.scss.storage import ScssFileStorage, find_file class ScssProcessor(object): + """ + If DEBUG mode enabled : compile the scss file + Else : give the path of the corresponding css supposed to already be compiled + Don't forget to use compilestatics to compile scss for production + """ prefix = iri_to_uri(getattr(settings, 'STATIC_URL', '/static/')) storage = ScssFileStorage() scss_extensions = [".scss"] diff --git a/core/templatetags/renderer.py b/core/templatetags/renderer.py index 5fc63458..23ae8d03 100644 --- a/core/templatetags/renderer.py +++ b/core/templatetags/renderer.py @@ -53,5 +53,8 @@ def datetime_format_python_to_PHP(python_format_string): @register.simple_tag() def scss(path): + """ + Return path of the corresponding css file after compilation + """ processor = ScssProcessor(path) return processor.get_converted_scss() \ No newline at end of file