mirror of
https://github.com/openvk/openvk
synced 2025-04-23 16:43:02 +03:00
Compare commits
4 commits
17d4b22b1b
...
e49f927186
Author | SHA1 | Date | |
---|---|---|---|
|
e49f927186 | ||
|
4166481a75 | ||
7fe0c6a122 | |||
|
c6f3d767fc |
8 changed files with 196 additions and 127 deletions
238
.github/workflows/build.yaml
vendored
238
.github/workflows/build.yaml
vendored
|
@ -3,142 +3,140 @@ name: Build images
|
|||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
BASE_IMAGE_NAME: openvk
|
||||
DB_IMAGE_NAME: mariadb
|
||||
EVENT_IMAGE_NAME: mariadb
|
||||
DB_VERSION: "10.9"
|
||||
BASE_IMAGE_NAME: openvk
|
||||
DB_IMAGE_NAME: mariadb
|
||||
EVENT_IMAGE_NAME: mariadb
|
||||
DB_VERSION: '10.9'
|
||||
|
||||
jobs:
|
||||
buildbase:
|
||||
name: Build base images
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [amd64, arm64]
|
||||
buildbase:
|
||||
name: Build base images
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
steps:
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
|
||||
- name: Change repository string to lowercase
|
||||
id: repositorystring
|
||||
uses: Entepotenz/change-string-case-action-min-dependencies@v1.1.0
|
||||
with:
|
||||
string: ${{ github.repository }}
|
||||
- name: Change repository string to lowercase
|
||||
id: repositorystring
|
||||
uses: Entepotenz/change-string-case-action-min-dependencies@v1.1.0
|
||||
with:
|
||||
string: ${{ github.repository }}
|
||||
|
||||
- name: Base image meta
|
||||
id: basemeta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/${{ steps.repositorystring.outputs.lowercase }}/${{env.BASE_IMAGE_NAME}}
|
||||
labels: |
|
||||
org.opencontainers.image.documentation=https://github.com/OpenVK/openvk/blob/master/install/automated/docker/Readme.md
|
||||
tags: |
|
||||
type=sha
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=ref,event=tag
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
- name: Base image meta
|
||||
id: basemeta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/${{ steps.repositorystring.outputs.lowercase }}/${{env.BASE_IMAGE_NAME}}
|
||||
labels: |
|
||||
org.opencontainers.image.documentation=https://github.com/OpenVK/openvk/blob/master/install/automated/docker/Readme.md
|
||||
tags: |
|
||||
type=sha
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=ref,event=tag
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Log into registry
|
||||
if: github.event_name != 'pull_request'
|
||||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
- name: Log into registry
|
||||
if: github.event_name != 'pull_request'
|
||||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
|
||||
- name: Build base image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/${{matrix.platform}}
|
||||
file: install/automated/docker/openvk.Dockerfile
|
||||
tags: ${{ steps.basemeta.outputs.tags }}
|
||||
labels: ${{ steps.basemeta.outputs.labels }}
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
build-args: |
|
||||
GITREPO=${{ steps.repositorystring.outputs.lowercase }}
|
||||
- name: Build base image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
file: install/automated/docker/openvk.Dockerfile
|
||||
tags: ${{ steps.basemeta.outputs.tags }}
|
||||
labels: ${{ steps.basemeta.outputs.labels }}
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
build-args: |
|
||||
GITREPO=${{ steps.repositorystring.outputs.lowercase }}
|
||||
|
||||
builddb:
|
||||
name: Build DB images
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [amd64, arm64]
|
||||
builddb:
|
||||
name: Build DB images
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
steps:
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
|
||||
- name: Change repository string to lowercase
|
||||
id: repositorystring
|
||||
uses: Entepotenz/change-string-case-action-min-dependencies@v1.1.0
|
||||
with:
|
||||
string: ${{ github.repository }}
|
||||
- name: Change repository string to lowercase
|
||||
id: repositorystring
|
||||
uses: Entepotenz/change-string-case-action-min-dependencies@v1.1.0
|
||||
with:
|
||||
string: ${{ github.repository }}
|
||||
|
||||
- name: MariaDB primary meta
|
||||
id: db-primarymeta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/${{ steps.repositorystring.outputs.lowercase }}/${{env.DB_IMAGE_NAME}}
|
||||
labels: |
|
||||
org.opencontainers.image.title=OpenVK MariaDB (Primary)
|
||||
org.opencontainers.image.description=OpenVK's image for MariaDB for primary database.
|
||||
org.opencontainers.image.documentation=https://github.com/OpenVK/openvk/blob/master/install/automated/docker/Readme.md
|
||||
tags: |
|
||||
type=sha,prefix=${{env.DB_VERSION}}-primary-sha-
|
||||
type=ref,event=branch,prefix=${{env.DB_VERSION}}-primary-
|
||||
type=ref,event=pr,prefix=${{env.DB_VERSION}}-primary-pr-
|
||||
type=ref,event=tag,prefix=${{env.DB_VERSION}}-primary-
|
||||
type=raw,value=${{env.DB_VERSION}}-primary,enable={{is_default_branch}}
|
||||
- name: MariaDB primary meta
|
||||
id: db-primarymeta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/${{ steps.repositorystring.outputs.lowercase }}/${{env.DB_IMAGE_NAME}}
|
||||
labels: |
|
||||
org.opencontainers.image.title=OpenVK MariaDB (Primary)
|
||||
org.opencontainers.image.description=OpenVK's image for MariaDB for primary database.
|
||||
org.opencontainers.image.documentation=https://github.com/OpenVK/openvk/blob/master/install/automated/docker/Readme.md
|
||||
tags: |
|
||||
type=sha,prefix=${{env.DB_VERSION}}-primary-sha-
|
||||
type=ref,event=branch,prefix=${{env.DB_VERSION}}-primary-
|
||||
type=ref,event=pr,prefix=${{env.DB_VERSION}}-primary-pr-
|
||||
type=ref,event=tag,prefix=${{env.DB_VERSION}}-primary-
|
||||
type=raw,value=${{env.DB_VERSION}}-primary,enable={{is_default_branch}}
|
||||
|
||||
- name: MariaDB event meta
|
||||
id: db-eventmeta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/${{ steps.repositorystring.outputs.lowercase }}/${{env.DB_IMAGE_NAME}}
|
||||
labels: |
|
||||
org.opencontainers.image.title=OpenVK MariaDB (EventDB)
|
||||
org.opencontainers.image.description=OpenVK's image for MariaDB for event database.
|
||||
org.opencontainers.image.documentation=https://github.com/OpenVK/openvk/blob/master/install/automated/docker/Readme.md
|
||||
tags: |
|
||||
type=sha,prefix=${{env.DB_VERSION}}-eventdb-sha-
|
||||
type=ref,event=branch,prefix=${{env.DB_VERSION}}-eventdb-
|
||||
type=ref,event=pr,prefix=${{env.DB_VERSION}}-eventdb-pr-
|
||||
type=ref,event=tag,prefix=${{env.DB_VERSION}}-eventdb-
|
||||
type=raw,value=${{env.DB_VERSION}}-eventdb,enable={{is_default_branch}}
|
||||
- name: MariaDB event meta
|
||||
id: db-eventmeta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/${{ steps.repositorystring.outputs.lowercase }}/${{env.DB_IMAGE_NAME}}
|
||||
labels: |
|
||||
org.opencontainers.image.title=OpenVK MariaDB (EventDB)
|
||||
org.opencontainers.image.description=OpenVK's image for MariaDB for event database.
|
||||
org.opencontainers.image.documentation=https://github.com/OpenVK/openvk/blob/master/install/automated/docker/Readme.md
|
||||
tags: |
|
||||
type=sha,prefix=${{env.DB_VERSION}}-eventdb-sha-
|
||||
type=ref,event=branch,prefix=${{env.DB_VERSION}}-eventdb-
|
||||
type=ref,event=pr,prefix=${{env.DB_VERSION}}-eventdb-pr-
|
||||
type=ref,event=tag,prefix=${{env.DB_VERSION}}-eventdb-
|
||||
type=raw,value=${{env.DB_VERSION}}-eventdb,enable={{is_default_branch}}
|
||||
|
||||
- name: Log into registry
|
||||
if: github.event_name != 'pull_request'
|
||||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
- name: Log into registry
|
||||
if: github.event_name != 'pull_request'
|
||||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
|
||||
- name: Build MariaDB primary image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
platforms: linux/${{matrix.platform}}
|
||||
file: install/automated/docker/mariadb-primary.Dockerfile
|
||||
tags: ${{ steps.db-primarymeta.outputs.tags }}
|
||||
labels: ${{ steps.db-primarymeta.outputs.labels }}
|
||||
build-args: |
|
||||
VERSION=${{env.DB_VERSION}}
|
||||
- name: Build MariaDB primary image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
file: install/automated/docker/mariadb-primary.Dockerfile
|
||||
tags: ${{ steps.db-primarymeta.outputs.tags }}
|
||||
labels: ${{ steps.db-primarymeta.outputs.labels }}
|
||||
build-args: |
|
||||
VERSION=${{env.DB_VERSION}}
|
||||
|
||||
- name: Build MariaDB event image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
platforms: linux/${{matrix.platform}}
|
||||
file: install/automated/docker/mariadb-eventdb.Dockerfile
|
||||
tags: ${{ steps.db-eventmeta.outputs.tags }}
|
||||
labels: ${{ steps.db-eventmeta.outputs.labels }}
|
||||
build-args: |
|
||||
VERSION=${{env.DB_VERSION}}
|
||||
- name: Build MariaDB event image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
file: install/automated/docker/mariadb-eventdb.Dockerfile
|
||||
tags: ${{ steps.db-eventmeta.outputs.tags }}
|
||||
labels: ${{ steps.db-eventmeta.outputs.labels }}
|
||||
build-args: |
|
||||
VERSION=${{env.DB_VERSION}}
|
||||
|
|
|
@ -62,9 +62,25 @@ class Clubs
|
|||
$order_str = 'id';
|
||||
|
||||
switch($order['type']) {
|
||||
default:
|
||||
case 'id':
|
||||
$order_str = 'id ' . ($order['invert'] ? 'ASC' : 'DESC');
|
||||
break;
|
||||
case 'subs':
|
||||
$sql_query = <<<EOF
|
||||
SELECT `groups`.`id`, `subs`
|
||||
FROM `groups`
|
||||
LEFT JOIN
|
||||
(SELECT `target`, COUNT(`follower`) as `subs`
|
||||
FROM `subscriptions`
|
||||
WHERE `model` = "openvk\\\\Web\\\\Models\\\\Entities\\\\Club"
|
||||
GROUP BY `target`) `subscriptions` ON `subscriptions`.`target` = `groups`.`id`
|
||||
WHERE `groups`.`name` LIKE ? OR `groups`.`about` LIKE ?
|
||||
ORDER BY `subs` DESC
|
||||
LIMIT ? OFFSET ?;
|
||||
EOF;
|
||||
|
||||
return new Util\RawEntityStream("Club", $sql_query, $query, $query);
|
||||
}
|
||||
|
||||
$result = $result->where("name LIKE ? OR about LIKE ?", $query, $query);
|
||||
|
|
|
@ -27,7 +27,7 @@ class EntityStream implements \IteratorAggregate
|
|||
return new $this->entityClass($result);
|
||||
}
|
||||
|
||||
private function stream(\Traversable $iterator): \Traversable
|
||||
protected function stream(\Traversable $iterator): \Traversable
|
||||
{
|
||||
foreach($iterator as $result)
|
||||
yield $this->getEntity($result);
|
||||
|
|
50
Web/Models/Repositories/Util/RawEntityStream.php
Normal file
50
Web/Models/Repositories/Util/RawEntityStream.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php declare(strict_types=1);
|
||||
namespace openvk\Web\Models\Repositories\Util;
|
||||
use Nette\Database\Row;
|
||||
|
||||
class RawEntityStream extends EntityStream
|
||||
{
|
||||
function __construct(string $repo, string $sql, ...$db_params)
|
||||
{
|
||||
$this->sqlQuery = $sql;
|
||||
$this->entityRepo = new ($class[0] === "\\" ? $repo : "openvk\\Web\\Models\\Repositories\\$repo"."s");
|
||||
$this->dbParams = $db_params;
|
||||
}
|
||||
|
||||
private function dbs(int $page = 0, ?int $perPage = NULL): \Traversable
|
||||
{
|
||||
if(!$this->dbQuery) {
|
||||
$this->dbParams[] = $perPage;
|
||||
$this->dbParams[] = (($page - 1) * $perPage);
|
||||
|
||||
$this->dbQuery = \Chandler\Database\DatabaseConnection::i()->getConnection()->query($this->sqlQuery, ...$this->dbParams);
|
||||
}
|
||||
|
||||
return $this->dbQuery;
|
||||
}
|
||||
|
||||
private function getEntity(Row $result)
|
||||
{
|
||||
$repo = new $this->entityRepo;
|
||||
return $repo->get($result->id);
|
||||
}
|
||||
|
||||
protected function stream(\Traversable $iterator): \Traversable
|
||||
{
|
||||
foreach($iterator as $result)
|
||||
yield $this->getEntity($result);
|
||||
}
|
||||
|
||||
function page(int $page, ?int $perPage = NULL): \Traversable
|
||||
{
|
||||
$fetchedRows = $this->dbs($page, $perPage);
|
||||
|
||||
return $this->stream($fetchedRows);
|
||||
}
|
||||
|
||||
function size(): int
|
||||
{
|
||||
bdump($this->dbs()->getRowCount());
|
||||
return $this->dbs()->getRowCount();
|
||||
}
|
||||
}
|
|
@ -232,7 +232,7 @@
|
|||
|
||||
sendMessage(content) {
|
||||
console.debug("New outcoming message. Pushing preview to local stack.");
|
||||
let tempId = this.newMessage(content);
|
||||
let tempId = this.newMessage(escapeHtml(content));
|
||||
|
||||
let msgData = new FormData();
|
||||
msgData.set("content", content);
|
||||
|
|
|
@ -343,6 +343,9 @@
|
|||
{if OPENVK_ROOT_CONF["openvk"]["preferences"]["commerce"]}
|
||||
<option value="rating" n:attr="selected => $order == 'rating'">{_s_order_by_rating}</option>
|
||||
{/if}
|
||||
{elseif $section == "groups"}
|
||||
<option value="id" n:attr="selected => $order == 'id'">{_s_order_by_creation_date}</option>
|
||||
<option value="subs" n:attr="selected => $order == 'subs'">{_s_order_by_subs}</option>
|
||||
{elseif $section == "posts"}
|
||||
<option value="id" n:attr="selected => $order == 'id'">{_s_order_by_publishing_date}</option>
|
||||
{elseif $section == "audios"}
|
||||
|
@ -357,7 +360,7 @@
|
|||
{/if}
|
||||
</select>
|
||||
|
||||
<label n:if="$order != 'rating'">
|
||||
<label n:if="$order != 'rating' && $order != 'subs'">
|
||||
<input type="checkbox" name="invert" value="1" form="search_form" n:attr="checked => $_REQUEST['invert'] == '1'">
|
||||
{_s_order_invert}
|
||||
</label>
|
||||
|
|
|
@ -2141,6 +2141,7 @@
|
|||
"s_order_by_creation_date" = "By creation date";
|
||||
"s_order_by_publishing_date" = "By publication date";
|
||||
"s_order_by_upload_date" = "By upload date";
|
||||
"s_order_by_subs" = "By followers";
|
||||
|
||||
"s_by_date" = "By date";
|
||||
"s_registered_before" = "Registered before";
|
||||
|
|
|
@ -2036,6 +2036,7 @@
|
|||
"s_order_by_creation_date" = "По дате создания";
|
||||
"s_order_by_publishing_date" = "По дате публикации";
|
||||
"s_order_by_upload_date" = "По дате загрузки";
|
||||
"s_order_by_subs" = "По подписчикам";
|
||||
|
||||
"s_by_date" = "По дате";
|
||||
"s_registered_before" = "Зарегистрирован до";
|
||||
|
|
Loading…
Reference in a new issue