Delete src directory

This commit is contained in:
José De Freitas 2021-04-22 16:33:08 -05:00 committed by GitHub
parent cacac033b1
commit 75fa5e22fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 0 additions and 362 deletions

View File

@ -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()

View File

@ -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 `\`<br/>- Spaces between badges |
| [Content about](rules/content_about.py) line. | - Trailing `\`<br/>- Spaces between words (including `,`) |
| [Featured playlists](rules/featured_playlists.py) line. | - Trailing `\`<br/>- Spaces between words (including `,`) and a trailing `.` |
| [Links formatted](rules/link_format.py) | - Well-formatted links (`[text](link)`) |

View File

@ -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)

View File

@ -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 "<br>" 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 "<br>" not in content[line+1]:
if last == " ":
content[line] = f"{value[:-1]}\\\n<br>\n"
else:
content[line] = f"{value[:-1]} \\\n<br>\n"
with open(file_readme, 'w') as write_readme:
write_readme.writelines(content)
result.append(f"🔴 {line}: backslash | line break. Fixed.")
elif last != "\\" and "<br>" 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 "<br>" not in content[line+1]:
content[line+1] = "<br>\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)

View File

@ -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)

View File

@ -1 +0,0 @@
web: gunicorn main:app

View File

@ -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/<channel>")
@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/<channel>/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"""
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
width="52px" height="22px" viewBox="0 0 52 22" fill="none">
<style>
.text {{
font-family: "Segoe UI", Ubuntu, Sans-Serif;
font-weight: bold;
}}
</style>
<rect x="0.5" y="0.5" height="99%" width="51" fill="none"/>
<g>
<text x="5" y="15" fill="#00b4f0" class="text">
{cvote.vote}
</text>
</g>
</svg>
"""
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)

View File

@ -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.
<img src="https://awesome-youtubers.herokuapp.com/channels/Don_Jones/image.svg">

Binary file not shown.

View File

@ -1,16 +0,0 @@
{% extends 'base.html' %}
{% block content %}
<table>
<tr>
<th>Name</th>
<th>Vote</th>
</tr>
{% for channel in channels %}
<tr>
<td>{{ channel.name }}</td>
<td>{{ channel.vote }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}

View File

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Awesome YouTubers</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>

Binary file not shown.