mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
dff881ee90 | |||
8ce3793ff6 | |||
b873215dd8 | |||
788cf0118d | |||
5dcb0d407e | |||
4ab4bffc0f | |||
75d272d430 | |||
2725cd10b4 | |||
b83f284b98 | |||
90672f7b39 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,12 +7,15 @@
|
|||||||
*_index
|
*_index
|
||||||
*.orig
|
*.orig
|
||||||
*.swp
|
*.swp
|
||||||
|
*.old
|
||||||
|
|
||||||
|
|
||||||
# binaries
|
# binaries
|
||||||
|
|
||||||
*.pyc
|
*.pyc
|
||||||
*.pyo
|
*.pyo
|
||||||
|
*.pyz
|
||||||
|
*.zip
|
||||||
__pycache__
|
__pycache__
|
||||||
.mypy*
|
.mypy*
|
||||||
*.db
|
*.db
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
|
export PYTHONWARNINGS=ignore::FutureWarning # scss prints future warnings
|
||||||
|
|
||||||
python -c "import scss" || {
|
python -c "import scss" || {
|
||||||
echo >&2 "Error: this script requires the scss python module. pip install -r dev-requirements.txt"
|
echo >&2 "Error: this script requires the scss python module. pip install -r dev-requirements.txt"
|
||||||
exit 1
|
exit 1
|
||||||
@ -23,15 +25,12 @@ echo "Compressing CSS..."
|
|||||||
|
|
||||||
echo $'\n''/* Prettify */' >>$CSS_OUTPUT
|
echo $'\n''/* Prettify */' >>$CSS_OUTPUT
|
||||||
python -m scss $CSSDIR'prettify.css' >>$CSS_OUTPUT
|
python -m scss $CSSDIR'prettify.css' >>$CSS_OUTPUT
|
||||||
rm $CSSDIR'prettify.min.css'
|
|
||||||
|
|
||||||
echo $'\n''/* Desert prettify theme */' >>$CSS_OUTPUT
|
echo $'\n''/* Desert prettify theme */' >>$CSS_OUTPUT
|
||||||
python -m scss $CSSDIR'desert.css' >>$CSS_OUTPUT
|
python -m scss $CSSDIR'desert.css' >>$CSS_OUTPUT
|
||||||
rm $CSSDIR'desert.min.css'
|
|
||||||
|
|
||||||
echo $'\n''/* Bootswatch bootstrap theme */' >>$CSS_OUTPUT
|
echo $'\n''/* Bootswatch bootstrap theme */' >>$CSS_OUTPUT
|
||||||
python -m scss $CSSDIR'bootswatch.4.5.css' >>$CSS_OUTPUT
|
python -m scss $CSSDIR'bootswatch.4.5.css' >>$CSS_OUTPUT
|
||||||
rm $CSSDIR'bootswatch.4.5.min.css'
|
|
||||||
|
|
||||||
echo $'\n''/* Our own CSS */' >>$CSS_OUTPUT
|
echo $'\n''/* Our own CSS */' >>$CSS_OUTPUT
|
||||||
python -m scss $CSSDIR'style.css' >>$CSS_OUTPUT
|
python -m scss $CSSDIR'style.css' >>$CSS_OUTPUT
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
doit==0.32.0
|
doit==0.32.0
|
||||||
pyScss==1.3.7
|
pyScss==1.3.7
|
||||||
|
twine==3.2.0
|
||||||
|
@ -44,10 +44,15 @@ GROUP = None
|
|||||||
|
|
||||||
# Names/links to insert in the menu bar.
|
# Names/links to insert in the menu bar.
|
||||||
# Any link with "mailto:" will be escaped to prevent spam
|
# Any link with "mailto:" will be escaped to prevent spam
|
||||||
|
|
||||||
MENU = (
|
MENU = (
|
||||||
('Home', '/'), # internal link. First link will be highlited
|
("Github", "https://github.com/Tygs/0bin"),
|
||||||
('Download 0bin', 'https://github.com/sametmax/0bin'), # external link
|
("Faq", "/faq/"), # You probably want to keep this
|
||||||
('Contact', 'mailto:your@email.com') # email
|
# Any link with "mailto:" will be escaped to limit spam, but displayed
|
||||||
|
# correctly to the user using JS.
|
||||||
|
("Contact", "mailto:your@email.com"),
|
||||||
|
("Zerobin Pastebin", "https://www.0bin.net/"), # Thanks the authors :)
|
||||||
|
("How to buy Bitcoin?", "/buy_bitcoin"), # Thanks the authors :)
|
||||||
)
|
)
|
||||||
|
|
||||||
# limit size of pasted text in bytes. Be careful allowing too much size can slow down user's
|
# limit size of pasted text in bytes. Be careful allowing too much size can slow down user's
|
||||||
|
123
dodo.py
123
dodo.py
@ -1,37 +1,67 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from fnmatch import fnmatch
|
||||||
|
from subprocess import check_output, STDOUT
|
||||||
|
|
||||||
import zerobin
|
from doit.tools import PythonInteractiveAction
|
||||||
|
|
||||||
|
try:
|
||||||
|
from local_dodo import *
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
ROOT = Path(__file__).absolute().parent
|
ROOT = Path(__file__).absolute().parent
|
||||||
SOURCE_DIR = ROOT / "zerobin/"
|
SOURCE_DIR = ROOT / "zerobin/"
|
||||||
DIST_DIR = ROOT / "dist"
|
DIST_DIR = ROOT / "dist"
|
||||||
|
|
||||||
|
ZEROBIN_VERSION = (SOURCE_DIR / "VERSION").read_text().strip()
|
||||||
|
|
||||||
def source_files(extensions=None):
|
DOIT_CONFIG = {
|
||||||
|
"default_tasks": ["task_compress"],
|
||||||
|
"action_string_formatting": "new",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def git(*args):
|
||||||
|
return check_output(
|
||||||
|
["git", *args], stderr=STDOUT, timeout=3, universal_newlines=True,
|
||||||
|
).rstrip("\n")
|
||||||
|
|
||||||
|
|
||||||
|
def source_files(extensions=None, exclude=()):
|
||||||
|
exclude_filter = ["*.pyc", ".*"]
|
||||||
|
exclude_filter.extend(exclude)
|
||||||
extensions = extensions or [".*"]
|
extensions = extensions or [".*"]
|
||||||
for ext in extensions:
|
for ext in extensions:
|
||||||
for file in SOURCE_DIR.rglob(f"*{ext}"):
|
for file in SOURCE_DIR.rglob(f"*{ext}"):
|
||||||
if (
|
if not (
|
||||||
not file.suffix.endswith("pyc")
|
file.is_dir()
|
||||||
and not file.is_dir()
|
or any(fnmatch(file, pattern) for pattern in exclude_filter)
|
||||||
and not "/." in str(file)
|
|
||||||
):
|
):
|
||||||
yield file
|
yield file
|
||||||
|
|
||||||
|
|
||||||
def generate_manifest():
|
def task_generate_manifest():
|
||||||
extensions = " ".join(set(f"*{f.suffix}" for f in source_files()))
|
def generate():
|
||||||
(ROOT / "MANIFEST.in").write_text(f"recursive-include zerobin {extensions}")
|
globs = " ".join(set(f"*{f.suffix}" for f in source_files()))
|
||||||
|
globs += " VERSION"
|
||||||
|
(ROOT / "MANIFEST.in").write_text(f"recursive-include zerobin {globs}")
|
||||||
|
|
||||||
|
return {
|
||||||
|
"targets": [ROOT / "MANIFEST.in"],
|
||||||
|
"actions": [generate],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def task_compress():
|
def task_compress():
|
||||||
|
main_js = str(SOURCE_DIR / "static/js/main.min.js")
|
||||||
|
main_css = str(SOURCE_DIR / "static/css/style.min.css")
|
||||||
return {
|
return {
|
||||||
"targets": [
|
"targets": [main_js, main_css],
|
||||||
str(SOURCE_DIR / "static/js/main.min.js"),
|
"file_dep": list(
|
||||||
str(SOURCE_DIR / "static/css/style.min.css"),
|
str(f) for f in source_files([".css", ".js"], exclude=[main_css, main_js])
|
||||||
],
|
),
|
||||||
"file_dep": list(str(f) for f in source_files([".css", ".js"])),
|
|
||||||
"actions": [str(ROOT / "compress.sh")],
|
"actions": [str(ROOT / "compress.sh")],
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,8 +69,69 @@ def task_compress():
|
|||||||
def task_build():
|
def task_build():
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"targets": [DIST_DIR / f"zerobin-{zerobin.__version__}-py3-none-any.whl"],
|
"targets": [DIST_DIR / f"zerobin-{ZEROBIN_VERSION}-py3-none-any.whl"],
|
||||||
"file_dep": list(str(f) for f in source_files() if ".min." not in str(f)),
|
"file_dep": list(str(f) for f in source_files() if ".min." not in str(f)),
|
||||||
"actions": [task_compress, generate_manifest, "python setup.py bdist_wheel",],
|
"task_dep": ["compress", "generate_manifest"],
|
||||||
|
"actions": ["python setup.py bdist_wheel"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def task_publish_to_pypi():
|
||||||
|
return {
|
||||||
|
"task_dep": ["build"],
|
||||||
|
"file_dep": [DIST_DIR / f"zerobin-{ZEROBIN_VERSION}-py3-none-any.whl"],
|
||||||
|
"actions": ["twine upload ./dist/*.whl"],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def task_bump_version():
|
||||||
|
def bump():
|
||||||
|
|
||||||
|
if git("branch", "--show-current") != "master":
|
||||||
|
sys.exit("You must be on the branch master to do that")
|
||||||
|
|
||||||
|
git("fetch", "origin", "master")
|
||||||
|
if git("rev-parse", "@{u}") != git("merge-base", "@", "@{u}"):
|
||||||
|
sys.exit("Cannot push a new version, you need to pull first")
|
||||||
|
|
||||||
|
git_status = git("status", "--porcelain=1").split("\n")
|
||||||
|
if not all(
|
||||||
|
line.startswith(" ") for line in git_status if not line.startswith("?")
|
||||||
|
):
|
||||||
|
sys.exit("Cannot commit the new version: you have changes to be commited.")
|
||||||
|
|
||||||
|
print("Current version is:", ZEROBIN_VERSION)
|
||||||
|
action = "0"
|
||||||
|
while action not in "123":
|
||||||
|
|
||||||
|
print("What kind of version is it?\n")
|
||||||
|
print("1) Major")
|
||||||
|
print("2) Minor")
|
||||||
|
print("3) Fix")
|
||||||
|
action = input("Enter 1, 2 or 3 (Ctrl + C to quit): ")
|
||||||
|
|
||||||
|
new_version = list(map(int, ZEROBIN_VERSION.split(".")))
|
||||||
|
action = int(action) - 1
|
||||||
|
new_version[action] += 1
|
||||||
|
new_version = ".".join(map(str, new_version))
|
||||||
|
|
||||||
|
print("The new version will be:", new_version)
|
||||||
|
if input("Ok? [y/N] ").strip().lower() != "y":
|
||||||
|
sys.exit("The version has NOT been bumped")
|
||||||
|
|
||||||
|
print("- Updating VERSION file")
|
||||||
|
(SOURCE_DIR / "VERSION").write_text(new_version)
|
||||||
|
print("- Commiting VERSION file")
|
||||||
|
git("commit", "-m", f"Bumping to version {new_version}")
|
||||||
|
print(f"- Adding v{new_version} tag")
|
||||||
|
git("tag", f"v{new_version}")
|
||||||
|
print("- Pushing tag")
|
||||||
|
git("push", "origin", "master", "--tag")
|
||||||
|
|
||||||
|
return {
|
||||||
|
"actions": [PythonInteractiveAction(bump),],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def task_release_to_pypi():
|
||||||
|
return {"task_dep": ["bump_version", "publish_to_pypi"], "actions": []}
|
||||||
|
1
zerobin/VERSION
Normal file
1
zerobin/VERSION
Normal file
@ -0,0 +1 @@
|
|||||||
|
1.0.4
|
@ -1,5 +1,5 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
__version__ = "1.0.3"
|
__version__ = (Path(__file__).parent / "VERSION").read_text().strip()
|
||||||
|
|
||||||
ROOT_DIR = Path(__file__).absolute().parent
|
ROOT_DIR = Path(__file__).absolute().parent
|
||||||
|
2
zerobin/static/css/style.min.css
vendored
2
zerobin/static/css/style.min.css
vendored
File diff suppressed because one or more lines are too long
@ -5,9 +5,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>0bin - encrypted pastebin</title>
|
<title>0bin - encrypted pastebin</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
|
||||||
<meta name="description" content="0bin is a client-side-encrypted
|
<meta name="description" content="0bin is a client-side-encrypted alternative pastebin. You can store code/text/images online for a set period of time and share with the world. Featuring burn after reading, history, clipboard.">
|
||||||
pastebin featuring burn after reading, history, and
|
|
||||||
a clipboard">
|
|
||||||
|
|
||||||
<link rel="icon" href="/static/img/favicon.ico" />
|
<link rel="icon" href="/static/img/favicon.ico" />
|
||||||
<link rel="apple-touch-icon" href="/static/img/apple-touch-icon.png" />
|
<link rel="apple-touch-icon" href="/static/img/apple-touch-icon.png" />
|
||||||
|
Reference in New Issue
Block a user