diff --git a/.gitignore b/.gitignore index c8daccf..b105b2a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ uploads *.pyc +env/ diff --git a/dist/yldme-0.0.1-py3.7.egg b/dist/yldme-0.0.1-py3.7.egg new file mode 100644 index 0000000..386ce2c Binary files /dev/null and b/dist/yldme-0.0.1-py3.7.egg differ diff --git a/requirements.txt b/requirements.txt index eb49ede..c3ee74e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ Pygments==2.2.0 tornado==5.1.1 +prompt-toolkit<2.1.0,>=2.0.0 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..8dea9f6 --- /dev/null +++ b/setup.py @@ -0,0 +1,44 @@ +"""yldme setup""" +import setuptools +import yldme + +LONG_DESC = open('README.md').read() +# VERSION = yldme.__version__ +with open('requirements.txt') as f: + requirements = f.read().splitlines() + +VERSION = "0.0.1" +# DOWNLOAD = "https://github.com/dylanaraps/pywal/archive/%s.tar.gz" % VERSION + +setuptools.setup( + name="yldme", + version=VERSION, + author="Peter Bui", + author_email="pbui@nd.edu", + description="Pastebin and url shortener", + long_description_content_type="text/markdown", + long_description=LONG_DESC, + keywords="pastebin url-shortnener", + license="MIT", + url="https://github.com/pbui/yldme", + # download_url=DOWNLOAD, + classifiers=[ + "Environment :: X11 Applications", + "License :: OSI Approved :: MIT License", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + ], + packages=["yldme"], + package_data={'': [ + 'templates/*', + 'assets/css/*', + 'assets/css/pygments/*', + 'uploads/',]}, + install_requires=requirements, + setup_requires=requirements, + entry_points={"console_scripts": ["yldme=yldme.__main__:main"]}, + python_requires=">=3.5", + test_suite="tests", + include_package_data=True, + zip_safe=False) diff --git a/yldme.py b/yldme/__main__.py similarity index 94% rename from yldme.py rename to yldme/__main__.py index ffa9c61..3fb14e5 100755 --- a/yldme.py +++ b/yldme/__main__.py @@ -23,6 +23,7 @@ import pygments.styles import pygments.util +__version__ = 1 # Configuration ---------------------------------------------------------------- YLDME_PRESETS = [ @@ -51,14 +52,23 @@ ('cse-40175-fa18' , 'https://www3.nd.edu/~pbui/teaching/cse.40175.fa18/', 'url'), ('pbc-su17' , 'https://www3.nd.edu/~pbui/teaching/pbc.su17/' , 'url'), ] -YLDME_URL = 'https://yld.me' -YLDME_PORT = 9515 +# YLDME_URL = 'https://yld.me' +YLDME_URL = '127.0.0.1' +YLDME_PORT = 8888 YLDME_ADDRESS = '127.0.0.1' YLDME_ALPHABET = string.ascii_letters + string.digits YLDME_MAX_TRIES = 10 YLDME_ASSETS = os.path.join(os.path.dirname(__file__), 'assets') YLDME_STYLES = os.path.join(YLDME_ASSETS, 'css', 'pygments') YLDME_UPLOADS = os.path.join(os.path.dirname(__file__), 'uploads') +# current_dir = os.path.dirname(__file__) +# current_dir = current_dir.split('/') +# current_dir = current_dir[:len(current_dir) - 2] +# current_dir = '/'.join(current_dir) +# YLDME_UPLOADS = os.path.join(current_dir, 'uploads') +# YLDME_ASSETS = os.path.join(current_dir, 'assets') +# YLDME_STYLES = os.path.join(YLDME_ASSETS, 'css', 'pygments') +print(YLDME_UPLOADS) # Constants -------------------------------------------------------------------- @@ -265,6 +275,10 @@ def post(self, type=None): name = self.application.generate_name() self.application.database.add(name, value_hash, type) if type != 'url': + print("looking for", YLDME_UPLOADS) + if not os.path.isdir(YLDME_UPLOADS): + print("did not find") + os.makedirs(YLDME_UPLOADS) with open(os.path.join(YLDME_UPLOADS, name), 'wb+') as fs: fs.write(value) data = self.application.database.get(name) @@ -316,7 +330,7 @@ def run(self): # Main execution --------------------------------------------------------------- -if __name__ == '__main__': +def main(): tornado.options.define('debug', default=False, help='Enable debugging mode.') tornado.options.define('port', default=YLDME_PORT, help='Port to listen on.') tornado.options.define('template_path', default=os.path.join(os.path.dirname(__file__), "templates"), help='Path to templates') @@ -326,4 +340,6 @@ def run(self): yldme = YldMeApplication(**options) yldme.run() +if __name__ == '__main__': + main() # vim: sts=4 sw=4 ts=8 expandtab ft=python diff --git a/assets/css/blugold.css b/yldme/assets/css/blugold.css similarity index 100% rename from assets/css/blugold.css rename to yldme/assets/css/blugold.css diff --git a/assets/css/pygments/GENERATE.SH b/yldme/assets/css/pygments/GENERATE.SH similarity index 100% rename from assets/css/pygments/GENERATE.SH rename to yldme/assets/css/pygments/GENERATE.SH diff --git a/assets/css/pygments/autumn.css b/yldme/assets/css/pygments/autumn.css similarity index 100% rename from assets/css/pygments/autumn.css rename to yldme/assets/css/pygments/autumn.css diff --git a/assets/css/pygments/borland.css b/yldme/assets/css/pygments/borland.css similarity index 100% rename from assets/css/pygments/borland.css rename to yldme/assets/css/pygments/borland.css diff --git a/assets/css/pygments/bw.css b/yldme/assets/css/pygments/bw.css similarity index 100% rename from assets/css/pygments/bw.css rename to yldme/assets/css/pygments/bw.css diff --git a/assets/css/pygments/colorful.css b/yldme/assets/css/pygments/colorful.css similarity index 100% rename from assets/css/pygments/colorful.css rename to yldme/assets/css/pygments/colorful.css diff --git a/assets/css/pygments/default.css b/yldme/assets/css/pygments/default.css similarity index 100% rename from assets/css/pygments/default.css rename to yldme/assets/css/pygments/default.css diff --git a/assets/css/pygments/emacs.css b/yldme/assets/css/pygments/emacs.css similarity index 100% rename from assets/css/pygments/emacs.css rename to yldme/assets/css/pygments/emacs.css diff --git a/assets/css/pygments/friendly.css b/yldme/assets/css/pygments/friendly.css similarity index 100% rename from assets/css/pygments/friendly.css rename to yldme/assets/css/pygments/friendly.css diff --git a/assets/css/pygments/fruity.css b/yldme/assets/css/pygments/fruity.css similarity index 100% rename from assets/css/pygments/fruity.css rename to yldme/assets/css/pygments/fruity.css diff --git a/assets/css/pygments/igor.css b/yldme/assets/css/pygments/igor.css similarity index 100% rename from assets/css/pygments/igor.css rename to yldme/assets/css/pygments/igor.css diff --git a/assets/css/pygments/manni.css b/yldme/assets/css/pygments/manni.css similarity index 100% rename from assets/css/pygments/manni.css rename to yldme/assets/css/pygments/manni.css diff --git a/assets/css/pygments/monokai.css b/yldme/assets/css/pygments/monokai.css similarity index 100% rename from assets/css/pygments/monokai.css rename to yldme/assets/css/pygments/monokai.css diff --git a/assets/css/pygments/murphy.css b/yldme/assets/css/pygments/murphy.css similarity index 100% rename from assets/css/pygments/murphy.css rename to yldme/assets/css/pygments/murphy.css diff --git a/assets/css/pygments/native.css b/yldme/assets/css/pygments/native.css similarity index 100% rename from assets/css/pygments/native.css rename to yldme/assets/css/pygments/native.css diff --git a/assets/css/pygments/paraisodark.css b/yldme/assets/css/pygments/paraisodark.css similarity index 100% rename from assets/css/pygments/paraisodark.css rename to yldme/assets/css/pygments/paraisodark.css diff --git a/assets/css/pygments/paraisolight.css b/yldme/assets/css/pygments/paraisolight.css similarity index 100% rename from assets/css/pygments/paraisolight.css rename to yldme/assets/css/pygments/paraisolight.css diff --git a/assets/css/pygments/pastie.css b/yldme/assets/css/pygments/pastie.css similarity index 100% rename from assets/css/pygments/pastie.css rename to yldme/assets/css/pygments/pastie.css diff --git a/assets/css/pygments/perldoc.css b/yldme/assets/css/pygments/perldoc.css similarity index 100% rename from assets/css/pygments/perldoc.css rename to yldme/assets/css/pygments/perldoc.css diff --git a/assets/css/pygments/rrt.css b/yldme/assets/css/pygments/rrt.css similarity index 100% rename from assets/css/pygments/rrt.css rename to yldme/assets/css/pygments/rrt.css diff --git a/assets/css/pygments/tango.css b/yldme/assets/css/pygments/tango.css similarity index 100% rename from assets/css/pygments/tango.css rename to yldme/assets/css/pygments/tango.css diff --git a/assets/css/pygments/trac.css b/yldme/assets/css/pygments/trac.css similarity index 100% rename from assets/css/pygments/trac.css rename to yldme/assets/css/pygments/trac.css diff --git a/assets/css/pygments/vim.css b/yldme/assets/css/pygments/vim.css similarity index 100% rename from assets/css/pygments/vim.css rename to yldme/assets/css/pygments/vim.css diff --git a/assets/css/pygments/vs.css b/yldme/assets/css/pygments/vs.css similarity index 100% rename from assets/css/pygments/vs.css rename to yldme/assets/css/pygments/vs.css diff --git a/assets/css/pygments/xcode.css b/yldme/assets/css/pygments/xcode.css similarity index 100% rename from assets/css/pygments/xcode.css rename to yldme/assets/css/pygments/xcode.css diff --git a/assets/js/index_interactive.js b/yldme/assets/js/index_interactive.js similarity index 100% rename from assets/js/index_interactive.js rename to yldme/assets/js/index_interactive.js diff --git a/templates/index.tmpl b/yldme/templates/index.tmpl similarity index 100% rename from templates/index.tmpl rename to yldme/templates/index.tmpl diff --git a/templates/paste.tmpl b/yldme/templates/paste.tmpl similarity index 100% rename from templates/paste.tmpl rename to yldme/templates/paste.tmpl