Пример #1
0
  private Series parseForm(Request request) {
    Series series = new Series();
    series.setName(request.formParam("name"));
    series.setDescription(request.formParam("description"));

    String path = request.formParam("path");
    if (path != null && !path.isEmpty()) {
      series.setPath(Paths.get(path));
    }

    return series;
  }
Пример #2
0
 Response show(Request request) {
   long id = Long.parseLong(request.urlParam("id"));
   Series series = wa.serieses.get(id);
   return render(
       "series/show.ftl",
       "series",
       series,
       "descriptionHtml",
       Markdown.render(series.getDescription(), request.uri()),
       "crawls",
       wa.crawls.listBySeriesId(id),
       "collections",
       wa.collections.listWhereSeriesId(id));
 }
Пример #3
0
  Response update(Request request) {
    long seriesId = Long.parseLong(request.urlParam("id"));
    List<Long> collectionIds =
        request
            .formParams()
            .getOrDefault("collection.id", Collections.emptyList())
            .stream()
            .map(Long::parseLong)
            .collect(Collectors.toList());
    List<String> collectionUrlFilters =
        request.formParams().getOrDefault("collection.urlFilters", Collections.emptyList());

    if (collectionIds.size() != collectionUrlFilters.size()) {
      return response(400, "collection.id and collection.urlFilters mismatch");
    }

    wa.serieses.update(seriesId, parseForm(request), collectionIds, collectionUrlFilters);
    return seeOther(request.contextUri().resolve("series/" + seriesId).toString());
  }
Пример #4
0
 Response edit(Request request) {
   long id = Long.parseLong(request.urlParam("id"));
   Series series = wa.serieses.get(id);
   return render(
       "series/edit.ftl",
       "series",
       series,
       "collections",
       wa.collections.listWhereSeriesId(id),
       "allCollections",
       wa.collections.listAll(),
       "csrfToken",
       Csrf.token(request));
 }
Пример #5
0
 Response createSeries(Request request) {
   long seriesId = wa.serieses.create(parseForm(request));
   return seeOther(request.contextUri().resolve("series/" + seriesId).toString());
 }
Пример #6
0
 Response index(Request request) {
   Pager<SeriesDAO.CrawlSeriesWithCount> pager =
       wa.serieses.paginate(Parsing.parseLongOrDefault(request.queryParam("page"), 1));
   return render("series/index.ftl", "seriesList", pager.items, "seriesPager", pager);
 }