Handlers: HandlerAllPages / HandlerCategory: Use PageListRenderer
This commit is contained in:
szülő
1c1416934b
commit
634cb2d7ee
@ -19,6 +19,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#include "handlerallpages.h"
|
||||
#include "../grouper.h"
|
||||
#include "../pagelistrenderer.h"
|
||||
|
||||
Response HandlerAllPages::handleRequest(const Request &r)
|
||||
{
|
||||
@ -27,17 +29,21 @@ Response HandlerAllPages::handleRequest(const Request &r)
|
||||
Response response;
|
||||
auto pageDao = this->database->createPageDao();
|
||||
QueryOption qo = queryOption(r);
|
||||
auto resultList = pageDao->getPageList(qo);
|
||||
if(resultList.size() == 0)
|
||||
std::vector<Page> pageList = pageDao->getPageList(qo);
|
||||
if(pageList.size() == 0)
|
||||
{
|
||||
return errorResponse("No pages", "This wiki does not have any pages yet");
|
||||
}
|
||||
TemplatePage searchPage = this->templ->getPage("allpages");
|
||||
std::string body = this->templ->renderSearch(resultList);
|
||||
searchPage.setVar("pagelist", body);
|
||||
searchPage.setVar("title", createPageTitle("All pages"));
|
||||
setGeneralVars(searchPage);
|
||||
response.setBody(searchPage.render());
|
||||
|
||||
PageListRenderer pagelistrender(*this->templ, *this->urlProvider, *this->database);
|
||||
TemplatePage allPages = this->templ->getPage("allpages");
|
||||
allPages.setVar("pagelistcontent", pagelistrender.render(pageList, r.get("rendertype")));
|
||||
allPages.setVar("pagelistletterlink", this->urlProvider->allPages(PageListRenderer::RENDER_GROUP_BY_LETTER));
|
||||
allPages.setVar("pagelistcreationdatelink", this->urlProvider->allPages(PageListRenderer::RENDER_GROUP_BY_CREATIONDATE));
|
||||
|
||||
allPages.setVar("title", createPageTitle("All pages"));
|
||||
setGeneralVars(allPages);
|
||||
response.setBody(allPages.render());
|
||||
response.setStatus(200);
|
||||
return response;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#include "handlercategory.h"
|
||||
#include "../pagelistrenderer.h"
|
||||
|
||||
Response HandlerCategory::handleRequest(const Request &r)
|
||||
{
|
||||
@ -34,8 +35,12 @@ Response HandlerCategory::handleRequest(const Request &r)
|
||||
QueryOption qo = queryOption(r);
|
||||
auto resultList = categoryDao->fetchMembers(categoryname, qo);
|
||||
TemplatePage searchPage = this->templ->getPage("show_category");
|
||||
std::string body = this->templ->renderSearch(resultList);
|
||||
searchPage.setVar("pagelist", body);
|
||||
PageListRenderer pagelistrender(*this->templ, *this->urlProvider, *this->database);
|
||||
|
||||
std::string body = pagelistrender.render(resultList, r.get("rendertype"));
|
||||
searchPage.setVar("pagelistcontent", body);
|
||||
searchPage.setVar("pagelistletterlink", this->urlProvider->category(categoryname, PageListRenderer::RENDER_GROUP_BY_LETTER));
|
||||
searchPage.setVar("pagelistcreationdatelink", this->urlProvider->category(categoryname, PageListRenderer::RENDER_GROUP_BY_CREATIONDATE));
|
||||
searchPage.setVar("categoryname", categoryname);
|
||||
setGeneralVars(searchPage);
|
||||
searchPage.setVar("title", createPageTitle("Category: " + categoryname));
|
||||
|
@ -1,6 +1,6 @@
|
||||
{qswiki:include:general_header}
|
||||
<div id="content" style="margin-top: 10px;">
|
||||
<h2>All pages</h2>
|
||||
{qswiki:var:pagelist}
|
||||
{qswiki:include:pagelistrender}
|
||||
</div>
|
||||
{qswiki:include:general_footer}
|
||||
{qswiki:include:general_footer}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{qswiki:include:general_header}
|
||||
<main id="content">
|
||||
<h2>Category: {qswiki:var:categoryname}</h2>
|
||||
{qswiki:var:pagelist}
|
||||
{qswiki:include:pagelistrender}
|
||||
</main>
|
||||
{qswiki:include:general_footer}
|
||||
{qswiki:include:general_footer}
|
||||
|
Betöltés…
Reference in New Issue
Block a user