Rename to CodeSmidgen

This commit is contained in:
Raoul Snyman 2023-07-27 23:14:10 -07:00
parent d31b783f55
commit 45d9263532
21 changed files with 38 additions and 38 deletions

2
.gitignore vendored
View File

@ -1,7 +1,7 @@
__pycache__ __pycache__
*.egg-info *.egg-info
*.sqlite *.sqlite
stickynotes.cfg codesmidgen.cfg
build build
dist dist
.coverage .coverage

View File

@ -8,7 +8,7 @@ steps:
image: python:3.11 image: python:3.11
commands: commands:
- pip install hatch - pip install hatch
- cp stickynotes.example.cfg stickynotes.cfg - cp codesmidgen.example.cfg codesmidgen.cfg
- hatch run tests:run - hatch run tests:run
publish-package: publish-package:
image: python:3.11 image: python:3.11

View File

@ -1,3 +1,3 @@
[stickynotes] [codesmidgen]
sqlalchemy_database_uri = sqlite:/// sqlalchemy_database_uri = sqlite:///
secret_key = yoursecretkeyhere secret_key = yoursecretkeyhere

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
StickyNotes, yet another paste bin CodeSmidgen, yet another paste bin
""" """
from configparser import ConfigParser from configparser import ConfigParser
from pathlib import Path from pathlib import Path
@ -8,8 +8,8 @@ from pathlib import Path
import quart_flask_patch # noqa: F401 import quart_flask_patch # noqa: F401
from quart import Quart from quart import Quart
from stickynotes.db import db from codesmidgen.db import db
from stickynotes.views import views from codesmidgen.views import views
def read_config(config_path=None): def read_config(config_path=None):
@ -17,16 +17,16 @@ def read_config(config_path=None):
Read the configuration file and return the values in a dictionary Read the configuration file and return the values in a dictionary
""" """
if config_path: if config_path:
config_file = config_path / 'stickynotes.cfg' config_file = config_path / 'codesmidgen.cfg'
else: else:
config_file = Path(__file__).parent / '..' / 'stickynotes.cfg' config_file = Path(__file__).parent / '..' / 'codesmidgen.cfg'
if not config_file.exists(): if not config_file.exists():
return {} return {}
config_parser = ConfigParser() config_parser = ConfigParser()
config_parser.read(config_file) config_parser.read(config_file)
config = {} config = {}
for option in config_parser.options('stickynotes'): for option in config_parser.options('codesmidgen'):
config[option.upper()] = config_parser.get('stickynotes', option) config[option.upper()] = config_parser.get('codesmidgen', option)
return config return config

3
codesmidgen/__main__.py Normal file
View File

@ -0,0 +1,3 @@
from codesmidgen.app import application
application.run()

View File

@ -3,7 +3,7 @@
This is the entry point for the WSGI server This is the entry point for the WSGI server
""" """
from pathlib import Path from pathlib import Path
from stickynotes import make_app from codesmidgen import make_app
application = make_app(Path(__file__).parent.parent) application = make_app(Path(__file__).parent.parent)

View File

@ -4,14 +4,14 @@ The models in use
""" """
from datetime import datetime from datetime import datetime
from stickynotes.db import Model, Column, Integer, String, Text, DateTime, Boolean from codesmidgen.db import Model, Column, Integer, String, Text, DateTime, Boolean
class StickyNote(Model): class Smidgen(Model):
""" """
The main (only?) table in the system The main (only?) table in the system
""" """
__tablename__ = 'sticky_notes' __tablename__ = 'smidgens'
id = Column(Integer, autoincrement=True, primary_key=True) id = Column(Integer, autoincrement=True, primary_key=True)
title = Column(String(255)) title = Column(String(255))

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -2,8 +2,8 @@
{% block content %} {% block content %}
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<h2>About StickyNotes</h2> <h2>About CodeSmidgen</h2>
<p>StickyNotes is a quick code paste application written in Python with Quartz, SQLAlchemy, Mako, Pygments and a few other Python libraries.</p> <p>CodeSmidgen is a quick code paste application written in Python with Quartz, SQLAlchemy, Mako, Pygments and a few other Python libraries.</p>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -4,7 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>StickyNotes</title> <title>CodeSmidgen</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootswatch@4.6.0/dist/darkly/bootstrap.min.css" type="text/css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootswatch@4.6.0/dist/darkly/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css" type="text/css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css" type="text/css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" type="text/css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" type="text/css">
@ -16,7 +16,7 @@
<body> <body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary navbar-fixed-top"> <nav class="navbar navbar-expand-lg navbar-dark bg-primary navbar-fixed-top">
<div class="container"> <div class="container">
<a href="/" class="navbar-brand">StickyNotes</a> <a href="/" class="navbar-brand">CodeSmidgen</a>
<button type="button" class="navbar-toggler collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <button type="button" class="navbar-toggler collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
@ -40,7 +40,7 @@
</div> </div>
<footer class="footer"> <footer class="footer">
<div class="container"> <div class="container">
<p class="text-muted">Copyright &copy; 2015 Raoul Snyman.</p> <p class="text-muted">Copyright &copy; 2023 Raoul Snyman.</p>
</div> </div>
</footer> </footer>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>

View File

@ -7,7 +7,7 @@
<textarea name="source" id="source" class="form-control" rows="20"></textarea> <textarea name="source" id="source" class="form-control" rows="20"></textarea>
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="text" name="title" id="title" class="form-control" placeholder="Title of your snippet"> <input type="text" name="title" id="title" class="form-control" placeholder="Title of your smidgen">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="language">Language</label> <label for="language">Language</label>

View File

@ -13,8 +13,8 @@ from pygments.formatters.html import HtmlFormatter
from pygments.lexers import get_lexer_by_name, get_all_lexers from pygments.lexers import get_lexer_by_name, get_all_lexers
from sqlalchemy import or_ from sqlalchemy import or_
from stickynotes.db import session from codesmidgen.db import session
from stickynotes.models import StickyNote from codesmidgen.models import Smidgen
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -55,10 +55,10 @@ async def notes():
""" """
Show a list of recent notes Show a list of recent notes
""" """
notes = StickyNote.query\ notes = Smidgen.query\
.filter(or_(StickyNote.expiry == None, StickyNote.expiry < datetime.utcnow()))\ .filter(or_(Smidgen.expiry == None, Smidgen.expiry < datetime.utcnow()))\
.filter(~StickyNote.private)\ .filter(~Smidgen.private)\
.order_by(StickyNote.created.desc())\ .order_by(Smidgen.created.desc())\
.limit(10) # noqa: E711 .limit(10) # noqa: E711
return await render_template('notes.html', notes=notes) return await render_template('notes.html', notes=notes)
@ -85,10 +85,10 @@ async def save():
expiry = created + EXPIRY_DELTAS.get(form['expiry'], EXPIRY_DELTAS['1d']) expiry = created + EXPIRY_DELTAS.get(form['expiry'], EXPIRY_DELTAS['1d'])
# Generate a short url, and check if it exists in the db # Generate a short url, and check if it exists in the db
url = _generate_short_url() url = _generate_short_url()
while StickyNote.query.filter(StickyNote.url == url).first(): while Smidgen.query.filter(Smidgen.url == url).first():
url = _generate_short_url() url = _generate_short_url()
# Create a new note # Create a new note
note = StickyNote( note = Smidgen(
title=form.get('title', ''), title=form.get('title', ''),
source=form['source'], source=form['source'],
lexer=form['language'], lexer=form['language'],
@ -113,7 +113,7 @@ async def view(note_url):
:param note_url: The note to show :param note_url: The note to show
""" """
note = StickyNote.query.filter(StickyNote.url == note_url).first() note = Smidgen.query.filter(Smidgen.url == note_url).first()
if not note: if not note:
flash('That note does not exist', 'danger') flash('That note does not exist', 'danger')
return redirect('/') return redirect('/')
@ -131,7 +131,7 @@ async def raw(note_url):
:param note_url: The note to show :param note_url: The note to show
""" """
note = StickyNote.query.filter(StickyNote.url == note_url).scalar() note = Smidgen.query.filter(Smidgen.url == note_url).scalar()
if not note: if not note:
flash('That note does not exist', 'danger') flash('That note does not exist', 'danger')
return redirect('/') return redirect('/')

View File

@ -3,7 +3,7 @@ requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build" build-backend = "hatchling.build"
[project] [project]
name = "StickyNotes" name = "CodeSmidgen"
dynamic = ["version"] dynamic = ["version"]
description = "A simple pastebin" description = "A simple pastebin"
license = "GPL-3.0-or-later" license = "GPL-3.0-or-later"
@ -53,11 +53,11 @@ source = "vcs"
[tool.hatch.build.targets.sdist] [tool.hatch.build.targets.sdist]
include = [ include = [
"/stickynotes", "/codesmidgen",
] ]
[tool.hatch.envs.default.scripts] [tool.hatch.envs.default.scripts]
serve = "quart -A stickynotes.app run" serve = "quart -A codesmidgen.app run"
[tool.hatch.envs.lint] [tool.hatch.envs.lint]
skip-install = true skip-install = true
@ -76,4 +76,4 @@ dependencies = [
] ]
[tool.hatch.envs.tests.scripts] [tool.hatch.envs.tests.scripts]
run = "pytest --cov=stickynotes --cov-report=html" run = "pytest --cov=codesmidgen --cov-report=html"

View File

@ -1,3 +0,0 @@
from stickynotes.app import application
application.run()

View File

@ -1,6 +1,6 @@
import pytest import pytest
from stickynotes.app import make_app from codesmidgen.app import make_app
pytestmark = [pytest.mark.asyncio] pytestmark = [pytest.mark.asyncio]