mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
Add knowledgebase
This commit is contained in:
parent
112bf4b8d4
commit
93909c7444
13 changed files with 163 additions and 8 deletions
|
@ -22,7 +22,7 @@ final class AboutPresenter extends OpenVKPresenter
|
|||
|
||||
function renderRules(): void
|
||||
{
|
||||
$this->template->rules = file_get_contents(__DIR__ . "/../../data/rules.xhtml");
|
||||
$this->pass("openvk!Support->knowledgeBaseArticle", "rules");
|
||||
}
|
||||
|
||||
function renderHelp(): void
|
||||
|
@ -38,7 +38,9 @@ final class AboutPresenter extends OpenVKPresenter
|
|||
{}
|
||||
|
||||
function renderPrivacy(): void
|
||||
{}
|
||||
{
|
||||
$this->pass("openvk!Support->knowledgeBaseArticle", "privacy");
|
||||
}
|
||||
|
||||
function renderVersion(): void
|
||||
{
|
||||
|
|
|
@ -9,8 +9,8 @@ use openvk\Web\Models\Repositories\TicketComments;
|
|||
use openvk\Web\Models\RowModel;
|
||||
use Nette\Database\Table\ActiveRow;
|
||||
use Chandler\Database\DatabaseConnection;
|
||||
use Composer\Factory;
|
||||
use Composer\IO\NullIO;
|
||||
use Chandler\Session\Session;
|
||||
use Netcarver\Textile;
|
||||
|
||||
final class SupportPresenter extends OpenVKPresenter
|
||||
{
|
||||
|
@ -188,4 +188,30 @@ final class SupportPresenter extends OpenVKPresenter
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
function renderKnowledgeBaseArticle(string $name): void
|
||||
{
|
||||
$lang = Session::i()->get("lang", "ru");
|
||||
$base = OPENVK_ROOT . "/data/knowledgebase";
|
||||
if(file_exists("$base/$name.$lang.textile"))
|
||||
$file = "$base/$name.$lang.textile";
|
||||
else if(file_exists("$base/$name.textile"))
|
||||
$file = "$base/$name.textile";
|
||||
else
|
||||
$this->notFound();
|
||||
|
||||
$lines = file($file);
|
||||
if(!preg_match("%^OpenVK-KB-Heading: (.+)$%", $lines[0], $matches)) {
|
||||
$heading = "Article $name";
|
||||
} else {
|
||||
$heading = $matches[1];
|
||||
array_shift($lines);
|
||||
}
|
||||
|
||||
$content = implode("\r\n", $lines);
|
||||
|
||||
$parser = new Textile\Parser;
|
||||
$this->template->heading = $heading;
|
||||
$this->template->content = $parser->parse($content);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<textarea name="html" style="display:none;"></textarea>
|
||||
<div id="editor" style="width:600px;height:300px;border:1px solid grey"></div>
|
||||
|
||||
<p><i><a href="/wall-21_1">Кое-что</a> из (X)HTML поддерживается.</i></p>
|
||||
<p><i><a href="/kb/notes">Кое-что</a> из (X)HTML поддерживается.</i></p>
|
||||
|
||||
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||
<button class="button">{_save}</button>
|
||||
|
|
11
Web/Presenters/templates/Support/KnowledgeBaseArticle.xml
Normal file
11
Web/Presenters/templates/Support/KnowledgeBaseArticle.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
{extends "../@layout.xml"}
|
||||
|
||||
{block title}{$heading}{/block}
|
||||
|
||||
{block header}
|
||||
{$heading}
|
||||
{/block}
|
||||
|
||||
{block content}
|
||||
{$content|noescape}
|
||||
{/block}
|
|
@ -25,6 +25,8 @@ routes:
|
|||
handler: "About->language"
|
||||
- url: "/donate"
|
||||
handler: "About->donate"
|
||||
- url: "/kb/{slug}"
|
||||
handler: "Support->knowledgeBaseArticle"
|
||||
- url: "/about:{?!productName}"
|
||||
handler: "About->version"
|
||||
placeholders:
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
"james-heinrich/getid3": "^1.9@dev",
|
||||
"rybakit/msgpack": "dev-master",
|
||||
"wapmorgan-alter/cab-archive": "0.0.7.1",
|
||||
"wapmorgan/binary-stream": "dev-master"
|
||||
"wapmorgan/binary-stream": "dev-master",
|
||||
"netcarver/textile": "^3.7@dev"
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
|
|
58
composer.lock
generated
58
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "61c3f4330692983a999c84dee65684a2",
|
||||
"content-hash": "cd5b144aeb47f3c9f8b3d4cf09cfad22",
|
||||
"packages": [
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
|
@ -304,6 +304,59 @@
|
|||
],
|
||||
"time": "2019-04-20T16:06:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "netcarver/textile",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/textile/php-textile.git",
|
||||
"reference": "1651585b54bfaa8def9aff28c1b08437475791a9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/textile/php-textile/zipball/1651585b54bfaa8def9aff28c1b08437475791a9",
|
||||
"reference": "1651585b54bfaa8def9aff28c1b08437475791a9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-coveralls/php-coveralls": "2.1.*",
|
||||
"phpunit/phpunit": "5.7.*",
|
||||
"squizlabs/php_codesniffer": "3.*",
|
||||
"symfony/yaml": "2.4.*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Netcarver\\Textile\\": "src/Netcarver/Textile/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"description": "Textile markup language parser",
|
||||
"homepage": "https://github.com/textile/php-textile",
|
||||
"keywords": [
|
||||
"document",
|
||||
"format",
|
||||
"html",
|
||||
"language",
|
||||
"markup",
|
||||
"parser",
|
||||
"php-textile",
|
||||
"plaintext",
|
||||
"textile"
|
||||
],
|
||||
"time": "2020-01-08T21:17:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "p3k/emoji-detector",
|
||||
"version": "0.2.1",
|
||||
|
@ -696,7 +749,8 @@
|
|||
"zadarma/user-api-v1": 20,
|
||||
"james-heinrich/getid3": 20,
|
||||
"rybakit/msgpack": 20,
|
||||
"wapmorgan/binary-stream": 20
|
||||
"wapmorgan/binary-stream": 20,
|
||||
"netcarver/textile": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
|
|
23
data/knowledgebase/notes.ru.textile
Normal file
23
data/knowledgebase/notes.ru.textile
Normal file
|
@ -0,0 +1,23 @@
|
|||
OpenVK-KB-Heading: Справка по редактированию заметок
|
||||
|
||||
Вики-разметка OpenVK это тоже самое, что и XHTML1.0 Transitional. Единственное изменение заключается в том, что мы убрали некоторые теги, которые могут принести вред OpenVK или не нужны.
|
||||
Список разрешённых тегов:
|
||||
* Все заголовки 3-6 уровней (h3-h6)
|
||||
* Параграфы (<p>)
|
||||
* Форматирование текста (<i>, <b>, <del>)
|
||||
* <sup>, <sub>, <ins>
|
||||
* Таблицы и всё, что с ними связано
|
||||
* Изображения и ссылки (<a>, <img>)
|
||||
* Списки (и <ol> и <ul>)
|
||||
* Перевод строки и горизонтальная линия (hr)
|
||||
* Цитаты (<blockquote> и <cite>)
|
||||
* <acronym>
|
||||
Обратите внимание, источником изображения могут быть только файлы из OpenVK. Это ограничение не распространяется на ссылки, где href может быть любой (в целях безопасности наших пользователей, ссылка будет автоматически заменена на редирект через away.php)
|
||||
Вы могли заметить, что в списке разрешённых тегов нету <style>, но ничего страшного, вы можете применять аттрибут style к тегам <div> и <img>. В перечень поддерживаемых свойств CSS входят:
|
||||
* float
|
||||
* height
|
||||
* width
|
||||
* max-height
|
||||
* max-width
|
||||
* font-weight
|
||||
Обратите внимание на то, что поддерживаются только значения в пикселях.
|
24
data/knowledgebase/notes.textile
Normal file
24
data/knowledgebase/notes.textile
Normal file
|
@ -0,0 +1,24 @@
|
|||
OpenVK-KB-Heading: Editing notes
|
||||
|
||||
OpenVK wiki-markup is basically XHTML1.0 Transitional. The only difference is that we removed tags that are not needed or may harm OpenVK and it's users.
|
||||
Allowed tags:
|
||||
* All headers from level 3 to 6 (h3-h6)
|
||||
* Paragraphs (<p>)
|
||||
* Text formatting (<i>, <b>, <del>)
|
||||
* <sup>, <sub>, <ins>
|
||||
* Everything related to tables
|
||||
* Links and images (<a>, <img>)
|
||||
* Lists (и <ol> и <ul>)
|
||||
* Line feed and horizontal rule (hr)
|
||||
* Blockquotes (<blockquote> и <cite>)
|
||||
* <acronym>
|
||||
|
||||
*Please note*: images can't have sourcemap and their source must be a file that is hosted on this OpenVK instance. This restrictions does not apply to links. Links can link to everything (except for data: and javascript: pseudoprotocols). They will be derefered though.
|
||||
You may also have noticed, that <style> is note in the allowlist, however, we do support styling <div> and <img> tags using style attribute. This CSS properties are allowed:
|
||||
* float
|
||||
* height
|
||||
* width
|
||||
* max-height
|
||||
* max-width
|
||||
* font-weight
|
||||
If property is a size property it can only accept pixels as value (no %, pt, pc, em, rem, vw or vh).
|
3
data/knowledgebase/privacy.ru.textile
Normal file
3
data/knowledgebase/privacy.ru.textile
Normal file
|
@ -0,0 +1,3 @@
|
|||
OpenVK-KB-Heading: Политика Конфиденциальности
|
||||
|
||||
Пример политики конфиденциальности
|
3
data/knowledgebase/privacy.textile
Normal file
3
data/knowledgebase/privacy.textile
Normal file
|
@ -0,0 +1,3 @@
|
|||
OpenVK-KB-Heading: Privacy Policy
|
||||
|
||||
Example pricacy policy
|
3
data/knowledgebase/rules.ru.textile
Normal file
3
data/knowledgebase/rules.ru.textile
Normal file
|
@ -0,0 +1,3 @@
|
|||
OpenVK-KB-Heading: Правила
|
||||
|
||||
Пример правил
|
3
data/knowledgebase/rules.textile
Normal file
3
data/knowledgebase/rules.textile
Normal file
|
@ -0,0 +1,3 @@
|
|||
OpenVK-KB-Heading: Rules
|
||||
|
||||
Sample rules
|
Loading…
Reference in a new issue