mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add IV footer.
This commit is contained in:
parent
a272807a99
commit
7addcf2d25
8 changed files with 93 additions and 20 deletions
|
@ -134,9 +134,32 @@ html.custom_scroll ::-webkit-scrollbar-thumb:hover {
|
||||||
.page-slide {
|
.page-slide {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
margin-left: 0%;
|
margin-left: 0%;
|
||||||
transition: margin 240ms ease-in-out;
|
transition: margin 240ms ease-in-out;
|
||||||
}
|
}
|
||||||
|
.page-footer {
|
||||||
|
height: 32px;
|
||||||
|
margin-top: -32px;
|
||||||
|
background: var(--td-window-bg-over);
|
||||||
|
}
|
||||||
|
.page-footer .content {
|
||||||
|
padding: 3px 18px;
|
||||||
|
font-size: 15px;
|
||||||
|
color: var(--td-window-sub-text-fg);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.page-footer .wrong {
|
||||||
|
position: relative;
|
||||||
|
padding: 5px;
|
||||||
|
margin: -5px;
|
||||||
|
color: var(--td-window-sub-text-fg);
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.page-footer .wrong:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
.hidden-left,
|
.hidden-left,
|
||||||
.hidden-right {
|
.hidden-right {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
@ -148,7 +171,7 @@ html.custom_scroll ::-webkit-scrollbar-thumb:hover {
|
||||||
margin-left: 100%;
|
margin-left: 100%;
|
||||||
}
|
}
|
||||||
article {
|
article {
|
||||||
padding-bottom: 12px;
|
padding-bottom: 40px;
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
|
@ -893,6 +916,9 @@ section.related a.related-link:after {
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
}
|
}
|
||||||
|
section.related a.related-link:last-child:after {
|
||||||
|
border-bottom: 0px;
|
||||||
|
}
|
||||||
section.related .related-link-url {
|
section.related .related-link-url {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
|
|
@ -26,7 +26,7 @@ var IV = {
|
||||||
}
|
}
|
||||||
target = target.parentNode;
|
target = target.parentNode;
|
||||||
}
|
}
|
||||||
if (!target || !target.hasAttribute('href')) {
|
if (!target || (context === '' && !target.hasAttribute('href'))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var base = document.createElement('A');
|
var base = document.createElement('A');
|
||||||
|
@ -413,9 +413,12 @@ var IV = {
|
||||||
var article = function (el) {
|
var article = function (el) {
|
||||||
return el.getElementsByTagName('article')[0];
|
return el.getElementsByTagName('article')[0];
|
||||||
};
|
};
|
||||||
var from = article(IV.findPageScroll());
|
var footer = function (el) {
|
||||||
var to = article(IV.makeScrolledContent(data.html));
|
return el.getElementsByClassName('page-footer')[0];
|
||||||
morphdom(from, to, {
|
};
|
||||||
|
var from = IV.findPageScroll();
|
||||||
|
var to = IV.makeScrolledContent(data.html);
|
||||||
|
morphdom(article(from), article(to), {
|
||||||
onBeforeElUpdated: function (fromEl, toEl) {
|
onBeforeElUpdated: function (fromEl, toEl) {
|
||||||
if (fromEl.classList.contains('video')
|
if (fromEl.classList.contains('video')
|
||||||
&& toEl.classList.contains('video')
|
&& toEl.classList.contains('video')
|
||||||
|
@ -439,6 +442,7 @@ var IV = {
|
||||||
return !fromEl.isEqualNode(toEl);
|
return !fromEl.isEqualNode(toEl);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
morphdom(footer(from), footer(to));
|
||||||
IV.initMedia();
|
IV.initMedia();
|
||||||
eval(data.js);
|
eval(data.js);
|
||||||
},
|
},
|
||||||
|
@ -477,9 +481,7 @@ var IV = {
|
||||||
var result = document.createElement('div');
|
var result = document.createElement('div');
|
||||||
result.className = 'page-scroll';
|
result.className = 'page-scroll';
|
||||||
result.tabIndex = '-1';
|
result.tabIndex = '-1';
|
||||||
result.innerHTML = '<div class="page-slide"><article>'
|
result.innerHTML = html.trim();
|
||||||
+ html
|
|
||||||
+ '</article></div>';
|
|
||||||
result.onscroll = IV.frameScrolled;
|
result.onscroll = IV.frameScrolled;
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
|
@ -5111,6 +5111,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_iv_share" = "Share";
|
"lng_iv_share" = "Share";
|
||||||
"lng_iv_join_channel" = "Join";
|
"lng_iv_join_channel" = "Join";
|
||||||
"lng_iv_window_title" = "Instant View";
|
"lng_iv_window_title" = "Instant View";
|
||||||
|
"lng_iv_wrong_layout" = "Wrong layout?";
|
||||||
|
|
||||||
"lng_limit_download_title" = "Download speed limited";
|
"lng_limit_download_title" = "Download speed limited";
|
||||||
"lng_limit_download_subscribe" = "Subscribe to {link} and increase download speed {increase}.";
|
"lng_limit_download_subscribe" = "Subscribe to {link} and increase download speed {increase}.";
|
||||||
|
|
|
@ -155,10 +155,6 @@ namespace {
|
||||||
+ "IV.init();"
|
+ "IV.init();"
|
||||||
+ page.script;
|
+ page.script;
|
||||||
|
|
||||||
const auto contentAttributes = page.rtl
|
|
||||||
? " dir=\"rtl\" class=\"rtl\""_q
|
|
||||||
: QByteArray();
|
|
||||||
|
|
||||||
return R"(<!DOCTYPE html>
|
return R"(<!DOCTYPE html>
|
||||||
<html)"_q
|
<html)"_q
|
||||||
+ classAttribute
|
+ classAttribute
|
||||||
|
@ -179,9 +175,7 @@ namespace {
|
||||||
<path d="M14.9972363,18 L9.13865768,12.1414214 C9.06055283,12.0633165 9.06055283,11.9366835 9.13865768,11.8585786 L14.9972363,6 L14.9972363,6" transform="translate(11.997236, 12.000000) scale(-1, -1) rotate(-90.000000) translate(-11.997236, -12.000000) "></path>
|
<path d="M14.9972363,18 L9.13865768,12.1414214 C9.06055283,12.0633165 9.06055283,11.9366835 9.13865768,11.8585786 L14.9972363,6 L14.9972363,6" transform="translate(11.997236, 12.000000) scale(-1, -1) rotate(-90.000000) translate(-11.997236, -12.000000) "></path>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
<div class="page-scroll" tabindex="-1"><div class="page-slide">
|
<div class="page-scroll" tabindex="-1">)"_q + page.content.trimmed() + R"(</div>
|
||||||
<article)"_q + contentAttributes + ">"_q + page.content + R"(</article>
|
|
||||||
</div></div>
|
|
||||||
<script>)"_q + js + R"(</script>
|
<script>)"_q + js + R"(</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -646,7 +640,12 @@ void Controller::processLink(const QString &url, const QString &context) {
|
||||||
const auto joinPrefix = u"join_link"_q;
|
const auto joinPrefix = u"join_link"_q;
|
||||||
const auto webpagePrefix = u"webpage"_q;
|
const auto webpagePrefix = u"webpage"_q;
|
||||||
const auto viewerPrefix = u"viewer"_q;
|
const auto viewerPrefix = u"viewer"_q;
|
||||||
if (context.startsWith(channelPrefix)) {
|
if (context == u"report-iv") {
|
||||||
|
_events.fire({
|
||||||
|
.type = Event::Type::Report,
|
||||||
|
.context = QString::number(compuseCurrentPageId()),
|
||||||
|
});
|
||||||
|
} else if (context.startsWith(channelPrefix)) {
|
||||||
_events.fire({
|
_events.fire({
|
||||||
.type = Event::Type::OpenChannel,
|
.type = Event::Type::OpenChannel,
|
||||||
.context = context.mid(channelPrefix.size()),
|
.context = context.mid(channelPrefix.size()),
|
||||||
|
@ -701,6 +700,13 @@ QString Controller::composeCurrentUrl() const {
|
||||||
+ (_hash.isEmpty() ? u""_q : ('#' + _hash));
|
+ (_hash.isEmpty() ? u""_q : ('#' + _hash));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64 Controller::compuseCurrentPageId() const {
|
||||||
|
const auto index = _index.current();
|
||||||
|
Assert(index >= 0 && index < _pages.size());
|
||||||
|
|
||||||
|
return _pages[index].pageId;
|
||||||
|
}
|
||||||
|
|
||||||
void Controller::showMenu() {
|
void Controller::showMenu() {
|
||||||
const auto index = _index.current();
|
const auto index = _index.current();
|
||||||
if (_menu || index < 0 || index > _pages.size()) {
|
if (_menu || index < 0 || index > _pages.size()) {
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
OpenLink,
|
OpenLink,
|
||||||
OpenLinkExternal,
|
OpenLinkExternal,
|
||||||
OpenMedia,
|
OpenMedia,
|
||||||
|
Report,
|
||||||
};
|
};
|
||||||
Type type = Type::Close;
|
Type type = Type::Close;
|
||||||
QString url;
|
QString url;
|
||||||
|
@ -116,6 +117,7 @@ private:
|
||||||
void quit();
|
void quit();
|
||||||
|
|
||||||
[[nodiscard]] QString composeCurrentUrl() const;
|
[[nodiscard]] QString composeCurrentUrl() const;
|
||||||
|
[[nodiscard]] uint64 compuseCurrentPageId() const;
|
||||||
void showShareMenu();
|
void showShareMenu();
|
||||||
void destroyShareMenu();
|
void destroyShareMenu();
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ struct Options {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Prepared {
|
struct Prepared {
|
||||||
|
uint64 pageId = 0;
|
||||||
QString name;
|
QString name;
|
||||||
QByteArray content;
|
QByteArray content;
|
||||||
QByteArray script;
|
QByteArray script;
|
||||||
|
|
|
@ -742,9 +742,7 @@ void Instance::show(
|
||||||
not_null<Data*> data,
|
not_null<Data*> data,
|
||||||
QString hash) {
|
QString hash) {
|
||||||
const auto guard = gsl::finally([&] {
|
const auto guard = gsl::finally([&] {
|
||||||
if (data->partial()) {
|
requestFull(session, data->id());
|
||||||
requestFull(session, data->id());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
if (_shown && _shownSession == session) {
|
if (_shown && _shownSession == session) {
|
||||||
_shown->moveTo(data, hash);
|
_shown->moveTo(data, hash);
|
||||||
|
@ -834,6 +832,17 @@ void Instance::show(
|
||||||
UrlClickHandler::Open(event.url);
|
UrlClickHandler::Open(event.url);
|
||||||
}).send();
|
}).send();
|
||||||
break;
|
break;
|
||||||
|
case Type::Report:
|
||||||
|
if (const auto controller = _shownSession->tryResolveWindow()) {
|
||||||
|
controller->window().activate();
|
||||||
|
controller->showPeerByLink(Window::PeerByLinkInfo{
|
||||||
|
.usernameOrId = "previews",
|
||||||
|
.resolveType = Window::ResolveType::BotStart,
|
||||||
|
.startToken = ("webpage"
|
||||||
|
+ QString::number(event.context.toULongLong())),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}, _shown->lifetime());
|
}, _shown->lifetime());
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,8 @@ private:
|
||||||
[[nodiscard]] QByteArray block(
|
[[nodiscard]] QByteArray block(
|
||||||
const MTPDpageListOrderedItemBlocks &data);
|
const MTPDpageListOrderedItemBlocks &data);
|
||||||
|
|
||||||
|
[[nodiscard]] QByteArray wrap(const QByteArray &content, int views);
|
||||||
|
|
||||||
[[nodiscard]] QByteArray tag(
|
[[nodiscard]] QByteArray tag(
|
||||||
const QByteArray &name,
|
const QByteArray &name,
|
||||||
const QByteArray &body = {});
|
const QByteArray &body = {});
|
||||||
|
@ -223,9 +225,13 @@ Parser::Parser(const Source &source, const Options &options)
|
||||||
: /*_options(options)
|
: /*_options(options)
|
||||||
, */_fileOriginPostfix('/' + Number(source.pageId)) {
|
, */_fileOriginPostfix('/' + Number(source.pageId)) {
|
||||||
process(source);
|
process(source);
|
||||||
|
_result.pageId = source.pageId;
|
||||||
_result.name = source.name;
|
_result.name = source.name;
|
||||||
_result.rtl = source.page.data().is_rtl();
|
_result.rtl = source.page.data().is_rtl();
|
||||||
_result.content = list(source.page.data().vblocks());
|
|
||||||
|
const auto views = source.page.data().vviews().value_or_empty();
|
||||||
|
const auto content = list(source.page.data().vblocks());
|
||||||
|
_result.content = wrap(content, views);
|
||||||
}
|
}
|
||||||
|
|
||||||
Prepared Parser::result() {
|
Prepared Parser::result() {
|
||||||
|
@ -925,6 +931,26 @@ QByteArray Parser::utf(const tl::conditional<MTPstring> &text) {
|
||||||
return text ? utf(*text) : QByteArray();
|
return text ? utf(*text) : QByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray Parser::wrap(const QByteArray &content, int views) {
|
||||||
|
const auto sep = " \xE2\x80\xA2 ";
|
||||||
|
const auto viewsText = views
|
||||||
|
? (tr::lng_stories_views(tr::now, lt_count_decimal, views) + sep)
|
||||||
|
: QString();
|
||||||
|
return R"(
|
||||||
|
<div class="page-slide">
|
||||||
|
<article>)"_q + content + R"(</article>
|
||||||
|
</div>
|
||||||
|
<div class="page-footer">
|
||||||
|
<div class="content">
|
||||||
|
)"_q
|
||||||
|
+ viewsText.toUtf8()
|
||||||
|
+ R"(<a class="wrong" data-context="report-iv">)"_q
|
||||||
|
+ tr::lng_iv_wrong_layout(tr::now).toUtf8()
|
||||||
|
+ R"(</a>
|
||||||
|
</div>
|
||||||
|
</div>)"_q;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray Parser::tag(
|
QByteArray Parser::tag(
|
||||||
const QByteArray &name,
|
const QByteArray &name,
|
||||||
const QByteArray &body) {
|
const QByteArray &body) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue