Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefanie S committed Jun 20, 2020
2 parents 017a817 + 9577d53 commit ea21e54
Show file tree
Hide file tree
Showing 273 changed files with 9,780 additions and 238 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _writerey_data
/bazel-out

# dependencies
/node_modules
**/node_modules

# profiling files
chrome-profiler-events*.json
Expand Down
373 changes: 373 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Writerey

Writerey is a small tool that wants to help you with your next writing project: A novel, an essay for school, a research, a poem booklet, ... you name it!
Writerey is a tool that wants to help you with your next writing project: A novel, an essay for school, a research, a poem booklet, ... you name it!

It provides you a distraction free place to sort your thoughts and write down your ideas. It keeps your project safe with autosave functionality and snapshots. Read more about the functionality you get from writerey below.
It provides you a distraction free place to sort your thoughts and write down your ideas. It keeps your project safe with autosave functionality and snapshots. It provides you handy functionality to note down thoughts and side-infos. Read more about the functionality you get from writerey in its [Wiki](https://github.com/s-blu/writerey/wiki).

writerey is open source and licensed under Mozilla Public License Version 2.0. For License information see LICENSE

## System requirements

Expand All @@ -29,11 +31,20 @@ For a complete list of used packages, please refer to package.json.

## Installation

Please visit the [Wiki](https://github.com/s-blu/writerey/wiki) to find a detailed explanation how to install writerey.

- Install Python 3
- Install Git
- Download the executable of writerey
- Download the executable of writerey from the Release page on Github
- Launch writerey.exe (on Windows)

writerey is build with [electron-forge](https://www.electronforge.io/). To build a executable for your target system, do the following:

- Get the repository locally
- Install dependencies with `npm i`
- Run `npm run build-make`
- Hope for the best since I never tried that for something else than Windows. :)

## Guide

For a guide on the app, please visit <fancy website I'll build later>
Please visit the [Wiki](https://github.com/s-blu/writerey/wiki) to find out more about writerey.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "writerey",
"description": "Writerey helps you to organize, compose and refine your stories.",
"version": "0.7.2",
"version": "0.8.0-PRE1",
"author": {
"name": "Stefanie S",
"email": "sts@s-blu.de"
},
"license": "MPL-2.0",
"main": "main.js",
"scripts": {
"ng": "ng",
Expand All @@ -15,9 +16,9 @@
"lint": "ng lint",
"e2e": "ng e2e",
"electron": "electron .",
"electron-build": "ng build --prod && npm run electron .",
"build-exe": "electron-packager . --overwrite",
"build-electron": "ng build --prod && npm run electron .",
"flask": "python server/app.py",
"build-exe": "electron-packager . --overwrite",
"package": "electron-forge package",
"build-make": "ng build --prod && electron-forge make",
"make": "electron-forge make"
Expand Down
15 changes: 13 additions & 2 deletions server/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from initialize_env import initialize_env

if __name__ == '__main__':
Expand Down Expand Up @@ -28,6 +34,11 @@
api = Api(app)
CORS(app) # resources={r"*": {"origins": '*'}}) # boooh. FIXME.

class Ping(Resource):
def get(self):
return {'message': 'Server is started up and ready to go. '}

api.add_resource(Ping, '/ping')
api.add_resource(Documents, '/doc/<string:doc_name>')
api.add_resource(Images, '/img/<string:doc_name>')
api.add_resource(ParagraphMeta, '/p/<string:doc_name>')
Expand All @@ -40,5 +51,5 @@
api.add_resource(GitMove, '/git/mv')

if __name__ == '__main__':
# app.run(port=port, debug=True) # FIXME
serve(app, listen= host + ":" + port)
app.run(port=port, debug=True) # FIXME
# serve(app, listen= host + ":" + port)
24 changes: 23 additions & 1 deletion server/directories.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
from flask import request
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from flask import request, abort
from flask_restful import Resource
from pathlib import Path
from writerey_config import basePath, metaSubPath
from pathUtils import PathUtils

import os
import json
import shutil
from logger import Logger


Expand All @@ -27,3 +34,18 @@ def put(self, dir_name):
Path(newPath).mkdir()
log.logDebug('mkdir:', {'path': PathUtils.sanitizePathString(newPath, True)})
return {'path': PathUtils.sanitizePathString(newPath, True)}

def delete(self, dir_name):
if request.args.get('dir_path'):
pathToDelete = PathUtils.sanitizePathList(
[basePath, request.args.get('dir_path')])
else:
pathToDelete = basePath

dirPath = PathUtils.sanitizePathList([pathToDelete, dir_name])
if not os.path.exists(dirPath):
return abort(400, 'File for deletion was not found')

shutil.rmtree(dirPath)

return {}
6 changes: 6 additions & 0 deletions server/directories.test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import unittest

class PathUtilsTest(unittest.TestCase):
Expand Down
33 changes: 30 additions & 3 deletions server/documents.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from flask import request
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from flask import request, abort
from flask_restful import Resource
from pathlib import Path
from writerey_config import basePath
from writerey_config import basePath, metaSubPath
from pathUtils import PathUtils

import os
import shutil
from stat import ST_MTIME


Expand All @@ -21,7 +28,7 @@ def get(self, doc_name):
return response
except OSError as err:
print('get document failed', err)
return '' # TODO send an error back here
return abort(500, err)

def put(self, doc_name):
if request.form['doc_path']:
Expand All @@ -37,6 +44,26 @@ def put(self, doc_name):
f.save(filePath)
return self.getResponseObject(open(filePath, encoding='utf-8'))

def delete(self, doc_name):
if request.args.get('doc_path'):
pathToDelete = PathUtils.sanitizePathList(
[basePath, request.args.get('doc_path')])
else:
pathToDelete = basePath

filePath = PathUtils.sanitizePathList([pathToDelete, doc_name])
if not os.path.exists(filePath):
return abort(400, 'File for deletion was not found')

os.remove(filePath)

meta_path = PathUtils.sanitizePathList([pathToDelete, metaSubPath, doc_name])
metaExists = os.path.exists(meta_path)
if (metaExists):
shutil.rmtree(meta_path)

return {}

def getResponseObject(self, file):
fstats = os.stat(file.name)
return {
Expand Down
6 changes: 6 additions & 0 deletions server/documents.test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import unittest

class PathUtilsTest(unittest.TestCase):
Expand Down
6 changes: 6 additions & 0 deletions server/git.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from flask import request
from flask_restful import Resource
from pathlib import Path
Expand Down
36 changes: 28 additions & 8 deletions server/gitMv.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from flask import request
from flask_restful import Resource
from logger import Logger
Expand All @@ -6,6 +12,7 @@
from gitUtils import GitUtils
from writerey_config import basePath, metaSubPath, linksFileName
from os import path
import shutil

class GitMove(Resource):
logger = Logger('GitMove')
Expand All @@ -15,14 +22,17 @@ def get(self):
abort(501, 'not implemented yet')

def put(self):
#TODO BE ABLE TO HANDLE DIRS
doc_name = request.form['doc_name']
doc_name = None
new_name = None
doc_path = request.form['doc_path']
new_name = request.form['new_doc_name']
new_doc_path = request.form['new_doc_path']
project_dir = request.form['project_dir']
msg = request.form['msg']
self.logger.logDebug('params', doc_name, doc_path, new_name, new_doc_path, msg)
try:
doc_name = request.form['doc_name']
new_name = request.form['new_doc_name']
except:
pass

if doc_name and not new_name:
abort(400, 'Got no new name, cannot move')
Expand All @@ -33,9 +43,8 @@ def put(self):

if doc_path == new_doc_path and doc_name == new_name:
self.logger.logDebug('path and name are identical to new path and name, return 400')
abort(400, 'New path and name are identical to existing path and name. Do nothing.')
abort(400, 'New path and name are identical to existing path and name.')

# TODO do a "before move" commit...? Maybe do that on FE side?
if doc_path == new_doc_path and doc_name.lower() == new_name.lower():
self.logger.logInfo('Rename is only changing case sensitivity. Doing extra commit to prevent trouble.', doc_name, '-->', new_name)
new_name_ptfrcs = new_name[:6] + '_ptfrcs' # "prevent trouble from renaming case sensitivity"
Expand All @@ -50,16 +59,27 @@ def moveViaGit(self, doc_path, doc_name, new_doc_path, new_name, msg, projectDir
new_path = PathUtils.sanitizePathList([new_doc_path, new_name])
old_meta_path = PathUtils.sanitizePathList([doc_path, metaSubPath, doc_name])
new_meta_path = PathUtils.sanitizePathList([new_doc_path, metaSubPath, new_name])
metaExists = path.exists(PathUtils.sanitizePathList([basePath, old_meta_path]))

try:
self.git.run(['git', 'ls-files', '--error-unmatch', old_path])
except:
self.logger.logDebug('file is not under version control yet, do a file system move')
shutil.move(PathUtils.sanitizePathList([basePath, old_path]), PathUtils.sanitizePathList([basePath, new_path]))
if (metaExists):
shutil.move(PathUtils.sanitizePathList([basePath, old_meta_path]), PathUtils.sanitizePathList([basePath, new_meta_path]))
return

self.logger.logDebug('moving file ...', old_path, new_path)
self.logger.logDebug('moving meta ...', old_meta_path, new_meta_path)
self.logger.logDebug('moving meta if ...', path.exists(PathUtils.sanitizePathList([basePath, old_meta_path])))
self.logger.logDebug('moving meta if ...', metaExists)
if not msg:
msg = 'Rename ' + old_path + ' to ' + new_path
self.git.run(["git", "mv", old_path, new_path])
if path.exists(PathUtils.sanitizePathList([basePath, old_meta_path])):
if metaExists:
self.git.run(["git", "mv", old_meta_path, new_meta_path])
if projectDir:
# add links file to the commit, since it possibly get changed on a move
linksFilePath = PathUtils.sanitizePathList([projectDir, metaSubPath, linksFileName])
if path.exists(linksFilePath):
self.git.run(["git", "add", linksFilePath])
Expand Down
6 changes: 6 additions & 0 deletions server/gitTag.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from flask import request
from flask_restful import Resource
from logger import Logger
Expand Down
6 changes: 6 additions & 0 deletions server/gitUtils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.


import subprocess
from pathUtils import PathUtils
Expand Down
6 changes: 6 additions & 0 deletions server/images.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from flask import request, send_from_directory
from flask_restful import Resource
from pathlib import Path
Expand Down
6 changes: 6 additions & 0 deletions server/initialize_env.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import subprocess

from pip._internal.utils.misc import get_installed_distributions
Expand Down
6 changes: 6 additions & 0 deletions server/label.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from flask import request
from flask_restful import Resource
from pathlib import Path
Expand Down
6 changes: 6 additions & 0 deletions server/links.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from flask import request
from flask_restful import Resource
from pathlib import Path
Expand Down
6 changes: 6 additions & 0 deletions server/logger.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.


from writerey_config import debugMode

Expand Down
6 changes: 6 additions & 0 deletions server/paragraph_meta.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from flask import request
from flask_restful import Resource
from pathlib import Path
Expand Down
6 changes: 6 additions & 0 deletions server/paragraph_meta.test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright (c) 2020 s-blu
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import unittest

class PathUtilsTest(unittest.TestCase):
Expand Down
Loading

0 comments on commit ea21e54

Please sign in to comment.