Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
uploads
*.pyc
env/
Binary file added dist/yldme-0.0.1-py3.7.egg
Binary file not shown.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Pygments==2.2.0
tornado==5.1.1
prompt-toolkit<2.1.0,>=2.0.0
44 changes: 44 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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)
22 changes: 19 additions & 3 deletions yldme.py → yldme/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import pygments.styles
import pygments.util

__version__ = 1
# Configuration ----------------------------------------------------------------

YLDME_PRESETS = [
Expand Down Expand Up @@ -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 --------------------------------------------------------------------

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand All @@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.