diff --git a/src/linter/lint.py b/src/linter/lint.py deleted file mode 100644 index 4c87861..0000000 --- a/src/linter/lint.py +++ /dev/null @@ -1,34 +0,0 @@ -# Last "as" keyword is in the form ab_cd, where "a" and -# "b" are the first letters of the two words of the module -# and "c" and "d" are the first letters of the two words -# of the function of the module. - -from rules.content_about import trailing_slash as ca_ts -from rules.featured_playlists import trailing_slash as fp_ts -from rules.youtubers_names import trailing_slash as yn_ts - - -def main() -> None: - """ - Main function. Used specifically to call print results - by calling functions into rules/. - - Functions: - content_about: trailing_slash, comma_separated - featured_playlists: trailing_slash, closed_backsticks - youtubers_names: trailing_slash, youtube_link - """ - - # "youtubers_names" - print("YouTubers names:") - print(yn_ts()) - # "content_about" - print("Content about:") - print(ca_ts()) - # "featured_playlists" - print("Featured playlists:") - print(fp_ts()) - - -if __name__ == '__main__': - main() diff --git a/src/linter/readme.md b/src/linter/readme.md deleted file mode 100644 index c97639e..0000000 --- a/src/linter/readme.md +++ /dev/null @@ -1,14 +0,0 @@ -# Awesome YouTubers linter - -The awesome-youtubers linter is a workflow that checks the layout of the pull requests opened. This helps the contributors show if -something in the layout is not formatted correctly so it can be fixed. This linter was created in order to keep the format of the -list without breaking the layouts (images, new lines, etc.) - -## Rules - -| File containing | Rules followed | -| ---------------------------------------------------------- | ---------------------------------------------------------------------------- | -| [YouTuber's name and link](rules/youtubers_names.py) line. | - Trailing `\`
- Spaces between badges | -| [Content about](rules/content_about.py) line. | - Trailing `\`
- Spaces between words (including `,`) | -| [Featured playlists](rules/featured_playlists.py) line. | - Trailing `\`
- Spaces between words (including `,`) and a trailing `.` | -| [Links formatted](rules/link_format.py) | - Well-formatted links (`[text](link)`) | diff --git a/src/linter/rules/__init__.py b/src/linter/rules/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/linter/rules/content_about.py b/src/linter/rules/content_about.py deleted file mode 100644 index cbb9aff..0000000 --- a/src/linter/rules/content_about.py +++ /dev/null @@ -1,36 +0,0 @@ -import pathlib - -here = pathlib.Path(__file__).parent -file_readme = here / '../../../readme.md' -with open(file_readme, 'r') as read_readme: - content = read_readme.readlines() - -CHECKER = "Content about:" - - -def trailing_slash() -> str: - """ - Looks for backslash and the end of all the matching - lines ("Content about:" lines). - """ - - result = ["🟢 0: perfect."] - - for line, value in enumerate(content): - if CHECKER in value: - last = value[-2] - if last != "\\": - if last == " ": - content[line] = f"{value[:-1]}\\\n" - else: - content[line] = f"{value[:-1]} \\\n" - - with open(file_readme, 'w') as write_readme: - write_readme.writelines(content) - - result.append(f"🔴 {line}: backslash. Fixed.") - - if len(result) > 1: - return '\n'.join(result[1:]) - else: - return ''.join(result) diff --git a/src/linter/rules/featured_playlists.py b/src/linter/rules/featured_playlists.py deleted file mode 100644 index 11bebc4..0000000 --- a/src/linter/rules/featured_playlists.py +++ /dev/null @@ -1,56 +0,0 @@ -import pathlib - -here = pathlib.Path(__file__).parent -file_readme = here / '../../../readme.md' -with open(file_readme, 'r') as read_readme: - content = read_readme.readlines() - -CHECKER = "Featured playlists:" -LENGTH = 124 - - -def trailing_slash() -> str: - """ - Looks for backslash and the end of all the matching - lines ("Featured playlists:" lines) and a line - break tag "
" at the next line. - """ - - result = ["🟢 0: perfect."] - - for line, value in enumerate(content): - if CHECKER in value: - last = value[-2] - if len(value) < LENGTH: - if last != "\\" and "
" not in content[line+1]: - if last == " ": - content[line] = f"{value[:-1]}\\\n
\n" - else: - content[line] = f"{value[:-1]} \\\n
\n" - - with open(file_readme, 'w') as write_readme: - write_readme.writelines(content) - - result.append(f"🔴 {line}: backslash | line break. Fixed.") - elif last != "\\" and "
" in content[line+1]: - if last == " ": - content[line] = f"{value[:-1]}\\\n" - else: - content[line] = f"{value[:-1]} \\\n" - - with open(file_readme, 'w') as write_readme: - write_readme.writelines(content) - - result.append(f"🔴 {line}: backslash. Fixed.") - elif last == "\\" and "
" not in content[line+1]: - content[line+1] = "
\n\n" - - with open(file_readme, 'w') as write_readme: - write_readme.writelines(content) - - result.append(f"🔴 {line}: line break. Fixed.") - - if len(result) > 1: - return '\n'.join(result[1:]) - else: - return ''.join(result) diff --git a/src/linter/rules/youtubers_names.py b/src/linter/rules/youtubers_names.py deleted file mode 100644 index 11ebed8..0000000 --- a/src/linter/rules/youtubers_names.py +++ /dev/null @@ -1,36 +0,0 @@ -import pathlib - -here = pathlib.Path(__file__).parent -file_readme = here / '../../../readme.md' -with open(file_readme, 'r') as read_readme: - content = read_readme.readlines() - -CHECKER = "[**" - - -def trailing_slash() -> str: - """ - Looks for backslash and the end of all the matching - lines (YouTubers names lines). - """ - - result = ["🟢 0: perfect."] - - for line, value in enumerate(content): - if CHECKER in value: - last = value[-2] - if last != "\\": - if last == " ": - content[line] = f"{value[:-1]}\\\n" - else: - content[line] = f"{value[:-1]} \\\n" - - with open(file_readme, 'w') as write_readme: - write_readme.writelines(content) - - result.append(f"🔴 {line}: backslash. Fixed.") - - if len(result) > 1: - return '\n'.join(result[1:]) - else: - return ''.join(result) diff --git a/src/voter/Procfile b/src/voter/Procfile deleted file mode 100644 index dc46f1b..0000000 --- a/src/voter/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: gunicorn main:app \ No newline at end of file diff --git a/src/voter/main.py b/src/voter/main.py deleted file mode 100644 index 882a802..0000000 --- a/src/voter/main.py +++ /dev/null @@ -1,121 +0,0 @@ -import threading -from flask import ( - Flask, make_response, - request, render_template -) -from flask_sqlalchemy import SQLAlchemy -from flask_limiter import Limiter -from flask_limiter.util import get_remote_address - -# App configuration - -app = Flask(__name__) -app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///youtubers.sqlite3" -app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False - -db = SQLAlchemy(app) - -limiter = Limiter(app, key_func=get_remote_address,) - -lock = threading.Lock() - - -# Database model - -class Channel(db.Model): - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String, unique=True, nullable=False) - vote = db.Column(db.Integer, default=0, nullable=False) - - -channels = Channel.query.order_by(Channel.name).all() -channels_names = [cname.name for cname in channels] - - -# Routes - -@app.route("/") -@limiter.exempt -def index(): - """ Main route of the website. """ - return "Awesome YouTubers voting system website." - - -@app.route("/channels/all") -@limiter.exempt -def list_channels(): - """ Lists all channels in the database. """ - - return render_template("all.html", channels=channels) - - -@app.route("/channels/") -@limiter.limit("20 per minute") -def get_channel(channel): - """ - If no query specified, prints the name of the - YouTube channel typed. When a query with the - name "vote" is given, adds or substracts 1 - from the specified YouTube score. - """ - - if "vote" in request.args: - vote = str(request.args["vote"]) - - if channel in channels_names: - cvote = Channel.query.filter_by(name=channel).first() - # Adds/substracts 1 from the channel. - if vote == "upvote": - cvote.vote += 1 - db.session.commit() - elif vote == "downvote": - cvote.vote -= 1 - db.session.commit() - else: - return "Vote word not recognised." - - return f"You {vote}d successfully the channel {channel}." - else: - return "Channel not found on the list." - else: - if channel in channels_names: - return "Channel: " + channel - else: - return "Channel not found on the list." - - -@app.route("/channels//image.svg") -@limiter.exempt -def img_channel(channel): - """ Returns the YouTube score in a svg image. """ - - if channel in channels_names: - cvote = Channel.query.filter_by(name=channel).first() - svg_image = f""" - - - - - - {cvote.vote} - - - - """ - - response = make_response(svg_image) - response.headers.set('Content-Type', 'image/svg+xml') - return response - else: - return "Channel not found on the list." - - -if __name__ == "__main__": - db.create_all() - app.run(debug=True) diff --git a/src/voter/readme.md b/src/voter/readme.md deleted file mode 100644 index 7e2017f..0000000 --- a/src/voter/readme.md +++ /dev/null @@ -1,35 +0,0 @@ -# Awesome YouTubers voting system - -## How to vote a YouTuber? - -It's as easy as clicking one of the two options that are located at the right-most part of the -YouTuber's name on the [list](../readme.md). You'll be redirected to the Awesome YouTubers -voting system website. You'll see the name of the YouTube channel and the vote you gave it. -This is anonymous and does not require authentication. - -If you think the YouTuber is awesome, you can upvote the channel. If not, you can downvote the -channel. When you upvote a channel you sum 1 to its calification, whereas when you downvote it -you substract 1 from its calification. The score the YouTuber has appears next to the icons. -The value starts at 0 and goes above and below it according to the votes. - -## How does it work? - -Each YouTuber has two options (upvote and downvote) on the YouTuber's name line. The options -each YouTuber has are linked to the Awesome YouTubers voting system website (see the source -in this folder) by the name of the YouTuber. When you click an option, the website opens with -the YouTuber's channel name and the vote you gave it (upvote = +1; downvote = -1). Your vote gets -automatically sent to a database when the scores are stored. They then get printed in the -[readme.md](../readme.md) file by referencing the image url. - -## Motivation - -Despite having already a [discussion about YouTubers](https://github.com/JoseDeFreitas/awesome-youtubers/discussions/32) -(specifically the ones that according to the community should be removed from the list for x or y -reasons) this voting system makes it easier, anonymous, and fair to decide if a YouTuber should be -on this list. All the YouTubers added get revised by me (I check whether the information the -contributor provided matches and I watch some videos looking for well explanations, good audio and -video quality, coverage of the topics it explains, among others), but, of course, I'm only one person, -so I think being able to receive opinions from all users is a good way to filter and have truly -awesome content based on the community's opinion. - - diff --git a/src/voter/requirements.txt b/src/voter/requirements.txt deleted file mode 100644 index 13fa70e..0000000 Binary files a/src/voter/requirements.txt and /dev/null differ diff --git a/src/voter/templates/all.html b/src/voter/templates/all.html deleted file mode 100644 index 0f196b1..0000000 --- a/src/voter/templates/all.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends 'base.html' %} - -{% block content %} - - - - - - {% for channel in channels %} - - - - - {% endfor %} -
NameVote
{{ channel.name }}{{ channel.vote }}
-{% endblock %} \ No newline at end of file diff --git a/src/voter/templates/base.html b/src/voter/templates/base.html deleted file mode 100644 index 07c1422..0000000 --- a/src/voter/templates/base.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - Awesome YouTubers - - - {% block content %} - {% endblock %} - - \ No newline at end of file diff --git a/src/voter/youtubers.sqlite3 b/src/voter/youtubers.sqlite3 deleted file mode 100644 index decd465..0000000 Binary files a/src/voter/youtubers.sqlite3 and /dev/null differ