feature/markdown #23

Avoinna
crtxcr haluaa yhdistää 9 committia lähteestä feature/markdown kohteeseen master
5 muutettua tiedostoa jossa 15 lisäystä ja 15 poistoa
Showing only changes of commit cec56d5a73 - Show all commits

Näytä tiedosto

@ -21,8 +21,8 @@ SOFTWARE.
#include "handlerpageedit.h" #include "handlerpageedit.h"
#include "../database/exceptions.h" #include "../database/exceptions.h"
#include "../request.h" #include "../request.h"
#include "../parserlegacy.h"
#include "../parser.h"
bool HandlerPageEdit::canAccess(std::string page) bool HandlerPageEdit::canAccess(std::string page)
{ {
return this->userSession->user.permissions.canEdit(); return this->userSession->user.permissions.canEdit();
@ -59,7 +59,7 @@ Response HandlerPageEdit::handleRequest(PageDao &pageDao, std::string pagename,
// TODO: must check, whether categories differ, and perhaps don't allow every user // TODO: must check, whether categories differ, and perhaps don't allow every user
// to set categories // to set categories
Parser parser; ParserLegacy parser;
std::vector<std::string> cats = parser.extractCategories(newContent); std::vector<std::string> cats = parser.extractCategories(newContent);
try try
{ {
@ -107,7 +107,7 @@ Response HandlerPageEdit::handleRequest(PageDao &pageDao, std::string pagename,
if(r.post("do") == "preview") if(r.post("do") == "preview")
{ {
std::string newContent = r.post("content"); std::string newContent = r.post("content");
Parser parser; ParserLegacy parser;
TemplatePage templatePage = this->templ->getPage("page_creation_preview"); TemplatePage templatePage = this->templ->getPage("page_creation_preview");
templatePage.setVar("actionurl", urlProvider->editPage(pagename)); templatePage.setVar("actionurl", urlProvider->editPage(pagename));
templatePage.setVar("preview_content", parser.parse(pageDao, *this->urlProvider, newContent)); templatePage.setVar("preview_content", parser.parse(pageDao, *this->urlProvider, newContent));

Näytä tiedosto

@ -21,7 +21,7 @@ SOFTWARE.
#include "handlerpageview.h" #include "handlerpageview.h"
#include "../database/exceptions.h" #include "../database/exceptions.h"
#include "../logger.h" #include "../logger.h"
#include "../parser.h" #include "../parserlegacy.h"
#include "../htmllink.h" #include "../htmllink.h"
bool HandlerPageView::canAccess(std::string page) bool HandlerPageView::canAccess(std::string page)
@ -130,7 +130,7 @@ Response HandlerPageView::handleRequest(PageDao &pageDao, std::string pagename,
TemplatePage &page = this->templ->getPage(templatepartname); TemplatePage &page = this->templ->getPage(templatepartname);
Parser parser; ParserLegacy parser;
Response result; Response result;
result.setStatus(200); result.setStatus(200);
std::string indexcontent; std::string indexcontent;

Näytä tiedosto

@ -24,10 +24,10 @@ SOFTWARE.
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include "parser.h" #include "parserlegacy.h"
#include "utils.h" #include "utils.h"
#include "htmllink.h" #include "htmllink.h"
std::vector<Headline> Parser::extractHeadlines(std::string content) const std::vector<Headline> ParserLegacy::extractHeadlines(std::string content) const
{ {
std::vector<Headline> result; std::vector<Headline> result;
utils::regex_callback_extractor(std::regex(R"(\[h(1|2|3)\](.*?)\[/h\1\])"), content, [&](std::smatch &smatch) { utils::regex_callback_extractor(std::regex(R"(\[h(1|2|3)\](.*?)\[/h\1\])"), content, [&](std::smatch &smatch) {
@ -39,7 +39,7 @@ std::vector<Headline> Parser::extractHeadlines(std::string content) const
return result; return result;
} }
std::vector<std::string> Parser::extractCategories(std::string content) const std::vector<std::string> ParserLegacy::extractCategories(std::string content) const
{ {
std::vector<std::string> result; std::vector<std::string> result;
std::string reg = R"(\[category\](.*?)\[/category\])"; std::string reg = R"(\[category\](.*?)\[/category\])";
@ -55,7 +55,7 @@ std::vector<std::string> Parser::extractCategories(std::string content) const
return result; return result;
} }
std::string Parser::extractCommand(std::string cmdname, std::string content) const std::string ParserLegacy::extractCommand(std::string cmdname, std::string content) const
{ {
std::string cmd = "[cmd:" + cmdname + "]"; std::string cmd = "[cmd:" + cmdname + "]";
std::string cmdend = "[/cmd:" + cmdname + "]"; std::string cmdend = "[/cmd:" + cmdname + "]";
@ -74,7 +74,7 @@ std::string Parser::extractCommand(std::string cmdname, std::string content) con
} }
return ""; return "";
} }
std::string Parser::processLink(const PageDao &pageDao, UrlProvider &urlProvider, std::smatch &match) const std::string ParserLegacy::processLink(const PageDao &pageDao, UrlProvider &urlProvider, std::smatch &match) const
{ {
std::string linktag = match.str(1); std::string linktag = match.str(1);
std::string inside = match.str(2); std::string inside = match.str(2);
@ -109,7 +109,7 @@ std::string Parser::processLink(const PageDao &pageDao, UrlProvider &urlProvider
return htmllink.render(); return htmllink.render();
} }
std::string Parser::parse(const PageDao &pagedao, UrlProvider &provider, std::string content) const std::string ParserLegacy::parse(const PageDao &pagedao, UrlProvider &provider, std::string content) const
{ {
std::string result; std::string result;
// we don't care about commands, but we nevertheless replace them with empty strings // we don't care about commands, but we nevertheless replace them with empty strings

Näytä tiedosto

@ -2,7 +2,7 @@
#define PARSER_H #define PARSER_H
#include "iparser.h" #include "iparser.h"
class Parser : public IParser class ParserLegacy : public IParser
{ {
private: private:
std::string processLink(const PageDao &pageDao, UrlProvider &urlProvider, std::smatch &match) const; std::string processLink(const PageDao &pageDao, UrlProvider &urlProvider, std::smatch &match) const;
@ -13,7 +13,7 @@ class Parser : public IParser
std::vector<std::string> extractCategories(std::string content) const override; std::vector<std::string> extractCategories(std::string content) const override;
std::string parse(const PageDao &pagedao, UrlProvider &provider, std::string content) const override; std::string parse(const PageDao &pagedao, UrlProvider &provider, std::string content) const override;
using IParser::IParser; using IParser::IParser;
~Parser(){}; ~ParserLegacy(){};
}; };
#endif // PARSER_H #endif // PARSER_H

Näytä tiedosto

@ -1,9 +1,9 @@
#ifndef PARSER_MARKDOWN_H #ifndef PARSER_MARKDOWN_H
#define PARSER_MARKDOWN_H #define PARSER_MARKDOWN_H
#include "parser.h" #include "parserlegacy.h"
#include "maddy/parser.h" #include "maddy/parser.h"
class ParserMarkdown : public Parser class ParserMarkdown : public ParserLegacy
{ {
private: private:
std::string processLink(const PageDao &pageDao, UrlProvider &urlProvider, std::smatch &match) const; std::string processLink(const PageDao &pageDao, UrlProvider &urlProvider, std::smatch &match) const;