How to use scrivito - 10 common examples

To help you get started, we’ve selected a few scrivito examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Scrivito / scrivito_example_app_js / src / Objs / SearchResults / SearchResultsComponent.js View on Github external
calculateResults() {
    if (!this.props.params.q) {
      return {
        searchResults: [],
        totalCount: 0,
        tags: [],
      };
    }

    let search = Scrivito.Obj.where(
      "*",
      "containsPrefix",
      this.props.params.q
    ).andNot("_objClass", "equals", blacklistObjClasses);

    // make sure, that tags are calculated _before_ limiting to specific tag.
    const tags = search.facet("tags").map(tag => tag.name());

    if (this.props.params.tag) {
      search = search.and("tags", "equals", this.props.params.tag);
    }

    return {
      searchResults: search.take(this.state.maxItems),
      totalCount: search.count(),
      tags,
github Scrivito / scrivito_example_app_js / src / Components / BlogPost / BlogPostNavigation.js View on Github external
const BlogPostPreviousLink = Scrivito.connect(({ currentBlogPost }) => {
  const currentDate = currentBlogPost.get("publishedAt");

  // find less than or equal publishedAt
  const [olderPost] = Scrivito.getClass("BlogPost")
    .all()
    .andNot("id", "equals", currentBlogPost.id())
    .andNot("publishedAt", "isGreaterThan", currentDate)
    .order("publishedAt", "desc")
    .take(1);

  if (!olderPost) {
    return null;
  }

  return (
    
      <i aria-hidden="true">
    </i><i aria-hidden="true">
  );
});</i>
github Scrivito / scrivito_example_app_js / src / Components / BlogPost / BlogPostNavigation.js View on Github external
const BlogPostNextLink = Scrivito.connect(({ currentBlogPost }) =&gt; {
  const currentDate = currentBlogPost.get("publishedAt");

  // find greater than publishedAt
  const [newerPost] = Scrivito.getClass("BlogPost")
    .where("publishedAt", "isGreaterThan", currentDate)
    .order("publishedAt", "asc")
    .take(1);

  if (!newerPost) {
    return null;
  }

  return (
    
      <i aria-hidden="true">
    </i><i aria-hidden="true">
  );
});
</i>
github Scrivito / scrivito_example_app_js / src / prerenderContent / prerenderObjs.js View on Github external
export default async function prerenderObjs(
  objClassesBlacklist,
  storeResult,
  reportError
) {
  console.time("[prerenderObjs]");

  console.time("Loading all objs");
  const objs = await Scrivito.load(() => allObjs(objClassesBlacklist));
  console.timeEnd("Loading all objs");
  console.log(`Loaded ${objs.length} objs`);

  let failedCount = 0;

  const objsGroups = chunk(objs, 10);
  await asyncForEachSequential(objsGroups, async objsGroup =>
    asyncForEach(objsGroup, async obj => {
      try {
        const prerenderedFiles = await prerenderObj(obj);
        await asyncForEach(prerenderedFiles, storeResult);
      } catch (e) {
        failedCount += 1;
        const pageId = obj.id();
        const pageUrl = Scrivito.urlFor(obj);
        reportError(
github Scrivito / scrivito_example_app_js / src / prerenderContent / prerenderSitemap.js View on Github external
export default async function prerenderSitemap(
  objClassesWhitelist,
  storeResult
) {
  console.time("[prerenderSitemap]");

  const pages = await Scrivito.load(() =>
    prerenderSitemapSearch(objClassesWhitelist).take()
  );
  const sitemapUrls = await Scrivito.load(() => pages.map(pageToSitemapUrl));
  const content = sitemapUrlsToSitemapXml(sitemapUrls);

  console.log(
    `[prerenderSitemap] Generated sitemap.xml with ${sitemapUrls.length} items.`
  );
  console.timeEnd("[prerenderSitemap]");
  await storeResult({ filename: "/sitemap.xml", content });
}
github Scrivito / scrivito_example_app_js / src / Objs / SearchResults / SearchResultItem.js View on Github external
function SearchResultItem({ resultItem, q }) {
  const searchWords = q.split(/\s+/);
  const extractedText = Scrivito.extractText(resultItem, { length: 220 });
  const textToHighlight = truncate(extractedText, {
    length: 200,
    separator: /,? +/,
  });

  return (
    <div>
      
      <div>
        
          <h3>
            </h3></div></div>
github Scrivito / scrivito_example_app_js / src / utils / textExtractRegistry.js View on Github external
export function registerTextExtract(className, attributes) {
  if (!isString(className)) {
    console.warn(
      `registerTextExtract: className '${className}' needs to be a string!`
    );
  }
  if (!Scrivito.getClass(className)) {
    console.warn(
      `registerTextExtract: className '${className}' is not defined!`
    );
  }
  if (textExtractRegistry[className]) {
    console.warn(
      `registerTextExtract: className '${className}' is already registered!`
    );
  }

  textExtractRegistry[className] = attributes;
}
github Scrivito / scrivito_example_app_js / src / Objs / SearchResults / SearchInput.js View on Github external
handleSubmit(event) {
    event.preventDefault();
    event.stopPropagation();
    Scrivito.navigateTo(() => Scrivito.currentPage(), { q: this.state.q });
  }
}
github Scrivito / scrivito_example_app_js / src / Components / Navigation / Search.js View on Github external
handleSubmit(event) {
      event.preventDefault();
      event.stopPropagation();
      Scrivito.navigateTo(oldestSearchResultsPage, { q: this.state.q });
      this.setState({ q: "" });
      this.props.toggleSearch();
    }
  }
github Scrivito / scrivito_example_app_js / src / Components / Navigation / NavigationSection.js View on Github external
const obj = Scrivito.currentPage();
  if (!obj.get("navigationSection")) {
    return null;
  }

  return (
    
  );
}

export default Scrivito.connect(NavigationSection);

scrivito

Scrivito is a professional, yet easy to use SaaS Enterprise Content Management Service, built for digital agencies and medium to large businesses. It is completely maintenance-free, cost-effective, and has unprecedented performance and security.

LGPL-3.0
Latest version published 5 days ago

Package Health Score

68 / 100
Full package analysis