moved all project assets to project folder
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtCore import QFileSystemWatcher
|
||||
import sass
|
||||
|
||||
class Compiler():
|
||||
def __init__(self,parent=None):
|
||||
paths = [
|
||||
'assets',
|
||||
'assets/scss',
|
||||
'assets/scss/styles.scss'
|
||||
]
|
||||
self.fs_watcher = QFileSystemWatcher(paths)
|
||||
# self.fs_watcher.directoryChanged.connect(self.directory_changed)
|
||||
self.fs_watcher.fileChanged.connect(self.compile_scss)
|
||||
self.compile_scss()
|
||||
|
||||
# def directory_changed(path):
|
||||
# print("Directory changed : %s" % path)
|
||||
|
||||
def compile_scss(path = ""):
|
||||
print("compiling sass : %s" % path)
|
||||
scss = sass.compile_file(b'assets/scss/main.scss')
|
||||
with open('assets/scss/main.css', 'w') as fp:
|
||||
fp.write(scss.decode('utf8'))
|
||||
+8
-6
@@ -24,8 +24,8 @@ class Summary(QWidget):
|
||||
super(Summary, self).__init__(parent)
|
||||
self.parent = parent
|
||||
|
||||
self.jsonfilepath = os.path.join(self.parent.core.cwd,'.config/summary.json')
|
||||
sum_json = open(self.jsonfilepath).read()
|
||||
jsonfilepath = os.path.join(self.parent.core.cwd,'.config/summary.json')
|
||||
sum_json = open(jsonfilepath).read()
|
||||
self.sum = json.loads(sum_json)
|
||||
|
||||
vbox = QVBoxLayout()
|
||||
@@ -43,13 +43,14 @@ class Summary(QWidget):
|
||||
# file
|
||||
filename = re.sub(r'\W', "_", text)+".md"
|
||||
# TODO: check if file does not already exists
|
||||
filepath = os.path.join(self.core.cwd,'contents',filename)
|
||||
filepath = os.path.join(self.parent.core.cwd,'contents',filename)
|
||||
with open(filepath, 'w') as fp:
|
||||
fp.write('#'+text)
|
||||
# json
|
||||
item = {"title":text,"file":filename}
|
||||
self.sum.append(item)
|
||||
with open(self.jsonfilepath, "w") as fp:
|
||||
jsonfilepath = os.path.join(self.parent.core.cwd,'.config/summary.json')
|
||||
with open(jsonfilepath, "w") as fp:
|
||||
json.dump(self.sum, fp, ensure_ascii=False, indent="\t")
|
||||
# refresh list
|
||||
self.list.addNewItem(item)
|
||||
@@ -59,11 +60,12 @@ class Summary(QWidget):
|
||||
newdata = []
|
||||
for i in range(0,self.list.count()):
|
||||
# print(self.item(i).item['title'])
|
||||
newdata.append(self.list.item(i).item)
|
||||
newdata.append(self.list.item(i).data)
|
||||
|
||||
# print(newdata)
|
||||
self.sum = newdata
|
||||
with open(self.jsonfilepath, "w") as fp:
|
||||
jsonfilepath = os.path.join(self.parent.core.cwd,'.config/summary.json')
|
||||
with open(jsonfilepath, "w") as fp:
|
||||
json.dump(newdata, fp, ensure_ascii=False, indent="\t")
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -25,6 +25,7 @@ class WebkitInspector(QWebInspector):
|
||||
super(WebkitInspector, self).__init__(parent)
|
||||
self.webkitview = webkitview
|
||||
self.setPage(self.webkitview.page())
|
||||
self.showMaximized()
|
||||
# TODO: webkitinspector is disappearing when chaging tabs
|
||||
|
||||
|
||||
@@ -73,7 +74,7 @@ class Editor(QWidget):
|
||||
# Initialize tab screen
|
||||
self.tabs = QTabWidget()
|
||||
|
||||
self.scsstab = CodeEditor(core, self.tabs, 'assets/scss/styles.scss')
|
||||
self.scsstab = CodeEditor(core, self.tabs, 'assets/css/styles.scss')
|
||||
self.jstab = CodeEditor(core, self.tabs, 'assets/js/script.js')
|
||||
|
||||
# Add tabs
|
||||
@@ -153,6 +154,6 @@ class DesignStack(QWidget):
|
||||
|
||||
def movedSplitter(self):
|
||||
settings = QSettings('FiguresLibres', 'Cascade')
|
||||
print(self.vsplitter.sizes())
|
||||
# print(self.vsplitter.sizes())
|
||||
settings.setValue('design/vsplitter/sizes', self.vsplitter.sizes())
|
||||
settings.setValue('design/hsplitter/sizes', self.hsplitter.sizes())
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from PyQt5.QtCore import QFileSystemWatcher
|
||||
import sass
|
||||
|
||||
class Compiler():
|
||||
def __init__(self,parent):
|
||||
self.parent = parent
|
||||
self.initWatching()
|
||||
self.compile_scss()
|
||||
# def directory_changed(path):
|
||||
# print("Directory changed : %s" % path)
|
||||
|
||||
def initWatching(self):
|
||||
self.refreshPaths()
|
||||
self.fs_watcher = QFileSystemWatcher(self.paths)
|
||||
# self.fs_watcher.directoryChanged.connect(self.directory_changed)
|
||||
self.fs_watcher.fileChanged.connect(self.compile_scss)
|
||||
|
||||
def compile_scss(self):
|
||||
print("compiling sass")
|
||||
try:
|
||||
scss = sass.compile_file(str.encode(os.path.join(self.parent.cwd,'assets/css/main.scss')))
|
||||
with open(os.path.join(self.parent.cwd,'assets/css/main.css'), 'w') as fp:
|
||||
fp.write(scss.decode('utf8'))
|
||||
except Exception as e:
|
||||
print("Error compiling Sass", e)
|
||||
pass
|
||||
|
||||
|
||||
def refreshPaths(self):
|
||||
self.paths = [
|
||||
os.path.join(self.parent.cwd,'assets'),
|
||||
os.path.join(self.parent.cwd,'assets/css'),
|
||||
os.path.join(self.parent.cwd,'assets/css/styles.scss')
|
||||
]
|
||||
|
||||
def reload(self):
|
||||
self.fs_watcher.removePaths(self.paths)
|
||||
self.refreshPaths()
|
||||
self.fs_watcher.addPaths(self.paths)
|
||||
+16
-4
@@ -13,8 +13,9 @@ import threading
|
||||
|
||||
class Server():
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, parent):
|
||||
|
||||
self.parent = parent
|
||||
# find free port
|
||||
sock = socket()
|
||||
sock.bind(('', 0))
|
||||
@@ -22,13 +23,24 @@ class Server():
|
||||
self._port = sock.getsockname()[1]
|
||||
sock.close()
|
||||
|
||||
self.httpd = http.server.HTTPServer(('', self.port), http.server.SimpleHTTPRequestHandler)
|
||||
self.thread = threading.Thread(target=self.httpd.serve_forever)
|
||||
# self.initial_cwd = os.getcwd()
|
||||
self.thread = threading.Thread(target=self.webserver)
|
||||
self.thread.daemon = True
|
||||
self.thread.start()
|
||||
print("serving at port", self._port)
|
||||
# os.chdir(self.initial_cwd)
|
||||
|
||||
def webserver(self):
|
||||
os.chdir(self.parent.cwd)
|
||||
self.httpd = http.server.HTTPServer(('', self.port), http.server.SimpleHTTPRequestHandler)
|
||||
self.httpd.serve_forever()
|
||||
print("serving at port", self._port)
|
||||
|
||||
@property
|
||||
def port(self):
|
||||
return self._port
|
||||
|
||||
def reload(self):
|
||||
# self.thread.shutdown()
|
||||
os.chdir(self.parent.cwd)
|
||||
# self.thread.start()
|
||||
# os.chdir(self.initial_cwd)
|
||||
|
||||
Reference in New Issue
Block a user