switched from sass to pyScss library
This commit is contained in:
+18
-19
@@ -19,7 +19,7 @@ import json
|
|||||||
# import git
|
# import git
|
||||||
# from pygit2 import Repository
|
# from pygit2 import Repository
|
||||||
|
|
||||||
from . import server, sasscompiler, md2html
|
from . import server, scsscompiler, md2html
|
||||||
|
|
||||||
# ______
|
# ______
|
||||||
# / ____/___ ________
|
# / ____/___ ________
|
||||||
@@ -56,7 +56,7 @@ class Core():
|
|||||||
|
|
||||||
def initDeamons(self):
|
def initDeamons(self):
|
||||||
self.server = server.Server(self)
|
self.server = server.Server(self)
|
||||||
self.sasscompiler = sasscompiler.Compiler(self)
|
self.scsscompiler = scsscompiler.Compiler(self)
|
||||||
self.contentcompiler = md2html.Compiler(self)
|
self.contentcompiler = md2html.Compiler(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -125,9 +125,9 @@ class Core():
|
|||||||
|
|
||||||
def updateScss(self, reload=True):
|
def updateScss(self, reload=True):
|
||||||
# print(self.docsettings)
|
# print(self.docsettings)
|
||||||
sassfilepath = os.path.join(self.cwd,'assets/css/setup.scss')
|
scssfilepath = os.path.join(self.cwd,'assets/css/setup.scss')
|
||||||
# print(sassfilepath)
|
# print(scssfilepath)
|
||||||
sass = open(sassfilepath,"r").read()
|
scss = open(scssfilepath,"r").read()
|
||||||
sets = {
|
sets = {
|
||||||
'pw':'page-width',
|
'pw':'page-width',
|
||||||
'ph':'page-height',
|
'ph':'page-height',
|
||||||
@@ -142,34 +142,34 @@ class Core():
|
|||||||
'lh':'line-height'
|
'lh':'line-height'
|
||||||
}
|
}
|
||||||
for s in sets:
|
for s in sets:
|
||||||
sass = re.sub(
|
scss = re.sub(
|
||||||
r'\$'+sets[s]+':\smm2pt\([0-9|\.]+\);',
|
r'\$'+sets[s]+':\smm2pt\([0-9|\.]+\);',
|
||||||
'$'+sets[s]+': mm2pt('+self.docsettings[s]+');',
|
'$'+sets[s]+': mm2pt('+self.docsettings[s]+');',
|
||||||
sass)
|
scss)
|
||||||
|
|
||||||
# $col-number: 9;
|
# $col-number: 9;
|
||||||
sass = re.sub(
|
scss = re.sub(
|
||||||
r'\$col-number:\s[0-9|\.]+;',
|
r'\$col-number:\s[0-9|\.]+;',
|
||||||
'$col-number: '+self.docsettings['cn']+';',
|
'$col-number: '+self.docsettings['cn']+';',
|
||||||
sass)
|
scss)
|
||||||
# $row-number: 12;
|
# $row-number: 12;
|
||||||
sass = re.sub(
|
scss = re.sub(
|
||||||
r'\$row-number:\s[0-9|\.]+;',
|
r'\$row-number:\s[0-9|\.]+;',
|
||||||
'$row-number: '+self.docsettings['rn']+';',
|
'$row-number: '+self.docsettings['rn']+';',
|
||||||
sass)
|
scss)
|
||||||
#$header-odd: "Libriis, default header";
|
#$header-odd: "Libriis, default header";
|
||||||
sass = re.sub(
|
scss = re.sub(
|
||||||
r'\$header-odd:\s".+";',
|
r'\$header-odd:\s".+";',
|
||||||
'$header-odd: "'+self.docsettings['ho']+'";',
|
'$header-odd: "'+self.docsettings['ho']+'";',
|
||||||
sass)
|
scss)
|
||||||
# $header-even: "Libriis, default header";
|
# $header-even: "Libriis, default header";
|
||||||
sass = re.sub(
|
scss = re.sub(
|
||||||
r'\$header-even:\s".+";',
|
r'\$header-even:\s".+";',
|
||||||
'$header-even: "'+self.docsettings['he']+'";',
|
'$header-even: "'+self.docsettings['he']+'";',
|
||||||
sass)
|
scss)
|
||||||
|
|
||||||
# print('sass', sass)
|
# print('scss', scss)
|
||||||
open(sassfilepath,"w").write(sass)
|
open(scssfilepath,"w").write(scss)
|
||||||
|
|
||||||
if reload:
|
if reload:
|
||||||
self._mw.designstack.webkitview.reload()
|
self._mw.designstack.webkitview.reload()
|
||||||
@@ -186,7 +186,6 @@ class Core():
|
|||||||
'nb_page='+str(self.docsettings['np'])+';',
|
'nb_page='+str(self.docsettings['np'])+';',
|
||||||
js)
|
js)
|
||||||
|
|
||||||
# print('sass', sass)
|
|
||||||
open(jsfilepath,"w").write(js)
|
open(jsfilepath,"w").write(js)
|
||||||
|
|
||||||
if reload:
|
if reload:
|
||||||
@@ -245,7 +244,7 @@ class Core():
|
|||||||
if not cwd == self.cwd:
|
if not cwd == self.cwd:
|
||||||
self.cwd = cwd
|
self.cwd = cwd
|
||||||
self.server.reload()
|
self.server.reload()
|
||||||
self.sasscompiler.reload()
|
self.scsscompiler.reload()
|
||||||
self.contentcompiler.reload()
|
self.contentcompiler.reload()
|
||||||
|
|
||||||
if not self.tempcwd:
|
if not self.tempcwd:
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ class Editor(QWidget):
|
|||||||
# Initialize tab screen
|
# Initialize tab screen
|
||||||
self.tabs = QTabWidget()
|
self.tabs = QTabWidget()
|
||||||
|
|
||||||
self.scsstab = CodeEditor(self, self.parent.core, self.tabs, 'assets/css/styles.scss', "sass")
|
self.scsstab = CodeEditor(self, self.parent.core, self.tabs, 'assets/css/styles.scss', "scss")
|
||||||
self.jstab = CodeEditor(self, self.parent.core, self.tabs, 'assets/js/script.js', 'js')
|
self.jstab = CodeEditor(self, self.parent.core, self.tabs, 'assets/js/script.js', 'js')
|
||||||
|
|
||||||
# Add tabs
|
# Add tabs
|
||||||
|
|||||||
@@ -348,6 +348,6 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
self.mainstack.setCurrentIndex(self.core.mw_curstack)
|
self.mainstack.setCurrentIndex(self.core.mw_curstack)
|
||||||
|
|
||||||
# TODO: add an app console window (show sass compilation errors for example)
|
# TODO: add an app console window (show scss compilation errors for example)
|
||||||
|
|
||||||
self.setCentralWidget(self.mainstack)
|
self.setCentralWidget(self.mainstack)
|
||||||
|
|||||||
@@ -70,7 +70,9 @@ class Compiler():
|
|||||||
# get story div
|
# get story div
|
||||||
story_dom = template_dom.find('div', {"id":"flow-main"})
|
story_dom = template_dom.find('div', {"id":"flow-main"})
|
||||||
|
|
||||||
|
# page index
|
||||||
pi = 0
|
pi = 0
|
||||||
|
# loop through pages following summary (pages liste)
|
||||||
for p in self.sum:
|
for p in self.sum:
|
||||||
# print(toc[p])
|
# print(toc[p])
|
||||||
pagename = p['title']
|
pagename = p['title']
|
||||||
@@ -84,14 +86,13 @@ class Compiler():
|
|||||||
continue
|
continue
|
||||||
# print('in_f : '+in_f)
|
# print('in_f : '+in_f)
|
||||||
|
|
||||||
pdoc_args = ['--mathjax',
|
pdoc_args = ['--mathjax']
|
||||||
'--smart']
|
|
||||||
|
|
||||||
pdoc_filters = []
|
pdoc_filters = []
|
||||||
|
|
||||||
output = pypandoc.convert_file(in_f,
|
output = pypandoc.convert_file(in_f,
|
||||||
to='html5',
|
to='html5',
|
||||||
format='markdown+header_attributes+link_attributes+bracketed_spans',
|
format='markdown+smart+header_attributes+link_attributes+bracketed_spans',
|
||||||
extra_args=pdoc_args,
|
extra_args=pdoc_args,
|
||||||
filters=pdoc_filters)
|
filters=pdoc_filters)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# @Author: Bachir Soussi Chiadmi <bach>
|
# @Author: Bachir Soussi Chiadmi <bach>
|
||||||
# @Date: 30-05-2017
|
# @Date: 30-05-2017
|
||||||
# @Email: bachir@figureslibres.io
|
# @Email: bachir@figureslibres.io
|
||||||
# @Filename: sasscompiler.py
|
# @Filename: scsscompiler.py
|
||||||
# @Last modified by: bach
|
# @Last modified by: bach
|
||||||
# @Last modified time: 03-06-2017
|
# @Last modified time: 03-06-2017
|
||||||
# @License: GPL-V3
|
# @License: GPL-V3
|
||||||
@@ -13,7 +13,7 @@ from __future__ import absolute_import, print_function, division, unicode_litera
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from PyQt5.QtCore import QFileSystemWatcher
|
from PyQt5.QtCore import QFileSystemWatcher
|
||||||
import sass
|
import scss
|
||||||
|
|
||||||
class Compiler():
|
class Compiler():
|
||||||
def __init__(self,parent):
|
def __init__(self,parent):
|
||||||
@@ -30,16 +30,21 @@ class Compiler():
|
|||||||
self.fs_watcher.fileChanged.connect(self.compile_scss)
|
self.fs_watcher.fileChanged.connect(self.compile_scss)
|
||||||
|
|
||||||
def compile_scss(self):
|
def compile_scss(self):
|
||||||
print("compiling sass")
|
print("compiling scss")
|
||||||
try:
|
try:
|
||||||
scss = sass.compile_file(str.encode(os.path.join(self.parent.cwd,'assets/css/main.scss')))
|
import_path = ['./assets/css/']
|
||||||
|
print("import path",import_path)
|
||||||
|
comp = scss.Compiler(output_style="compressed", search_path=import_path)
|
||||||
|
# Compiler().compile_string("a { color: red + green; }")
|
||||||
|
scss_file = open(os.path.join(self.parent.cwd,'assets/css/main.scss'),"r")
|
||||||
|
css = comp.compile_string(scss_file.read())
|
||||||
|
# print("css : %s" % css)
|
||||||
with open(os.path.join(self.parent.cwd,'assets/css/main.css'), 'w') as fp:
|
with open(os.path.join(self.parent.cwd,'assets/css/main.css'), 'w') as fp:
|
||||||
fp.write(scss.decode('utf8'))
|
fp.write(css)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error compiling Sass", e)
|
print("Error compiling scss", e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def refreshPaths(self):
|
def refreshPaths(self):
|
||||||
self.paths = [
|
self.paths = [
|
||||||
os.path.join(self.parent.cwd,'assets'),
|
os.path.join(self.parent.cwd,'assets'),
|
||||||
@@ -51,7 +56,7 @@ class Compiler():
|
|||||||
self.paths.append(os.path.join(self.parent.cwd,'assets/css',f))
|
self.paths.append(os.path.join(self.parent.cwd,'assets/css',f))
|
||||||
|
|
||||||
def reload(self):
|
def reload(self):
|
||||||
print('Reload sass compiler')
|
print('Reload scss compiler')
|
||||||
self.fs_watcher.removePaths(self.paths)
|
self.fs_watcher.removePaths(self.paths)
|
||||||
self.refreshPaths()
|
self.refreshPaths()
|
||||||
print('paths', self.paths)
|
print('paths', self.paths)
|
||||||
@@ -43,7 +43,7 @@ you'll have to build qt-webkit from source : https://github.com/annulen/webkit/w
|
|||||||
#### dependences
|
#### dependences
|
||||||
```shell
|
```shell
|
||||||
apt-get install qt5-base pandoc python3 python3-pyqt5 python3-pip
|
apt-get install qt5-base pandoc python3 python3-pyqt5 python3-pip
|
||||||
pip3 install sass markdown beautifulsoup4 pypandoc pygments setuptools pyphen
|
pip3 install pyScss markdown beautifulsoup4 pypandoc pygments setuptools pyphen
|
||||||
```
|
```
|
||||||
#### Libriis
|
#### Libriis
|
||||||
clone
|
clone
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
sass
|
pyScss
|
||||||
pyphen
|
pyphen
|
||||||
pygments-style-github
|
pygments-style-github
|
||||||
|
|||||||
Reference in New Issue
Block a user