aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ignis/views.py24
-rw-r--r--templates/dev_status/home.html6
2 files changed, 25 insertions, 5 deletions
diff --git a/ignis/views.py b/ignis/views.py
index 67201aaf..9f539d05 100644
--- a/ignis/views.py
+++ b/ignis/views.py
@@ -51,10 +51,30 @@ def get_image(request, slug, md5):
@csrf_exempt
def cover_image(request, repository):
- url = 'https://socialify.git.ci/luciferreeves/{}/png?font=KoHo&language=1&name=1&pattern=Floating%20Cogs&theme=Dark'.format(repository)
+ url = 'https://socialify.git.ci/luciferreeves/{}/png?font=KoHo&language=1&name=1&pattern=Solid&theme=Dark'.format(repository)
image = requests.get(url).content
- return HttpResponse(image, content_type='image/png')
+
+ # reduce image size to 320x160
+ image = Image.open(BytesIO(image))
+ image = image.resize((320, 160), Image.ANTIALIAS)
+
+ # remove black background
+ image = image.convert('RGBA').getdata()
+ new_data = []
+ for item in image:
+ if item[0] == 0 and item[1] == 0 and item[2] == 0:
+ new_data.append((255, 255, 255, 0))
+ else:
+ new_data.append(item)
+
+ # Convert back to png and return
+ output = BytesIO()
+ image = Image.new('RGBA', (320, 160))
+ image.putdata(new_data)
+ image.save(output, format='GIF')
+ return HttpResponse(output.getvalue(), content_type='image/gif')
+
def upload_image(request):
if request.method == 'POST':
diff --git a/templates/dev_status/home.html b/templates/dev_status/home.html
index 91a00276..31b22a74 100644
--- a/templates/dev_status/home.html
+++ b/templates/dev_status/home.html
@@ -49,12 +49,12 @@
<table style="width=720px; margin: 0 auto; table-layout: fixed;">
{% for repo in repos %}
<tr>
- <td>
- <a href="{% url 'dev_status:repo' repo.name %}" style="display: inline-block; margin-right: 10px; background-image: url('{% url 'ignis:cover_image' repo.name %}');" class="zoom"></a>
+ <td><a href="{% url 'dev_status:repo' repo.name %}">
+ <img src="{% url 'ignis:cover_image' repo.name %}" style="display: inline-block; margin-right: 10px;" class="zoom">
</a>
</td>
<td>
- <p style="font-size: 20px; font-weight: bold;">{{ repo.name }}</p>
+ <p style="font-size: 20px; font-weight: bold;"><a href="{% url 'dev_status:repo' repo.name %}">{{ repo.name }}</a></p>
<p style="font-size: 15px;">{{ repo.description }}</p>
</td>