Coder Social home page Coder Social logo

expose-to-statamic-exporter's Introduction

Expose to Statamic Exporter


This package can be used to assist with the export of Expose CMS data into a Statamic CMS project.

Example Step by Step.

  • Get News Articles from DB
  • Loop through Each Article:
    • Check if Entry Exists
    • If not Create, else fetch
    • build a data array (title, template, published and any other fields you might require)
    • For the Entry body you can start building up HTML body, then add to this using the Textile Parser.
    • if an image is required use the AssetFactory to create one. and add this to the data array using the filename.
    • If an image is to be displayed in the body of the post add <img src='asset::container_name::fileName'/> to the HTML body
    • If any terms are Required use the TermFactory to create one by passing the Taxonomy and the Slug.
    • the html body can be passed to the HtmlToProseMirrorJsonConverter and then added ot the Data.
    • Once finished call save on any Entries

Installation

You can install the package via composer:

composer require  garrick3491/expose-statamic-export

Usage

  1. Create a new blank Entry using the EntryFactory by passing the Collection, Slug and Blueprint
  2. AssetExists can be used to check if any Assets exist in a given Asset Container name with a given File Name
  3. AssetFactory can be used to generate Assets when given a filepath, filename and Asset Container name
  4. EntryRetriever can be used to fetch Entries rather than creating them from scratch.
  5. TextileParser can be used to convert Textile into HTML.
  6. HtmlToProseMirrorJsonConverter can be used to convert HTML into Prose Mirror JSON that Statamic Accepts.
$entryFactory = new EntryFactory();
$entryFactory->createNewEntry('news', 'article_one', 'news') // returns entry;
$assetExists = new AssetExists();
echo $assetExists->doesAssetExist('asset', 'article_one_header_image') //bool;
$assetFactory = new AssetFactory();
echo $assetFactory->createNewAsset('asset', 'article_one_header_image', self::IMAGE_PATH  . '/' . $fileName) // returns saved Asset;
$entryRetriever = new EntryRetriever();
echo $entryRetriever->getSingleEntry('news', '********-****-****-****-********') // returns Entry if exists, Throws DoesNotExistException if no entry found;
$textileParser = new TextileParser();
echo $textileParser->convertTextileToHtml('h2. *Some Text*') // returns string HTML;
$proseMirrorConverter = new HtmlToProseMirrorJsonConverter();
echo $proseMirrorConverter->convertHtmlToProseMirrorJson('<p>Hello World</p>') // returns array of data that can be added to entry;

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

expose-to-statamic-exporter's People

Contributors

garrick3491 avatar dependabot[bot] avatar

Watchers

James Hall avatar Andy Fitch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.