Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Dan's (Lecturer) code
- Loading branch information
Prinex
committed
Nov 21, 2022
0 parents
commit 41f7f1c3e49fe8e671e5188e79202ce77cc21319
Showing
48 changed files
with
60,323 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*~ | ||
env | ||
*# | ||
#* |
49
README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# CW Template | ||
|
||
Build using Flask, see https://flask.palletsprojects.com/en/2.2.x/ | ||
|
||
## Build Instruction | ||
|
||
1. (Optional) Create a new virtual env | ||
```python -m venv env``` | ||
Remember to activate the Env when you go to use it | ||
``` | ||
source env/bin/activate | ||
``` | ||
2. Install Requirements | ||
``` | ||
pip install -r REQUIREMENTS.txt | ||
``` | ||
3. Run | ||
``` | ||
flask --app app/ --debug run | ||
``` | ||
The site should now be visible on 127.0.0.1:5000 | ||
## Inital DB | ||
Database Schema can be found in ```schema.db``` | ||
You can initialise a testing db by visiting ```127.0.0.1:5000/initdb``` | ||
## Files | ||
Some Supporting files | ||
- schema.sql | ||
Basic database schema to get you started | ||
You can build this by visiting the ```/initdb``` url | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
flask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .meta import * | ||
|
||
from .views import * |
69
app/meta.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
""" | ||
Setup "Meta" class, | ||
Contains App definition and database init functionality | ||
# ------ DATABASE FUNC ------- | ||
# Taken from from https://flask.palletsprojects.com/en/2.2.x/patterns/sqlite3/ | ||
""" | ||
|
||
|
||
|
||
import flask | ||
from flask import g | ||
import sqlite3 | ||
|
||
DATABASE = 'database.db' | ||
UPLOAD_FOLDER = 'uploads' | ||
|
||
|
||
app = flask.Flask(__name__) | ||
|
||
app.config.update( | ||
SECRET_KEY="secr3t!", | ||
SESSION_COOKIE_SAMESITE='Strict', | ||
UPLOAD_FOLDER=UPLOAD_FOLDER | ||
) | ||
|
||
|
||
def make_dicts(cursor, row): | ||
return dict((cursor.description[idx][0], value) | ||
for idx, value in enumerate(row)) | ||
|
||
|
||
def get_db(): | ||
db = getattr(g, '_database', None) | ||
if db is None: | ||
db = g._database = sqlite3.connect(DATABASE) | ||
|
||
db.row_factory = make_dicts | ||
return db | ||
|
||
def query_db(query, args=(), one=False): | ||
cur = get_db().execute(query, args) | ||
rv = cur.fetchall() | ||
cur.close() | ||
return (rv[0] if rv else None) if one else rv | ||
|
||
def write_db(query, args=()): | ||
""" | ||
Helper Method for Write | ||
""" | ||
db = get_db() | ||
db.execute(query, args) | ||
db.commit() | ||
|
||
|
||
@app.teardown_appcontext | ||
def close_connection(exception): | ||
db = getattr(g, '_database', None) | ||
if db is not None: | ||
db.close() | ||
|
||
def init_db(): | ||
with app.app_context(): | ||
db = get_db() | ||
with app.open_resource('../schema.sql', mode='r') as f: | ||
db.cursor().executescript(f.read()) | ||
db.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.collection .collection-item.avatar .title{ | ||
font-weight: bold; | ||
color: black; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"rules": { | ||
"indent": [ | ||
2, | ||
"tab" | ||
], | ||
"strict": 0, | ||
"no-console": 0, | ||
"quotes": [ | ||
2, | ||
"double" | ||
], | ||
"semi": [ | ||
2, | ||
"always" | ||
] | ||
}, | ||
"env": { | ||
"browser": true, | ||
"node":true | ||
}, | ||
"extends": "eslint:recommended" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
localtesting/ | ||
node_modules/ | ||
bower_components/ | ||
|
||
#For IDE | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
language: node_js | ||
node_js: | ||
- '6' | ||
- '5' | ||
- '4' | ||
- '0.12' | ||
before_script: | ||
- npm install -g gulp | ||
script: gulp | ||
deploy: | ||
provider: npm | ||
email: support@nextstepwebs.com | ||
api_key: | ||
secure: nADZupyOhJAhTQgr5uOIydbDEjCTAj+3nGHW7ZBJUrVJcb0uR4pg8ngmwrUpvaCeNXgKPG9Uag75/mPcBre9ly2cigBIG9LHlxImlF8qi1jRJykcNRmBb9N2MJJj+zdAMwLaF5Ns+f2v3zt97qxovbEzunhXGcZeCaxc6y40nDM8OTyo0PESNBjQYqaNblt2gO2KHysrwFL8i4kCCKLa+HOBLu2iqgk/fYVqTmfhEeOiiwQ4lIXJeyPyzgb3OPhKCMV1FI5H0T48fRD0MPczt8ds3Daj1OjCbIZurQ7s1dcKwz1g6TKATN59HcMsSarW4lImrEeYmfQxz2F5NjKDRhnith5V0W2IssrkpDG9teTFQ20eQdl5cpnlGjgBvsjb8GhPLR44GvefyJL4+kJGI3O1KVq3/7wbmu/IXrvhtKHEQSdGL2PTqW8QxKasAoUCnk3LGZKN12g8bg0xDg2tvoCUk5Z3asHLRdCJpDbBq1h8QfZ4HV5VLYjr84xduOUZbEUtfMVAixPpJ4h1E3OXJ1wil97BlHjxOZ8JkkxJg5lgSUZ/O/QWwJokEAYXR9c+ouMoVokChAyleV77cRZ5qLn9zbnUxZtnKX8w0IUKeu95/z8QgiaRcERKVCpZvceo8Qw0Y+JoiEtno7Zg/nsrZGxsS6K/V3yg1QQmT3bjDHQ= | ||
on: | ||
tags: true | ||
repo: NextStepWebs/simplemde-markdown-editor | ||
branch: production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
### Overview | ||
First of all, thanks for your interest in helping make SimpleMDE even better. Contributions help resolve rare bugs, accomplish neat new features, polish the code, and improve the documentation. | ||
|
||
### Guidelines for contributing | ||
- The *most important* guideline for contributing is to compare against the `development` branch when creating a pull request. This allows time to test and modify code changes before merging them into the stable master branch with the next release. | ||
- Travis CI is configured to build and verify all PRs. If your PR causes the build to fail, please add an additional commit that resolves any problems. | ||
- If you really want to earn some brownie points, create a JSFiddle that demonstrates your code changes. Seriously, this helps immensely and allows one or multiple people to easily provide feedback on the great work you've done. | ||
- When creating the JSFiddle, keep in mind that you can use http://rawgit.com for your files. | ||
- Do your best to fully test your changes. Anticipate edge-case behavior. | ||
- Try to keep your codebase that you're making changes to as up-to-date as possible with the origin. SimpleMDE creates new releases frequently, so it's easy to fall behind if you've been working on something new for a while. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Next Step Webs, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
Oops, something went wrong.