Restructure scss file layout & task

This commit is contained in:
Sonny 2019-11-14 22:49:56 +01:00
parent bb0c2e792c
commit a350cc280d
48 changed files with 48 additions and 39 deletions

View file

@ -1,25 +1,33 @@
import { src, dest } from 'gulp'; import { dest, series, src } from 'gulp';
import concat from 'gulp-concat'; import concat from 'gulp-concat';
import path from 'path'; import path from 'path';
import sass from 'gulp-sass'; import sass from 'gulp-sass';
const PROJECT_DIR = path.join('src', 'newsreader'); const PROJECT_DIR = path.join('src', 'newsreader');
const STATIC_DIR = path.join(PROJECT_DIR, 'scss'); const SRC_DIR = path.join(PROJECT_DIR, 'scss');
const STATIC_SUFFIX = 'dist/css/';
export const ACCOUNTS_DIR = path.join(PROJECT_DIR, 'accounts', 'static'); export const ACCOUNTS_DIR = path.join(PROJECT_DIR, 'accounts', 'static', 'accounts');
export const CORE_DIR = path.join(PROJECT_DIR, 'news', 'core', 'static'); export const CORE_DIR = path.join(PROJECT_DIR, 'news', 'core', 'static', 'core');
export const accountsTask = () => { const taskMappings = [
return src(`${STATIC_DIR}/accounts/index.scss`) { name: 'login', destDir: `${ACCOUNTS_DIR}/${STATIC_SUFFIX}` },
{ name: 'homepage', destDir: `${CORE_DIR}/${STATIC_SUFFIX}` },
];
export const sassTask = done => {
const tasks = taskMappings.map(taskMapping => {
const name = taskMapping.name;
const destDir = taskMapping.destDir;
return () => {
return src(`${SRC_DIR}/pages/${name}/index.scss`)
.pipe(sass().on('error', sass.logError)) .pipe(sass().on('error', sass.logError))
.pipe(concat('accounts.css')) .pipe(concat(`${name}.css`))
.pipe(dest(`${ACCOUNTS_DIR}/accounts/dist/css`)); .pipe(dest(destDir));
}; };
});
export const coreTask = () => { series(...tasks)(done);
return src(`${STATIC_DIR}/homepage/index.scss`)
.pipe(sass().on('error', sass.logError))
.pipe(concat('core.css'))
.pipe(dest(`${CORE_DIR}/core/dist/css`));
}; };

View file

@ -3,11 +3,10 @@ import { parallel, series, watch as _watch } from 'gulp';
import path from 'path'; import path from 'path';
import del from 'del'; import del from 'del';
import { ACCOUNTS_DIR, CORE_DIR, accountsTask, coreTask } from './gulp/sass'; import { ACCOUNTS_DIR, CORE_DIR, sassTask } from './gulp/sass';
import babelTask from './gulp/babel'; import babelTask from './gulp/babel';
const PROJECT_DIR = path.join('src', 'newsreader'); const PROJECT_DIR = path.join('src', 'newsreader');
const sassTasks = [accountsTask, coreTask];
const clean = () => { const clean = () => {
return del([ return del([
@ -20,8 +19,8 @@ const clean = () => {
export const watch = () => { export const watch = () => {
return _watch([`${PROJECT_DIR}/scss/**/*.scss`, `${PROJECT_DIR}/js/**/*.js`], done => { return _watch([`${PROJECT_DIR}/scss/**/*.scss`, `${PROJECT_DIR}/js/**/*.js`], done => {
series(clean, ...sassTasks, babelTask)(done); series(clean, sassTask, babelTask)(done);
}); });
}; };
export default series(clean, ...sassTasks, babelTask); export default series(clean, sassTask, babelTask);

View file

@ -75,7 +75,7 @@ class User(AbstractUser):
every=1, period=IntervalSchedule.HOURS every=1, period=IntervalSchedule.HOURS
) )
self.task = PeriodicTask.objects.create( self.task, _ = PeriodicTask.objects.get_or_create(
enabled=True, enabled=True,
interval=self.task_interval, interval=self.task_interval,
name=f"{self.email}-collection-task", name=f"{self.email}-collection-task",

View file

@ -3,7 +3,7 @@
{% load static %} {% load static %}
{% block head %} {% block head %}
<link href="{% static 'accounts/dist/css/accounts.css' %}" rel="stylesheet" /> <link href="{% static 'accounts/dist/css/login.css' %}" rel="stylesheet" />
{% endblock %} {% endblock %}
{% block content %} {% block content %}

View file

@ -10,10 +10,10 @@ from newsreader.news.core.endpoints import (
NestedPostCategoryView, NestedPostCategoryView,
NestedRuleCategoryView, NestedRuleCategoryView,
) )
from newsreader.news.core.views import MainView from newsreader.news.core.views import NewsView
index_page = login_required(MainView.as_view()) index_page = login_required(NewsView.as_view())
endpoints = [ endpoints = [
path("posts/", ListPostView.as_view(), name="posts-list"), path("posts/", ListPostView.as_view(), name="posts-list"),

View file

@ -3,8 +3,8 @@ from typing import Dict
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
class MainView(TemplateView): class NewsView(TemplateView):
template_name = "core/main.html" template_name = "core/homepage.html"
# TODO serialize objects to show filled main page # TODO serialize objects to show filled main page
def get_context_data(self, **kwargs) -> Dict: def get_context_data(self, **kwargs) -> Dict:

View file

@ -1,6 +0,0 @@
// General imports
@import "../partials/variables";
@import "../components/index";
// Page specific
@import "./components/index";

View file

View file

@ -1,7 +0,0 @@
// General imports
@import "../partials/variables";
@import "../components/index";
// Page specific
@import "./components/index";
@import "./elements/index";

View file

@ -0,0 +1,8 @@
// General imports
@import "../../partials/variables";
@import "../../components/index";
@import "../../elements/index";
// Page specific
@import "./components/index";
@import "./elements/index";

View file

@ -0,0 +1,7 @@
// General imports
@import "../../partials/variables";
@import "../../components/index";
@import "../../elements/index";
// Page specific
@import "./components/index";