diff --git a/README.rst b/README.rst index d57f9fa..f3db271 100644 --- a/README.rst +++ b/README.rst @@ -12,15 +12,18 @@ to `moderate the pastebin content`_ as they have no way to decrypt it. It's an Python implementation of the `zerobin project`_, created by sebsauvage, under the `WTFPL licence`_. -For now tested with IE9, and the last opera, safari, chrome and FF. +To run zerobin, download zerobin.pyz from the latest release_ then: -There is a `good doc `_, -but in short:: +:: - pip install zerobin - zerobin + python zerobin.pyz + +0bin requires Python 3.7 or higher. + +You may need to type :code:`py -3.7 zerobin.pyz` on Windows, or :code:`python3.7 zerobin.pyz` on Mac/Linux, depending on your configuration. + +If you are familiar with the Python ecosystem, you can also :code:`python -m pip install zerobin --user` and run :code:`python -m zerobin` for the same effect. -0bin runs on Python 3.7+. How it works ============= @@ -69,7 +72,8 @@ Known issues .. _zerobin project: https://github.com/sebsauvage/ZeroBin/ .. _node.js: http://nodejs.org/ .. _is not worth it: http://stackoverflow.com/questions/201705/how-many-random-elements-before-md5-produces-collisions -.. _WTF licence: http://en.wikipedia.org/wiki/WTFPL +.. _WTFPL licence: http://en.wikipedia.org/wiki/WTFPL +.. _release: https://github.com/Tygs/0bin/releases Contributing ============= diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9ac9b91 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = [ + "setuptools >= 40.9.0", + "wheel", +] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index a7142a6..cfde55b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,3 +25,6 @@ install_requires = * = static/img/*, static/css/*, static/js/*, view/* hello = *.msg +[options.entry_points] +console_scripts = + zerobin = zerobin.cli:main diff --git a/setup.py b/setup.py deleted file mode 100644 index cc99f67..0000000 --- a/setup.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python - - -from setuptools import setup - - -setup() - diff --git a/zerobin/__init__.py b/zerobin/__init__.py index 5c09490..1200bdc 100644 --- a/zerobin/__init__.py +++ b/zerobin/__init__.py @@ -1,5 +1,5 @@ from pathlib import Path -__version__ = "1.0.0" +__version__ = "1.0.3" ROOT_DIR = Path(__file__).absolute().parent diff --git a/zerobin/cli.py b/zerobin/cli.py index 504366b..13670a3 100644 --- a/zerobin/cli.py +++ b/zerobin/cli.py @@ -158,13 +158,64 @@ def set_admin_password(password): settings.ADMIN_PASSWORD_FILE.write_bytes(hash_password(password)) +def clean_expired_pastes( + *, dry_run=False, verbose=False, config_dir="", data_dir="", +): + """ Clean expired file pastes and empty paste directories + + This features delete files from the data dir, make sure it's safe. + + Use "dry_run" and "verbose" options to check first + """ + + ensure_app_context(config_dir=config_dir, data_dir=data_dir) + + print("Deleting expired pastes...") + i = 0 + for p in Paste.iter_all(): + if p.has_expired: + if not dry_run: + p.delete() + if verbose: + print(p.path, "has expired") + i += 1 + if dry_run: + print(f"{i} pastes would have been deleted") + else: + print(f"{i} pastes deleted") + + print("Deleting empty paste directories...") + i = 0 + for p in settings.DATA_DIR.rglob("*"): + try: + if p.is_dir() and not next(p.iterdir(), None): + if not dry_run: + p.rmdir() + if verbose: + print(p, "is empty") + i += 1 + except OSError as e: + print(f'Error while processing "{p}: {e}') + if dry_run: + print(f"{i} directories would have been deleted") + else: + print(f"{i} directories deleted") + print("Done") + + def main(): - subcommands = [runserver, delete_paste, infos, set_admin_password] + subcommands = [ + runserver, + delete_paste, + infos, + set_admin_password, + clean_expired_pastes, + ] subcommand_names = [ clize.util.name_py2cli(name) for name in clize.util.dict_from_names(subcommands).keys() ] if len(sys.argv) < 2 or sys.argv[1] not in subcommand_names: sys.argv.insert(1, subcommand_names[0]) - clize.run(runserver, delete_paste, infos, set_admin_password) + clize.run(runserver, delete_paste, infos, set_admin_password, clean_expired_pastes) diff --git a/zerobin/default_settings.py b/zerobin/default_settings.py index 8b7b8e1..df0448f 100644 --- a/zerobin/default_settings.py +++ b/zerobin/default_settings.py @@ -1,6 +1,6 @@ # Get error messages and auto reload. # Don't set this to True in production -DEBUG = True +DEBUG = False # Port and host for the embedded python server HOST = "127.0.0.1" @@ -20,7 +20,7 @@ MENU = ( # Size limit of the paste content in bytes. Be careful, allowing a size too big can # slow down the user's browser -MAX_SIZE = 1024 * 600 +MAX_SIZE = 1024 * 1000 # Display a tiny counter for pastes created. DISPLAY_COUNTER = True diff --git a/zerobin/views/buy_bitcoin.tpl b/zerobin/views/buy_bitcoin.tpl index cd6fb1f..dc9d4be 100644 --- a/zerobin/views/buy_bitcoin.tpl +++ b/zerobin/views/buy_bitcoin.tpl @@ -1,85 +1,151 @@

How To Buy Bitcoin?

-

-

What is Bitcoin?

+

+ + +

What is Bitcoin?

+ + +

Bitcoin was created by Satoshi Nakamoto, a pseudonymous person or team who outlined the technology in a 2008 white + paper. It’s an appealingly simple concept: bitcoin is digital money that allows for secure + peer-to-peer transactions on the internet. +

+

Unlike services like Venmo and PayPal, which rely on the traditional financial system for permission to transfer + money and on existing debit/credit accounts, bitcoin is decentralized: any two people, anywhere in the world, can + send bitcoin to each other without the involvement of a bank, the government, or other institution. +

+ Every transaction involving Bitcoin is tracked on the blockchain, which is similar to a bank ledger, or log of + customers’ funds going in and out of the bank. In simple terms, it’s a record of every transaction ever made + using bitcoin. +

+

+ There will only ever be 21 million bitcoin. This is digital money that cannot be inflated or manipulated in any + way. +

+

+ It isn’t necessary to buy an entire bitcoin: you can buy just a fraction of one if that’s all you want or need. +

-

Bitcoin was created by Satoshi Nakamoto, a pseudonymous person or team who outlined the technology in a 2008 white paper. It’s an appealingly simple concept: bitcoin is digital money that allows for secure peer-to-peer transactions on the internet. -

-

Unlike services like Venmo and PayPal, which rely on the traditional financial system for permission to transfer money and on existing debit/credit accounts, bitcoin is decentralized: any two people, anywhere in the world, can send bitcoin to each other without the involvement of a bank, government, or other institution. -

- Every transaction involving Bitcoin is tracked on the blockchain, which is similar to a bank’s ledger, or log of customers’ funds going in and out of the bank. In simple terms, it’s a record of every transaction ever made using bitcoin. -

-

- There will only ever be 21 million bitcoin. This is digital money that cannot be inflated or manipulated in any way. -

-

- It isn’t necessary to buy an entire bitcoin: you can buy just a fraction of one if that’s all you want or need. -

Why would I buy Bitcoin?

-

Bitcoin is in the news today more than ever. Thanks to skyrocketing prices and rollercoaster dips, everyone and their dogs are interested in learning how to buy and sell Bitcoin. As the most popular form of cryptocurrency, Bitcoin is now widely accepted around the world and has a growing number of applications. If you want to take advantage of that though, you first need to know how to buy Bitcoin and what to do with it when you have. -

+ +

Bitcoin is in the news today more than ever. Thanks to skyrocketing prices and rollercoaster dips, everyone and + their dogs are interested in learning how to buy and sell Bitcoin. As the most popular form of cryptocurrency, + Bitcoin is now widely accepted around the world and has a growing number of applications. If you want to take + advantage of that though, you first need to know how to buy Bitcoin and what to do with it when you have. +

+

How to buy Bitcoin ?

-

The best place to make your first Bitcoin purchase is on an exchange. There are a whole lot of exchanges out there, with varying performance. Some are less trustworthy than others, and some can be quite limited, so it’s crucial to pick the right exchange in the first place. We recommend using Binance, follow the simple guide bellow to buy your first Bitcoins. -

+ +

The best place to make your first Bitcoin purchase is on an exchange. There are a whole lot of exchanges out + there, with varying performance. Some are less trustworthy than others, and some can be quite limited, so it’s + crucial to pick the right exchange in the first place. We recommend using Binance, follow the simple + guide below to buy your first Bitcoins. +

+
1. Buy Bitcoin on Binance
-

We recommend buying Bitcoins on Binance because in terms of volume, it is considered to be the world's leading platform. - In 2019, Binance reports an average trading volume of $2.8 billion per day. This platform, launched on July 14, 2017 in Hong Kong, has the advantage of operating with technical assistance 24 hours a day, 7 days a week. Its CEO Zhao Changpeng, who has become a billionaire, was featured on the cover of the prestigious Forbes magazine in February 2018. -

-
2. How do I register with Binance to buy Bitcoin?
+

We recommend buying Bitcoins on Binance because in terms of volume, it is considered to be the world's leading + platform. + In 2019, Binance reports an average trading volume of $2.8 billion per day. This platform, + launched on July 14, 2017, in Hong Kong, has the advantage of operating with technical assistance 24 hours a + day, 7 days a week. Its CEO Zhao Changpeng, who has become a billionaire, was featured on the + cover of the prestigious Forbes magazine in February 2018. +

-

The first step before buying Bitcoin on Binance is to register. The user must first select the language in which they want to access the site, then enter a valid email address and finally choose a password. -

-

Click here to register an account with Binance now!

+
2. How do I register with Binance to buy Bitcoin?
- Register Binance -

For your security, the platform offers you to proceed to the 2FA, also called "Two Step Verification", which consists in logging in with your password and your phone using Google Authenticator. Both we and the platform recommend that you delay the purchase of your Bitcoins by opting for this extra layer of security. Binance Academy 2fa available here. -

+

The first step before buying Bitcoin on Binance is to register. The user must first select the language in which they want + to access the site, then enter a valid email address and finally choose a password. +

- 2FA Binance -

The second step is to verify your identity. Indeed, Binance is subject to KYC regulations as part of the fight against money laundering and terrorist financing. The platform will ask you whether or not you reside in China, before moving on to other personal information (surname, first name, gender, country of residence). -

+

Click here + to register an account with Binance now!

- Verify identity Binance -

Authentication is done by sending the number and a photocopy of both sides of your ID and a photo of you. On this photo, you must show the same ID and a newspaper (or other document) with the current date. -

+ Register Binance - Verify identity Binance -

The easiest way to get Bitcoin at Binance is to buy it by credit card. To do so, head over to the “Buy Crypto” section on the Binance toolbar, and choose the “Buy with Credit Card” option. -

+

For your security, the platform offers you to proceed to the 2FA, also called "Two Step Verification", which + consists in logging in with your password and your phone using Google + Authenticator. Both we and the platform recommend that you delay the purchase of your Bitcoins by opting + for this extra layer of security. Binance Academy 2FA available here. +

- Verify identity Binance -

Select your currency and BTC coin you wish to purchase and enter the amount before clicking "Buy BTC". All you will need to do is enter your bank details and the purchase will be completed.

+ 2FA Binance - Verify identity Binance -

Although it is mainly focused on the exchange of cryptomoney, Binance is now establishing itself as a very competitive platform for the purchase of cryptomoney by credit card. It is also reassuring because of its reputation, its activity and its ecosystem.

+

The second step is to verify your identity. Indeed, Binance is subject to KYC regulations as part of the fight against money laundering + and terrorist financing. The platform will ask you whether or not you reside in China, before moving on to + other personal information (surname, first name, gender, country of residence). +

-

You're now a part of the future! Congrats!

-

-

Read more about Bitcoins -
Bitcoin.org -

+ Verify identity Binance + + +

Authentication is done by sending the number and a photocopy of both sides of your ID and a photo of you. On + this photo, you must show the same ID and a newspaper (or other document) with the current date. +

+ + + Verify identity Binance + + +

The easiest way to get Bitcoin at Binance is to buy it by credit card. To do so, head over to the “Buy Crypto” + section on the Binance + toolbar, and choose the “Buy with Credit Card” option. +

+ + + Verify identity Binance + + +

Select your currency and BTC coin you wish to purchase and enter the amount before clicking "Buy BTC". All you + will need to do is enter your bank details and the purchase will be completed.

+ + + Verify identity Binance + + +

Although it is mainly focused on the exchange of cryptomoney, Binance is now establishing + itself as a very competitive platform for the purchase of cryptomoney by credit card. It is also reassuring + because of its reputation, its activity and its ecosystem.

+ + +

You're now a part of the future! Congrats!

+ + +

+

Read more about Bitcoins +
Bitcoin.org +

+
+ % rebase("base", settings=settings, pastes_count=pastes_count)