比较提交
6 次代码提交
dab0b94ec4
...
master
作者 | SHA1 | 提交日期 | |
---|---|---|---|
22e3941f2c | |||
168d24c545 | |||
d1358f7e77 | |||
79d69f4b65 | |||
bfeacb0510 | |||
c6013338a9 |
50
cache/mapcache.h
vendored
50
cache/mapcache.h
vendored
@ -5,12 +5,13 @@
|
|||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "icache.h"
|
||||||
|
|
||||||
/* Thread-Safe Key-Value store */
|
/* Thread-Safe Key-Value store */
|
||||||
template <class T> class MapCache
|
template <class T> class MapCache
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::map<std::string, T> cache;
|
std::unordered_map<std::string, T> cache;
|
||||||
mutable std::shared_mutex sharedMutex;
|
mutable std::shared_mutex sharedMutex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -34,6 +35,53 @@ template <class T> class MapCache
|
|||||||
std::lock_guard<std::shared_mutex> lock{sharedMutex};
|
std::lock_guard<std::shared_mutex> lock{sharedMutex};
|
||||||
this->cache.clear();
|
this->cache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void remove(const std::string &key)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::shared_mutex> lock{sharedMutex};
|
||||||
|
this->cache.erase(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
void removePrefix(const std::string &key)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::shared_mutex> lock{sharedMutex};
|
||||||
|
std::erase_if(this->cache, [key](const auto &item)
|
||||||
|
{
|
||||||
|
auto const& [k, v] = item;
|
||||||
|
return k.starts_with(std::string_view(key));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class StringCache : public MapCache<std::string>, public ICache
|
||||||
|
{
|
||||||
|
virtual std::optional<std::string> get(std::string_view key) const override
|
||||||
|
{
|
||||||
|
return MapCache<std::string>::find(std::string(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void put(std::string_view key, std::string val) override
|
||||||
|
{
|
||||||
|
MapCache<std::string>::set(std::string(key), val);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void remove(std::string_view key) override
|
||||||
|
{
|
||||||
|
MapCache<std::string>::remove(std::string(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void removePrefix(std::string_view prefix)
|
||||||
|
{
|
||||||
|
MapCache<std::string>::removePrefix(std::string(prefix));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void clear() override
|
||||||
|
{
|
||||||
|
MapCache<std::string>::clear();
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAPCACHE_H
|
#endif // MAPCACHE_H
|
||||||
|
@ -89,7 +89,6 @@ std::string HandlerFeedGenerator::generateAtom(const std::vector<HandlerFeedGene
|
|||||||
newestPublished = initialRevision.timestamp;
|
newestPublished = initialRevision.timestamp;
|
||||||
}
|
}
|
||||||
std::string entryPublished = utils::formatLocalDate(initialRevision.timestamp, dateformat) + "Z";
|
std::string entryPublished = utils::formatLocalDate(initialRevision.timestamp, dateformat) + "Z";
|
||||||
std::string entryUpdated = utils::formatLocalDate(current.timestamp, dateformat) + "Z";
|
|
||||||
std::string entryurl =
|
std::string entryurl =
|
||||||
this->urlProvider->combine({this->urlProvider->rootUrl(), this->urlProvider->page(page.name)});
|
this->urlProvider->combine({this->urlProvider->rootUrl(), this->urlProvider->page(page.name)});
|
||||||
TemplatePage atomentry = this->templ->getPage("feeds/atomentry");
|
TemplatePage atomentry = this->templ->getPage("feeds/atomentry");
|
||||||
@ -97,7 +96,7 @@ std::string HandlerFeedGenerator::generateAtom(const std::vector<HandlerFeedGene
|
|||||||
atomentry.setVar("entryurl", utils::html_xss(entryurl));
|
atomentry.setVar("entryurl", utils::html_xss(entryurl));
|
||||||
atomentry.setVar("entryid", utils::html_xss(entryurl));
|
atomentry.setVar("entryid", utils::html_xss(entryurl));
|
||||||
atomentry.setVar("entrypublished", entryPublished);
|
atomentry.setVar("entrypublished", entryPublished);
|
||||||
atomentry.setVar("entryupdated", entryUpdated);
|
atomentry.setVar("entryupdated", entryPublished);
|
||||||
atomentry.setVar("entrycontent", utils::html_xss(revisionRenderer.renderContent(current, page.title)));
|
atomentry.setVar("entrycontent", utils::html_xss(revisionRenderer.renderContent(current, page.title)));
|
||||||
stream << atomentry.render();
|
stream << atomentry.render();
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ std::string HandlerPageView::createIndexContent(IParser &parser, std::string con
|
|||||||
}
|
}
|
||||||
previous = h.level;
|
previous = h.level;
|
||||||
HtmlLink link;
|
HtmlLink link;
|
||||||
link.href = "#" + h.title;
|
link.href = "#" + utils::strreplace(h.title, " ", "");
|
||||||
link.innervalue = h.title;
|
link.innervalue = h.title;
|
||||||
link.cssclass = "indexlink";
|
link.cssclass = "indexlink";
|
||||||
indexcontent += "<li>" + link.render() + "</li>";
|
indexcontent += "<li>" + link.render() + "</li>";
|
||||||
|
@ -191,6 +191,10 @@ std::string Parser::parse(const PageDao &pagedao, UrlProvider &provider, const s
|
|||||||
{
|
{
|
||||||
newlines = "<br>";
|
newlines = "<br>";
|
||||||
}
|
}
|
||||||
|
if(tag == "br")
|
||||||
|
{
|
||||||
|
return std::string("<br>");
|
||||||
|
}
|
||||||
if(tag != "code" && tag != "blockquote")
|
if(tag != "code" && tag != "blockquote")
|
||||||
{
|
{
|
||||||
content = parse(pagedao, provider, content, callback);
|
content = parse(pagedao, provider, content, callback);
|
||||||
@ -220,7 +224,7 @@ std::string Parser::parse(const PageDao &pagedao, UrlProvider &provider, const s
|
|||||||
}
|
}
|
||||||
if(tag[0] == 'h')
|
if(tag[0] == 'h')
|
||||||
{
|
{
|
||||||
return "<" + tag + " id='" + content + "'>" + content + "</" + tag + ">";
|
return "<" + tag + " id='" + utils::strreplace(content, " ", "") + "'>" + content + "</" + tag + ">";
|
||||||
}
|
}
|
||||||
if(tag == "code" || tag == "blockquote")
|
if(tag == "code" || tag == "blockquote")
|
||||||
{
|
{
|
||||||
|
@ -72,7 +72,7 @@ std::unique_ptr<ICache> createCache(const ConfigVariableResolver &resolver)
|
|||||||
std::string path = resolver.getConfig("cache_fs_dir");
|
std::string path = resolver.getConfig("cache_fs_dir");
|
||||||
if(path == "")
|
if(path == "")
|
||||||
{
|
{
|
||||||
return std::make_unique<NoCache>(path);
|
return std::make_unique<StringCache>();
|
||||||
}
|
}
|
||||||
return std::make_unique<FsCache>(path);
|
return std::make_unique<FsCache>(path);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,11 @@ bool SandboxLinux::enable(std::vector<std::string> fsPaths)
|
|||||||
}
|
}
|
||||||
for(unsigned int i = 0; i < fsPaths.size(); i++)
|
for(unsigned int i = 0; i < fsPaths.size(); i++)
|
||||||
{
|
{
|
||||||
exile_append_path_policies(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_ALL_WRITE, fsPaths[i].c_str());
|
std::string &path = fsPaths[i];
|
||||||
|
if(path.size() > 0)
|
||||||
|
{
|
||||||
|
exile_append_path_policies(policy, EXILE_FS_ALLOW_ALL_READ | EXILE_FS_ALLOW_ALL_WRITE, path.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
policy->drop_caps = 1;
|
policy->drop_caps = 1;
|
||||||
policy->not_dumpable = 1;
|
policy->not_dumpable = 1;
|
||||||
|
在新工单中引用
屏蔽一个用户