Compare commits

...

3 commits

8 changed files with 815057 additions and 4 deletions

Binary file not shown.

View file

@ -1,6 +1,26 @@
services: services:
web: web:
build: . # Путь к Dockerfile (в текущей директории) build: . # Путь к Dockerfile (в текущей директории)
<<<<<<< HEAD
container_name: workshop
# ports:
# - "80:5000" # Проброс портов
volumes:
- /storage/public/complete/workshop/:/data
networks:
- all
labels:
- traefik.enable=true
- traefik.http.routers.workshop.rule=Host(`csgoworkshop.ru`) || Host(`www.csgoworkshop.ru`)
- traefik.http.routers.workshop.entrypoints=websecure, web
- traefik.http.routers.workshop.tls=true
- traefik.http.routers.workshop.tls.certresolver=production-cloudflare
restart: unless-stopped
networks:
all:
external: true
=======
ports: ports:
- "80:5000" # Проброс портов - "80:5000" # Проброс портов
volumes: volumes:
@ -12,3 +32,4 @@ volumes:
type: cifs type: cifs
o: "username=Shaman,password=" o: "username=Shaman,password="
device: "//192.168.31.3/share/public/complete/workshop" device: "//192.168.31.3/share/public/complete/workshop"
>>>>>>> 9cc0929a09596abeb93ee7f2711527fb5da25f7a

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View file

@ -6,7 +6,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>workshop</title> <title>workshop</title>
<link rel="stylesheet" href="{{ url_for('static', filename='main.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='main.css') }}">
<<<<<<< HEAD
<link rel="icon" href="https://csgoworkshop.ru/favicon.ico" type="image/x-icon">
=======
<link rel="icon" href="{{ url_for('static', filename='assets/steam-120.ico') }}" type="image/x-icon"> <link rel="icon" href="{{ url_for('static', filename='assets/steam-120.ico') }}" type="image/x-icon">
>>>>>>> 9cc0929a09596abeb93ee7f2711527fb5da25f7a
</head> </head>
@ -23,7 +27,7 @@
{{ description }} {{ description }}
</div> </div>
<a href="{{ url_for('download_bsp', image_path=image_url) }}"> <a href="{{ url_for('download_bsp', image_path=image_url) }}">
<button class="download-btn">🡇 Скачать</button> <button class="download-btn">Скачать</button>
</a> </a>
</div> </div>

View file

@ -5,17 +5,48 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>workshop</title> <title>workshop</title>
<<<<<<< HEAD
<link rel="icon" href="https://csgoworkshop.ru/favicon.ico" type="image/x-icon">
=======
<link rel="icon" href="{{ url_for('static', filename='assets/steam-120.ico') }}" type="image/x-icon"> <link rel="icon" href="{{ url_for('static', filename='assets/steam-120.ico') }}" type="image/x-icon">
>>>>>>> 9cc0929a09596abeb93ee7f2711527fb5da25f7a
<link rel="stylesheet" href="{{ url_for('static', filename='workshop.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='workshop.css') }}">
<script src="{{ url_for('static', filename='workshop.js') }}" defer></script> <script src="{{ url_for('static', filename='workshop.js') }}" defer></script>
<!-- Yandex.Metrika counter -->
<script type="text/javascript">
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
ym(99366428, "init", {
clickmap:true,
trackLinks:true,
accurateTrackBounce:true
});
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/99366428" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->
</head> </head>
<body> <body>
<<<<<<< HEAD
<div class="top-bar"> <div class="top-bar">
<div class="left-text"> <div class="left-text">
<p>Сделал: ©️𝙎𝙃∆𝙈∆𝙉©️</p> <p>Сделал: ©️𝙎𝙃∆𝙈∆𝙉©️</p>
<p>Неофициальный сайт<br>с картами для CS:GO<br>из мастерской Steam</p> <p>Неофициальный сайт<br>с картами для CS:GO<br>из мастерской Steam</p>
</div> </div>
<h1 class="center-text">CS:GO Workshop</h1>
<a href="https://cloud.s.shsr.ru/apps/forms/s/xr8NyqdpsodwcNnRBSrMzJ4N" class="contact-button" target="_blank">Связаться</a>
=======
<div class="top-bar">
<div class="left-text">
<p>Сделал: ©️𝙎𝙃∆𝙈∆𝙉©️</p>
<p>Неофициальный сайт<br>с картами для CS:GO<br>из мастерской Steam</p>
>>>>>>> 9cc0929a09596abeb93ee7f2711527fb5da25f7a
</div>
<h1 class="center-text">Добро пожаловать в Workshop</h1> <h1 class="center-text">Добро пожаловать в Workshop</h1>
<a href="https://cloud.s.shsr.ru/apps/forms/s/xr8NyqdpsodwcNnRBSrMzJ4N" class="contact-button" target="_blank">Связаться</a> <!-- Добавлен target="_blank" --> <a href="https://cloud.s.shsr.ru/apps/forms/s/xr8NyqdpsodwcNnRBSrMzJ4N" class="contact-button" target="_blank">Связаться</a> <!-- Добавлен target="_blank" -->
</div> </div>

120
main.py
View file

@ -5,6 +5,10 @@ import aiosqlite
from quart import Quart, render_template, request, send_from_directory, Response from quart import Quart, render_template, request, send_from_directory, Response
from datetime import datetime from datetime import datetime
from babel.dates import format_datetime from babel.dates import format_datetime
<<<<<<< HEAD
from urllib.parse import quote
=======
>>>>>>> 9cc0929a09596abeb93ee7f2711527fb5da25f7a
@ -29,6 +33,7 @@ last_download_times = {}
DOWNLOAD_COOLDOWN = 10 DOWNLOAD_COOLDOWN = 10
async def get_maps(page=1, per_page=30): async def get_maps(page=1, per_page=30):
print(f"Запрос карт на странице {page}, с {per_page} картами на странице.")
async with aiosqlite.connect(DB_PATH) as conn: async with aiosqlite.connect(DB_PATH) as conn:
cursor = await conn.cursor() cursor = await conn.cursor()
@ -43,54 +48,89 @@ async def get_maps(page=1, per_page=30):
maps = await cursor.fetchall() maps = await cursor.fetchall()
print(f"Получено {len(maps)} карт на странице {page}.")
return maps return maps
def get_image_path(filepath): def get_image_path(filepath):
<<<<<<< HEAD
print(f"Получение пути изображения для файла: {filepath}")
image_path = os.path.join(DATA, filepath) image_path = os.path.join(DATA, filepath)
if not os.path.exists(image_path): if not os.path.exists(image_path):
print("Изображение не найдено, возвращаем дефолтное.")
=======
image_path = os.path.join(DATA, filepath)
if not os.path.exists(image_path):
>>>>>>> 9cc0929a09596abeb93ee7f2711527fb5da25f7a
return "/images/image.jpg" return "/images/image.jpg"
return f"/images/{filepath.split('/')[0]}/{filepath.split('/')[1]}/{filepath.split('/')[1]}.jpg" return f"/images/{filepath.split('/')[0]}/{filepath.split('/')[1]}/{filepath.split('/')[1]}.jpg"
def get_star_image(stars): def get_star_image(stars):
print(f"Получение изображения для {stars} звезд.")
if stars is None or stars == 0: if stars is None or stars == 0:
return "/stars/0-star.png" return "/stars/0-star.png"
return f"/stars/{stars}-star.png" return f"/stars/{stars}-star.png"
@app.route('/images/<path:filename>') @app.route('/images/<path:filename>')
async def serve_image(filename): async def serve_image(filename):
<<<<<<< HEAD
print(f"Запрос изображения с именем: {filename}")
image_path = os.path.join(DATA, filename) image_path = os.path.join(DATA, filename)
if os.path.exists(image_path): if os.path.exists(image_path):
print(f"Изображение {filename} найдено и отправляется.")
=======
image_path = os.path.join(DATA, filename)
if os.path.exists(image_path):
>>>>>>> 9cc0929a09596abeb93ee7f2711527fb5da25f7a
return await send_from_directory(DATA, filename) return await send_from_directory(DATA, filename)
else: else:
default_image_path = os.path.join(DATA, 'image.jpg') default_image_path = os.path.join(DATA, 'image.jpg')
if os.path.exists(default_image_path): if os.path.exists(default_image_path):
<<<<<<< HEAD
print("Изображение не найдено, отправляем дефолтное.")
return await send_from_directory(DATA, 'image.jpg') return await send_from_directory(DATA, 'image.jpg')
print("Не найдено ни одного изображения.")
=======
return await send_from_directory(DATA, 'image.jpg')
>>>>>>> 9cc0929a09596abeb93ee7f2711527fb5da25f7a
return "Default image not found", 404 return "Default image not found", 404
@app.route('/stars/<filename>') @app.route('/stars/<filename>')
async def serve_star_image(filename): async def serve_star_image(filename):
<<<<<<< HEAD
print(f"Запрос изображения звезды: {filename}")
stars = os.path.join(DATA, 'stars') stars = os.path.join(DATA, 'stars')
star_path = os.path.join(stars, filename) star_path = os.path.join(stars, filename)
if os.path.exists(star_path): if os.path.exists(star_path):
print(f"Звезда {filename} найдена и отправляется.")
=======
stars = os.path.join(DATA, 'stars')
star_path = os.path.join(stars, filename)
if os.path.exists(star_path):
>>>>>>> 9cc0929a09596abeb93ee7f2711527fb5da25f7a
return await send_from_directory(stars, filename) return await send_from_directory(stars, filename)
else: else:
print("Изображение звезды не найдено.")
return "Star image not found", 404 return "Star image not found", 404
@app.route('/download_bsp') @app.route('/download_bsp')
async def download_bsp(): async def download_bsp():
user_ip = request.remote_addr user_ip = request.remote_addr
print(f"Запрос на скачивание от IP: {user_ip}")
current_time = time.time() current_time = time.time()
last_time = last_download_times.get(user_ip, 0) last_time = last_download_times.get(user_ip, 0)
if current_time - last_time < DOWNLOAD_COOLDOWN: if current_time - last_time < DOWNLOAD_COOLDOWN:
wait_time = DOWNLOAD_COOLDOWN - (current_time - last_time) wait_time = DOWNLOAD_COOLDOWN - (current_time - last_time)
print(f"Пользователь должен подождать {int(wait_time)} секунд до следующего скачивания.")
return f"Please wait {int(wait_time)} seconds before downloading again.", 429 return f"Please wait {int(wait_time)} seconds before downloading again.", 429
last_download_times[user_ip] = current_time last_download_times[user_ip] = current_time
print("Тайм-аут скачивания обновлен.")
image_path = request.args.get('image_path') image_path = request.args.get('image_path')
if not image_path: if not image_path:
print("Не указан путь к изображению.")
return "No image path provided", 400 return "No image path provided", 400
image_folder = os.path.dirname(image_path.replace("/images/", "")) image_folder = os.path.dirname(image_path.replace("/images/", ""))
@ -102,13 +142,19 @@ async def download_bsp():
break break
if not bsp_filename: if not bsp_filename:
print("Не найден .bsp файл в той же директории.")
return "No .bsp file found in the same directory", 404 return "No .bsp file found in the same directory", 404
file_path = os.path.join(DATA, image_folder, bsp_filename) file_path = os.path.join(DATA, image_folder, bsp_filename)
<<<<<<< HEAD
print(f"Найден файл для скачивания: {file_path}")
=======
>>>>>>> 9cc0929a09596abeb93ee7f2711527fb5da25f7a
SPEED_LIMIT = 40 * 1024 * 1024 // 8 SPEED_LIMIT = 60 * 1024 * 1024 // 8
async def file_stream(): async def file_stream():
print("Начало передачи файла по частям.")
with open(file_path, 'rb') as f: with open(file_path, 'rb') as f:
while chunk := f.read(SPEED_LIMIT): while chunk := f.read(SPEED_LIMIT):
yield chunk yield chunk
@ -121,6 +167,7 @@ async def download_bsp():
@app.route('/main') @app.route('/main')
async def main_page(): async def main_page():
print("Запрос страницы карты с параметрами:", request.args)
image_url = request.args.get('image_url', 'default_image.jpg') image_url = request.args.get('image_url', 'default_image.jpg')
map_title = request.args.get('map_title', 'Default Map Title') map_title = request.args.get('map_title', 'Default Map Title')
@ -167,6 +214,9 @@ async def main_page():
else: else:
file_size_display = 'Не найден' file_size_display = 'Не найден'
print(f"Отправка страницы карты {map_title} с данными:")
print(f"Игра: {game_mode}, Теги: {tags}, Размер файла: {file_size_display}, Время добавления: {added_time}")
return await render_template( return await render_template(
'main.html', 'main.html',
image_url=image_url, image_url=image_url,
@ -182,6 +232,7 @@ async def main_page():
@app.route('/') @app.route('/')
async def index(): async def index():
print("Запрос главной страницы с параметрами фильтрации:", request.args)
page = int(request.args.get('page', 1)) page = int(request.args.get('page', 1))
selected_game_modes = request.args.getlist('game_modes') selected_game_modes = request.args.getlist('game_modes')
start_date = request.args.get('start_date') start_date = request.args.get('start_date')
@ -232,6 +283,7 @@ async def index():
([f'stars={selected_stars}'] if selected_stars else []) ([f'stars={selected_stars}'] if selected_stars else [])
) )
print(f"Общее количество карт: {total_maps}, Страниц: {total_pages}")
return await render_template( return await render_template(
'workshop.html', 'workshop.html',
maps_data=maps_data, maps_data=maps_data,
@ -245,6 +297,7 @@ async def index():
) )
async def get_maps_filtered(page=1, selected_game_modes=None, start_date=None, end_date=None, search_title=None, selected_stars=None): async def get_maps_filtered(page=1, selected_game_modes=None, start_date=None, end_date=None, search_title=None, selected_stars=None):
print(f"Фильтрация карт с параметрами: {locals()}")
async with aiosqlite.connect(DB_PATH) as conn: async with aiosqlite.connect(DB_PATH) as conn:
cursor = await conn.cursor() cursor = await conn.cursor()
@ -281,11 +334,76 @@ async def get_maps_filtered(page=1, selected_game_modes=None, start_date=None, e
await cursor.execute(query, params) await cursor.execute(query, params)
maps = await cursor.fetchall() maps = await cursor.fetchall()
print(f"Найдено {len(maps)} карт после фильтрации.")
return maps return maps
@app.route('/favicon.ico')
async def favicon():
return await send_from_directory(os.getcwd(), 'favicon.ico')
@app.route('/sitemap.xml')
async def sitemap():
domain = "https://csgoworkshop.ru"
async with aiosqlite.connect(DB_PATH) as conn:
cursor = await conn.cursor()
# Получаем список всех карт
await cursor.execute('SELECT Title FROM maps')
maps = await cursor.fetchall()
# Создаем базовые URL для sitemap
urls = [
f"{domain}/",
f"{domain}/main",
]
# Добавляем URL-адреса для всех карт
for map_title, in maps:
encoded_title = quote(map_title)
urls.append(f"{domain}/main?map_title={encoded_title}")
# Генерируем XML
sitemap_xml = '<?xml version="1.0" encoding="UTF-8"?>\n'
sitemap_xml += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'
for url in urls:
sitemap_xml += " <url>\n"
sitemap_xml += f" <loc>{url}</loc>\n"
sitemap_xml += f" <lastmod>{datetime.utcnow().strftime('%Y-%m-%d')}</lastmod>\n"
sitemap_xml += " <changefreq>weekly</changefreq>\n"
sitemap_xml += " <priority>0.8</priority>\n"
sitemap_xml += " </url>\n"
sitemap_xml += '</urlset>'
return Response(sitemap_xml, content_type='application/xml')
@app.route('/robots.txt')
async def robots_txt():
content = """
User-agent: *
Disallow:
"""
return Response(content, content_type='text/plain')
if __name__ == '__main__': if __name__ == '__main__':
<<<<<<< HEAD
print("Запуск приложения...")
import hypercorn.asyncio
from hypercorn.config import Config
config = Config()
config.bind = ["0.0.0.0:5000"]
hypercorn.asyncio.run(app, config)
=======
import hypercorn.asyncio import hypercorn.asyncio
from hypercorn.config import Config from hypercorn.config import Config
config = Config() config = Config()
config.bind = ["0.0.0.0:5000"] config.bind = ["0.0.0.0:5000"]
hypercorn.asyncio.run(app, config) hypercorn.asyncio.run(app, config)
>>>>>>> 9cc0929a09596abeb93ee7f2711527fb5da25f7a

View file

@ -1,4 +1,8 @@
aiosqlite~=0.20.0 aiosqlite~=0.20.0
Hypercorn~=0.17.3 Hypercorn~=0.17.3
Quart~=0.19.6 Quart~=0.19.6
<<<<<<< HEAD
babel~=2.16.0 babel~=2.16.0
=======
babel~=2.16.0
>>>>>>> 9cc0929a09596abeb93ee7f2711527fb5da25f7a

814875
sitemap.xml Normal file

File diff suppressed because it is too large Load diff