Compare commits

...

9 Commits

  1. 47
      README.md
  2. 4
      ozgursozluk/__init__.py
  3. 31
      ozgursozluk/configs.py
  4. 10
      ozgursozluk/scraper.py
  5. 2
      ozgursozluk/static/startpage.css
  6. 2
      ozgursozluk/templates/donate.html
  7. 19
      ozgursozluk/templates/settings.html
  8. 15
      ozgursozluk/utils.py
  9. 35
      ozgursozluk/views.py

@ -1,16 +1,15 @@
<img src="https://github.com/beucismis/ozgursozluk/assets/40023234/4f145030-2376-4d2d-acb0-39167212793f" width="380">
<img src="https://github.com/beucismis/ozgursozluk/assets/40023234/4f145030-2376-4d2d-acb0-39167212793f" width="350">
![](https://img.shields.io/badge/python-3.8%2B-blue)
![](https://img.shields.io/pypi/v/ozgursozluk)
![](https://img.shields.io/pypi/dm/ozgursozluk)
![](https://img.shields.io/badge/code%20style-black-black)
![](https://img.shields.io/github/actions/workflow/status/beucismis/ozgursozluk/tests.yml?label=tests)
![](https://img.shields.io/github/actions/workflow/status/beucismis/ozgursozluk/publish.yml?label=publish)
![](https://img.shields.io/badge/python-3.8%2B-blue?style=flat-square&labelColor=black&color=%237FBE4A)
![](https://img.shields.io/pypi/v/ozgursozluk?style=flat-square&labelColor=black&color=%237FBE4A)
![](https://img.shields.io/badge/code%20style-black-black?style=flat-square&labelColor=black&color=%237FBE4A)
![](https://img.shields.io/github/actions/workflow/status/beucismis/ozgursozluk/tests.yml?label=tests&style=flat-square&labelColor=black&color=%237FBE4A)
![](https://img.shields.io/github/actions/workflow/status/beucismis/ozgursozluk/publish.yml?label=publish&style=flat-square&labelColor=black&color=%237FBE4A)
A free and open source alternative ekşi sözlük front-end. Does not use the API, only scrapes the web.
Official instance: https://ozgursozluk.freedns.rocks</br>
Donate: https://ozgursozluk.freedns.rocks/donate
Official instance: (offline) https://ozgursozluk.freedns.rocks </br>
Donate: (offline) https://ozgursozluk.freedns.rocks/donate
## Features
@ -63,10 +62,24 @@ See also, https://github.com/beucismis/ozgursozluk/wiki/Main
| Key | Type | Default Value |
| - | - | - |
| `SECRET_KEY` | `str` | |
| `SECRET_KEY` | `str` | random |
| `FLASK_RUN_HOST` | `str` | `127.0.0.1` |
| `FLASK_RUN_PORT` | `str` | `5000` |
| `EKSI_SOZLUK_BASE_URL` | `str` | `https://eksisozluk1923.com` |
| `EKSI_SOZLUK_BASE_URL` | `str` | `https://eksisozluk.com` |
## Preview
<table>
<tbody>
<tr>
<td><img src="https://github.com/beucismis/ozgursozluk/assets/40023234/47ba12c6-e67c-43c7-9f99-652769db7c88"></td>
<td><img src="https://github.com/beucismis/ozgursozluk/assets/40023234/7bbe9de7-0165-4bc4-aba3-b2b306396372"></td>
<td><img src="https://github.com/beucismis/ozgursozluk/assets/40023234/d7621df4-9f74-4186-b633-d801a676176d"></td>
<td><img src="https://github.com/beucismis/ozgursozluk/assets/40023234/bc444a11-4b89-4ef0-9fc6-4d5f6318b626"></td>
<td><img src="https://github.com/beucismis/ozgursozluk/assets/40023234/78fde617-b634-4bb0-adf8-193159709c25"></td>
</tr>
</tbody>
</table>
## Redirection
@ -80,18 +93,6 @@ Pattern type: Regular Expression
Example result: https://ozgursozluk.freedns.rocks/linux--32084
```
## Preview
<table>
<tbody>
<tr>
<td><img src="https://github.com/beucismis/ozgursozluk/assets/40023234/620558a0-f518-42c8-9b2a-cc67067f63f3"></td>
<td><img src="https://github.com/beucismis/ozgursozluk/assets/40023234/2c4d2fc7-d5dc-4a20-bc09-03b8ea36caad"></td>
<td><img src="https://github.com/beucismis/ozgursozluk/assets/40023234/8dfd442c-cddb-41cd-ac3c-d95f0436e2e5"></td>
</tr>
</tbody>
</table>
## License
This project is licensed under WTFPL for details, check [LICENSE](LICENSE) file.

@ -3,9 +3,9 @@ from flask import Flask
from ozgursozluk.configs import SECRET_KEY
__version__ = "0.8.0"
__version__ = "0.8.1"
__source_code__ = "https://github.com/beucismis/ozgursozluk"
__description__ = "a free and open source alternative ekşi sözlük front-end"
__description__ = "A free and open source alternative ekşi sözlük front-end"
app = Flask(__name__)
app.secret_key = SECRET_KEY

@ -1,11 +1,25 @@
import secrets
from os import environ
from typing import Final
SECRET_KEY: Final = environ.get("OZGURSOZLUK_SECRET_KEY", "")
EKSI_SOZLUK_BASE_URL: Final = environ.get("EKSI_SOZLUK_BASE_URL", "https://eksisozluk.com")
SECRET_KEY: Final = environ.get("OZGURSOZLUK_SECRET_KEY", secrets.token_hex(24))
EKSI_SOZLUK_BASE_URL: Final = environ.get(
"EKSI_SOZLUK_BASE_URL", "https://eksisozluk.com"
)
DEFAULT_THEME: Final = "light"
THEMES: Final = [
"light",
"dark",
"amoled",
"violet",
"gruvbox",
"gruvboxlight",
"discord",
"startpage",
]
DEFAULT_THEME: Final = THEMES[0]
DEFAULT_DISPLAY_PINNED_TOPICS: Final = "true"
DEFAULT_DISPLAY_ENTRY_FAVORITE_COUNT: Final = "false"
DEFAULT_DISPLAY_ENTRY_AUTHOR: Final = "false"
@ -18,14 +32,3 @@ DEFAULT_COOKIES: Final = {
"display_entry_author": DEFAULT_DISPLAY_ENTRY_AUTHOR,
"display_entry_datetime": DEFAULT_DISPLAY_ENTRY_DATETIME,
}
THEMES: Final = [
"light",
"dark",
"amoled",
"violet",
"gruvbox",
"gruvboxlight",
"discord",
"startpage",
]

@ -6,7 +6,15 @@ from bs4 import BeautifulSoup
from fake_useragent import UserAgent
from ozgursozluk.configs import EKSI_SOZLUK_BASE_URL
from ozgursozluk.models import Entry, EntryTopic, Topic, Author, Gundem, Debe, SearchResult
from ozgursozluk.models import (
Entry,
EntryTopic,
Topic,
Author,
Gundem,
Debe,
SearchResult,
)
class EksiSozluk:

@ -4,7 +4,7 @@
--title-fg: #81C14B;
--entry-bg: #0c0d0f;
--entry-link-fg: #81C14B;
--border: #0c0d0f;
--border: #17191c;
--button-bg: #0c0d0f;
color-scheme: dark;
}

@ -8,7 +8,7 @@
<div class="topic donate">
<p>
donate to the developer <3
</br></br>
</br></br></br>
<b>bitcoin [btc]:</b></br>
3EEMjJwf1RE48iziynYYPweV1nsWguTUUz
</p>

@ -62,22 +62,19 @@
{% endfor %}
</select>
</div>
<div style="text-align: right; padding: 2rem 0.5rem 2rem 0.5rem;">
<div style="padding: 2rem 0.5rem 2rem 0.5rem;">
<button style="width: 100%;" type="submit">save</button>
</div>
</form>
</br>
<div style="text-align: center; padding-bottom: 0.5rem;">
<b>note:</b> settings are saved in browser cookies, clearing your cookies will reset them.
also this website does not have an official affiliation with eksisozluk.com.
</br></br>
<b>v{{ version }}</b>
-
last commit(s):
{% if last_commit == None %}
<a href="{{ source_code }}/commits" target="_blank">go</a>
{% else %}
<a href="{{ source_code }}/commit/{{ last_commit }}" target="_blank">{{ last_commit[:8] }}</a>
{% endif %}
also this website does not have an official affiliation with <i>eksisozluk.com</i>.
</br></br></br>
version {{ version }}
-
last commit:
<a href="{{ source_code }}/commit/{{ last_commit }}" target="_blank">{{ last_commit[:8] }}</a>
-
made with <3 on the <a href="{{ url_for('topic', path='thinkpad-t61--1883047') }}">t61</a>
</div>

@ -1,9 +1,5 @@
from datetime import datetime, timedelta
import requests
import ozgursozluk
def expires() -> datetime:
"""One year later."""
@ -12,12 +8,9 @@ def expires() -> datetime:
def last_commit() -> str:
"""Return the last commit ID."""
request = requests.get("https://api.github.com/repos/beucismis/ozgursozluk/commits")
"""Return the last commit hash."""
if request.status_code == 403:
return None
return request.json()[0]["sha"]
with open(".git/refs/heads/main") as file:
hash = file.read()
return hash

@ -4,11 +4,12 @@ from flask import url_for, redirect, request, render_template
import ozgursozluk
from ozgursozluk.scraper import EksiSozluk
from ozgursozluk.utils import last_commit, expires
from ozgursozluk.utils import expires, last_commit
from ozgursozluk.configs import THEMES, DEFAULT_COOKIES
es = EksiSozluk()
last_commit = last_commit()
@ozgursozluk.app.context_processor
@ -17,13 +18,20 @@ def global_template_variables():
return dict(
themes=THEMES,
last_commit=last_commit(),
last_commit=last_commit,
version=ozgursozluk.__version__,
source_code=ozgursozluk.__source_code__,
description=ozgursozluk.__description__,
)
@ozgursozluk.app.errorhandler(404)
def page_not_found(error):
"""Error handler route."""
return render_template("404.html"), 404
@ozgursozluk.app.route("/", methods=["GET", "POST"])
def index():
"""Index route."""
@ -42,6 +50,13 @@ def index():
return render_template("index.html", gundem=gundem, p=p)
@ozgursozluk.app.route("/debe")
def debe():
"""Debe route."""
return render_template("debe.html", debe=es.get_debe())
@ozgursozluk.app.route("/<path>")
def topic(path: str):
"""Topic route."""
@ -66,13 +81,6 @@ def author(nickname: str):
return render_template("author.html", author=es.get_author(nickname))
@ozgursozluk.app.route("/debe")
def debe():
"""Debe route."""
return render_template("debe.html", debe=es.get_debe())
@ozgursozluk.app.route("/search")
def search():
"""Search route."""
@ -87,7 +95,7 @@ def search():
@ozgursozluk.app.route("/random")
def random():
"""Random entry route."""
"""Random entry route. Experimental!"""
return redirect(url_for("entry", id=randint(1, 300_000_000)))
@ -119,10 +127,3 @@ def settings():
for cookie in DEFAULT_COOKIES
},
)
@ozgursozluk.app.errorhandler(404)
def page_not_found(error):
"""Error handler route."""
return render_template("404.html"), 404

Loading…
Cancel
Save