Compare commits
2 Commits
afb13b6a03
..
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 85d1e2be85 | |||
| e6bc69aa3e |
@@ -33,11 +33,6 @@ def tmsmp(sec: int) -> str:
|
|||||||
days = round(sec / 86400, 1)
|
days = round(sec / 86400, 1)
|
||||||
return f"{days:.0f} d" if days.is_integer() else f"{days:.1f} d"
|
return f"{days:.0f} d" if days.is_integer() else f"{days:.1f} d"
|
||||||
|
|
||||||
def utmsmp(unix: int) -> str:
|
|
||||||
return datetime \
|
|
||||||
.utcfromtimestamp(unix) \
|
|
||||||
.strftime('%Y-%m-%d %H:%M:%S')
|
|
||||||
|
|
||||||
def rtmsmp(unix: int) -> str:
|
def rtmsmp(unix: int) -> str:
|
||||||
return tmsmp(int(time() - unix))
|
return tmsmp(int(time() - unix))
|
||||||
|
|
||||||
@@ -53,7 +48,8 @@ def render_tmpl(filename: str, **kwargs) -> str:
|
|||||||
template_path = os.path.join("risdeveau/templates", filename)
|
template_path = os.path.join("risdeveau/templates", filename)
|
||||||
return minify(
|
return minify(
|
||||||
render_template(template_path, **kwargs),
|
render_template(template_path, **kwargs),
|
||||||
remove_empty_space=True
|
remove_empty_space=True,
|
||||||
|
remove_all_empty_space=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@bp.route("/static/<path:filename>")
|
@bp.route("/static/<path:filename>")
|
||||||
@@ -77,7 +73,6 @@ args = {
|
|||||||
"lb": lb_data,
|
"lb": lb_data,
|
||||||
"steam": steam_data,
|
"steam": steam_data,
|
||||||
"tmsmp": tmsmp,
|
"tmsmp": tmsmp,
|
||||||
"utmsmp": utmsmp,
|
|
||||||
"rtmsmp": rtmsmp
|
"rtmsmp": rtmsmp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,13 @@ data = {
|
|||||||
def modify_game_list(json: dict) -> dict:
|
def modify_game_list(json: dict) -> dict:
|
||||||
if 'games' in json.keys():
|
if 'games' in json.keys():
|
||||||
apps = (3301060, 404790, 1281930, 1920960, 1325960, 431960)
|
apps = (3301060, 404790, 1281930, 1920960, 1325960, 431960)
|
||||||
new_games = []
|
new_games = {}
|
||||||
for i, g in enumerate(json['games']):
|
for i, g in enumerate(json['games']):
|
||||||
if g['appid'] not in apps:
|
if g['appid'] not in apps:
|
||||||
json['games'][i]['h_cover'] = f"https://shared.fastly.steamstatic.com/store_item_assets//steam/apps/{g['appid']}/header.jpg"
|
json['games'][i]['h_cover'] = f"https://shared.fastly.steamstatic.com/store_item_assets//steam/apps/{g['appid']}/header.jpg"
|
||||||
json['games'][i]['v_cover'] = f"https://shared.fastly.steamstatic.com/store_item_assets//steam/apps/{g['appid']}/library_600x900.jpg"
|
json['games'][i]['v_cover'] = f"https://shared.fastly.steamstatic.com/store_item_assets//steam/apps/{g['appid']}/library_600x900.jpg"
|
||||||
new_games.append(json['games'][i])
|
|
||||||
|
new_games[g['appid']] = json['games'][i]
|
||||||
json['games'] = new_games
|
json['games'] = new_games
|
||||||
return json
|
return json
|
||||||
|
|
||||||
|
|||||||
@@ -65,4 +65,72 @@ document.addEventListener('alpine:init', () => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
Alpine.data('steam_rtime', (unixTimestamp) => ({
|
||||||
|
targetDate: new Date(unixTimestamp * 1000),
|
||||||
|
timeString: '',
|
||||||
|
timer: null,
|
||||||
|
interval: 1000,
|
||||||
|
|
||||||
|
colorClasses: {
|
||||||
|
green: 't-green',
|
||||||
|
yellow: 't-yellow',
|
||||||
|
orange: 't-orange',
|
||||||
|
red: 't-red'
|
||||||
|
},
|
||||||
|
|
||||||
|
currentColor: 'green',
|
||||||
|
|
||||||
|
get textColorClass() {
|
||||||
|
return this.colorClasses[this.currentColor];
|
||||||
|
},
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this.updateTime();
|
||||||
|
this.timer = setInterval(() => this.updateTime(), this.interval);
|
||||||
|
|
||||||
|
this.$el.addEventListener('alpine:removing', () => {
|
||||||
|
if (this.interval) clearInterval(this.interval);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
updateTime() {
|
||||||
|
const now = new Date();
|
||||||
|
const diffInMinutes = Math.floor((now - this.targetDate) / 60000);
|
||||||
|
const diffInHours = Math.floor(diffInMinutes / 60);
|
||||||
|
const diffInDays = Math.floor(diffInHours / 24);
|
||||||
|
const diffInMonths = Math.floor(diffInDays / 30);
|
||||||
|
|
||||||
|
let newInterval = this.interval;
|
||||||
|
|
||||||
|
if (diffInMinutes < 60) {
|
||||||
|
this.timeString = `${diffInMinutes} m ago`;
|
||||||
|
newInterval = 10000;
|
||||||
|
} else if (diffInHours < 24) {
|
||||||
|
this.timeString = `${diffInHours} h ago`;
|
||||||
|
newInterval = 60000;
|
||||||
|
} else if (diffInDays < 30) {
|
||||||
|
this.timeString = `${diffInDays} d ago`;
|
||||||
|
clearInterval(this.timer);
|
||||||
|
} else {
|
||||||
|
this.timeString = `${diffInMonths} mth ago`;
|
||||||
|
clearInterval(this.timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diffInHours < 12) {
|
||||||
|
this.currentColor = 'green';
|
||||||
|
} else if (diffInDays < 1) {
|
||||||
|
this.currentColor = 'yellow';
|
||||||
|
} else if (diffInMonths < 6) {
|
||||||
|
this.currentColor = 'orange'
|
||||||
|
} else {
|
||||||
|
this.currentColor = 'red';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.interval != newInterval) {
|
||||||
|
clearInterval(this.timer)
|
||||||
|
this.timer = setInterval(() => this.updateTime(), newInterval);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
@@ -51,7 +51,27 @@ h3 {
|
|||||||
|
|
||||||
.steam {
|
.steam {
|
||||||
.block {
|
.block {
|
||||||
|
&:not(.popup) {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.popup {
|
||||||
|
margin-top: -.5rem;
|
||||||
|
padding-top: 1rem;
|
||||||
|
background-color: theme.$mantle;
|
||||||
|
transition: all ease-out 300ms;
|
||||||
|
|
||||||
|
&.enter {}
|
||||||
|
|
||||||
|
&.off {
|
||||||
|
margin-bottom: -.5rem;
|
||||||
|
padding: 0 .5rem;
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-100%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
height: 7rem;
|
height: 7rem;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<h3>Contacts</h3>
|
<h3>Contacts</h3>
|
||||||
<div class="blocks badges">
|
<div class="blocks badges">
|
||||||
<a class="block" href="https://matrix.to/#/@risdeveau:lair.moe">
|
<a class="block" href="https://matrix.to/#/@risdeveau:codrs.ru">
|
||||||
<img class="icon" src="https://matrix.org/assets/favicon.ico" />
|
<img class="icon" src="https://matrix.org/assets/favicon.ico" />
|
||||||
Matrix
|
Matrix
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -37,11 +37,11 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Programmer</td>
|
<td>Programmer</td>
|
||||||
<td>2.5/4yr.</td>
|
<td>2/4yr.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Translator</td>
|
<td>Translator</td>
|
||||||
<td>2.5/3yr.</td>
|
<td>2/3yr.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
{% if request.headers.get('hx-request') != "true" %}
|
||||||
|
<div x-data='{ "current": null, "total_mode": "T" }' class="mt-1">
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="block steam"
|
class="block steam"
|
||||||
hx-get="/m/steam"
|
hx-get="/m/steam"
|
||||||
@@ -10,10 +14,12 @@
|
|||||||
>
|
>
|
||||||
<h2><a href="https://steamcommunity.com/id/risdeveau">Steam</a></h2>
|
<h2><a href="https://steamcommunity.com/id/risdeveau">Steam</a></h2>
|
||||||
|
|
||||||
|
{{ steam.caches.recent.status }}
|
||||||
|
{{ steam.caches.owned.status }}
|
||||||
{% if steam.caches.recent.data.games %}
|
{% if steam.caches.recent.data.games %}
|
||||||
<h3>Recently played:</h3>
|
<h3>Recently played:</h3>
|
||||||
{% for g in steam.caches.recent.data.games %}
|
{% for g in steam.caches.recent.data.games.values() %}
|
||||||
<a href="https://store.steampowered.com/app/{{ g.appid }}" class="block">
|
<div href="https://store.steampowered.com/app/{{ g.appid }}" class="block">
|
||||||
<picture>
|
<picture>
|
||||||
<source media="(max-width: 45rem)" srcset="{{ g.v_cover }}">
|
<source media="(max-width: 45rem)" srcset="{{ g.v_cover }}">
|
||||||
<img src="{{ g.h_cover }}">
|
<img src="{{ g.h_cover }}">
|
||||||
@@ -22,14 +28,35 @@
|
|||||||
<div>
|
<div>
|
||||||
<strong>{{ g.name }}</strong>
|
<strong>{{ g.name }}</strong>
|
||||||
<p>Played last 2 weeks: {{ tmsmp(g.playtime_2weeks*60) }}
|
<p>Played last 2 weeks: {{ tmsmp(g.playtime_2weeks*60) }}
|
||||||
<p>
|
|
||||||
Total played:
|
<div>
|
||||||
{{ tmsmp(g.playtime_linux_forever*60) }} (<abbr title="On Linux">L</abbr>) +
|
<p
|
||||||
{{ tmsmp(g.playtime_windows_forever*60) }} (<abbr title="On Windows">W</abbr>) =
|
x-data='{ playtime: { L: "{{ tmsmp(g.playtime_linux_forever*60) }}", W: "{{ tmsmp(g.playtime_windows_forever*60) }}", T: "{{ tmsmp(g.playtime_forever*60) }}" }}'
|
||||||
{{ tmsmp(g.playtime_forever*60) }} (<abbr title="Total">T</abbr>)
|
x-text="`Total played: ${playtime[total_mode]}`"
|
||||||
|
>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button @click="total_mode = 'L'" :class="total_mode == 'L' && 't-green'">L</button>
|
||||||
|
<button @click="total_mode = 'W'" :class="total_mode == 'W' && 't-green'">W</button>
|
||||||
|
<button @click="total_mode = 'T'" :class="total_mode == 'T' && 't-green'">T</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if steam.caches.owned.data.games %}
|
||||||
|
{% if steam.caches.owned.data.games[g.appid] %}
|
||||||
|
<p
|
||||||
|
x-data="steam_rtime({{ steam.caches.owned.data.games[g.appid].rtime_last_played }})"
|
||||||
|
x-text="`Last played: ${timeString}`"
|
||||||
|
:class="textColorClass"
|
||||||
|
></p>
|
||||||
|
{% else %}
|
||||||
|
<p class="t-red">Last played: Unknown</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<p
|
<p
|
||||||
x-data="rtime({{steam.caches.recent.last_updated}})"
|
x-data="rtime({{steam.caches.recent.last_updated}})"
|
||||||
@@ -39,9 +66,13 @@
|
|||||||
|
|
||||||
{% if steam.caches.owned.data.games %}
|
{% if steam.caches.owned.data.games %}
|
||||||
<h3>Top played games:</h3>
|
<h3>Top played games:</h3>
|
||||||
{% set owned_games = steam.caches.owned.data.games | sort(attribute="playtime_forever", reverse=true) %}
|
{% set owned_games = steam.caches.owned.data.games.values() | sort(attribute="playtime_forever", reverse=true) %}
|
||||||
{% for g in owned_games[:5] %}
|
{% for g in owned_games[:5] %}
|
||||||
<a href="https://store.steampowered.com/app/{{ g.appid }}" class="block">
|
<div
|
||||||
|
@click='current == {{ g.appid }} ? current = null : current = {{ g.appid }}'
|
||||||
|
href="https://store.steampowered.com/app/{{ g.appid }}"
|
||||||
|
class="block"
|
||||||
|
>
|
||||||
<picture>
|
<picture>
|
||||||
<source media="(max-width: 45rem)" srcset="{{ g.v_cover }}">
|
<source media="(max-width: 45rem)" srcset="{{ g.v_cover }}">
|
||||||
<img src="{{ g.h_cover }}">
|
<img src="{{ g.h_cover }}">
|
||||||
@@ -56,14 +87,39 @@
|
|||||||
{{ tmsmp(g.playtime_forever*60) }} (<abbr title="Total">T</abbr>)
|
{{ tmsmp(g.playtime_forever*60) }} (<abbr title="Total">T</abbr>)
|
||||||
</p>
|
</p>
|
||||||
{% if g.rtime_last_played != 0 %}
|
{% if g.rtime_last_played != 0 %}
|
||||||
<p>Last played: {{ utmsmp(g.rtime_last_played) }}</p>
|
<p
|
||||||
|
x-data="steam_rtime({{ g.rtime_last_played }})"
|
||||||
|
x-text="`Last played: ${timeString}`"
|
||||||
|
:class="textColorClass"
|
||||||
|
></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</div>
|
||||||
|
<div
|
||||||
|
class="block popup"
|
||||||
|
x-show="current == {{ g.appid }}"
|
||||||
|
x-transition:enter-start="off"
|
||||||
|
x-transition:leave-end="off"
|
||||||
|
>
|
||||||
|
<p>Some info</p>
|
||||||
|
<p>Some info</p>
|
||||||
|
<p>Some info</p>
|
||||||
|
<p>Some info</p>
|
||||||
|
<p>Some info</p>
|
||||||
|
<p>Some info</p>
|
||||||
|
<p>Some info</p>
|
||||||
|
<p>Some info</p>
|
||||||
|
<p>Some info</p>
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<p
|
<p
|
||||||
x-data="rtime({{steam.caches.owned.last_updated}})"
|
x-data="rtime({{steam.caches.owned.last_updated}})"
|
||||||
x-text="`Last updated: ${timeString}`"
|
x-text="`Last updated: ${timeString}`"
|
||||||
></p>
|
></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if request.headers.get('hx-request') != "true" %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
@use "catppuccin" as theme;
|
@use "catppuccin" as theme;
|
||||||
|
|
||||||
|
.m {
|
||||||
|
&t {
|
||||||
|
&-1 { margin-top: .5rem; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.t {
|
.t {
|
||||||
&-red { color: theme.$red; }
|
&-red { color: theme.$red; }
|
||||||
&-orange { color: theme.$peach; }
|
&-orange { color: theme.$peach; }
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<p><a href="https://m.lair.moe" target="_blank"><strong>Matrix</strong></a> — {{ _('index.descr:matrix') }}</p>
|
<p><a href="https://m.codrs.ru" target="_blank"><strong>Matrix</strong></a> — {{ _('index.descr:matrix') }}</p>
|
||||||
<p><a href="https://c.lair.moe" target="_blank"><strong>Copyparty</strong></a> — {{ _('index.descr:copyparty') }}</p>
|
<p><a href="https://c.lair.moe" target="_blank"><strong>Copyparty</strong></a> — {{ _('index.descr:copyparty') }}</p>
|
||||||
<p><a href="https://tools.lair.moe" target="_blank"><strong>IT-tools</strong></a> — {{ _('index.descr:tools') }}</p>
|
<p><a href="https://tools.lair.moe" target="_blank"><strong>IT-tools</strong></a> — {{ _('index.descr:tools') }}</p>
|
||||||
<p><a href="https://vert.lair.moe" target="_blank"><strong>Vert</strong></a> — {{ _('index.descr:vert') }}</p>
|
<p><a href="https://vert.lair.moe" target="_blank"><strong>Vert</strong></a> — {{ _('index.descr:vert') }}</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user