GithubHelp home page GithubHelp logo

ouxsoft / livingmarkup Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 11.54 MB

A Processor for Markup written in PHP. Allows extraction of Markup into a data structure, orchestrated nested manipulation of said structure, and output as (optimized) Markup.

License: MIT License

PHP 99.24% HTML 0.76%
template-engine lhtml-processor markup-converter markup abstraction-layer hacktoberfest processor

livingmarkup's People

Contributors

aswinvk28 avatar codacy-badger avatar hxtree avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

aswinvk28

livingmarkup's Issues

Package Rename

Considerations alternative names for PXP repository. Rather than an abbreviation of what it does, move towards something meaningful to communicate what it can do. PXP has always been a code word for the project.

Suggestions:
DynamicMarkup
AtomicMarkup

Factors:

  • Should point towards a specification rather than a implementation.
  • Should be unique
  • Should be short
  • Easy to remember
  • Explain it's purpose

docker compose

remover docker build
move docker compose down and compose up top.
allow caching unless argument passed

No root element error

The following example will fail without warning as there is no root element. A notice should be provided.

<redact>
Hello
</redact>
<p><redact>Bear</redact></p>

Perhaps in the form of a comment such as <!-- No Root Element Found --> or an <html> tag should be automatically added.

Content Types ?

Bolts way of handling content types is neat although I don't like the single file. This is a copy and past from the editor default setup.

# This file defines the contenttypes on the website. See the documentation for
# details: https://docs.bolt.cm/contenttypes/intro

# The Homepage contenttype is a singleton: There can be only one record of this
# contenttype.

homepage:
    name: Homepage
    singular_name: Homepage
    fields:
        title:
            type: text
            class: large
            group: content
            postfix: |
                The 'Homepage' can contain basic information about the website. This title will be
                shown on the homepage of the website, as the name implies. To change the
                <em><strong>name</strong></em> of the site, as is shown in the header, and the tab
                in the webbrowser, edit <code>sitename:</code> in the configuration file.
        image:
            type: image
            placeholder: https://source.unsplash.com/1920x640/?cityscape,landscape,nature/__random__
        teaser:
            type: html
            height: 150px
        content:
            type: html
            height: 300px
        contentlink:
            type: text
            label: Link
            placeholder: 'contenttype/slug or http://example.org/'
            postfix: "Use this to add a link for this Homepage. This could either be an 'internal' link like <tt>page//about</tt>, if you use a contenttype/slug combination. Otherwise use a proper URL, like `http://example.org`."
        slug:
            type: slug
            uses: title
            group: meta
    viewless: true
    singleton: true
    default_status: published
    icon_many: "fa:home"
    icon_one: "fa:home"


# Pages can be used for the more 'static' pages on your site. This content-type
# has a 'templateselect' field, which allows you to override the record_template
# setting for an individual page.
# The taxonomy for this ContentType is defined as 'groups', which is a so-called
# "grouping taxonomy". This way you can easily group sets of pages that logically
# belong together. If your site has a 'services' section, in which you'd like to
# list the different types of services a company provides, you can group these
# together.

pages:
    name: Pages
    singular_name: Page
    fields:
        title:
            type: text
            class: large
            group: content
        slug:
            type: slug
            uses: title
        image:
            type: image
            placeholder: https://source.unsplash.com/1280x768/?business,workplace/__random__
        teaser:
            type: html
            height: 150px
        body:
            type: html
            height: 300px
        template:
            type: templateselect
            filter: '*.twig'
    taxonomy: [ groups ]
    recordsperpage: 20


# Entries can be used for things like 'news' or 'blogpostings'. They have a
# 'teaser', which can be used for a short blurb on listing-pages, allowing
# visitors to click-through to the rest of the entry. It also has fields for an
# image and an optional video.
# A relation is defined to the pages ContentType. This way you can refer to a
# page from your news-item.
# This ContentType defines 'categories' and 'tags' as taxonomies, allowing the
# editor to use both to categorize a specific entry.
# The 'sort' is set to '-datepublish', which means that newer entries will be
# shown above older entries.

entries:
    name: Entries
    singular_name: Entry
    fields:
        title:
            type: text
            class: large
            group: content
        slug:
            type: slug
            uses: title
        teaser:
            type: html
            height: 150px
        body:
            type: html
            height: 300px
        image:
            type: image
            group: media
            placeholder: https://source.unsplash.com/1280x768/?business,workspace,interior/__random__
        video:
            type: video
    relations:
        pages:
          multiple: false
          order: title
          label: Select a page
    taxonomy: [ categories, tags ]
    record_template: entry.twig
    listing_template: listing.twig
    listing_records: 10
    default_status: published
    sort: -datepublish
    recordsperpage: 20


# The 'Showcases' is not particularly useful in most cases, but it does a good
# job of showcasing most of the available fieldtypes. Feel free to delete it, or
# copy some fields to your own ContentTypes.
# Since no templates are defined for this ContentType, the default record_template,
# listing_template, and related settings are used from config.yml

showcases:
    name: Showcases
    slug: showcases
    singular_name: Showcase
    singular_slug: showcase
    fields:
        title:
            type: text
            class: large
            required: true
            pattern: ".{2,255}" # see: http://html5pattern.com/
            error: "The Title field is required, and must contain at least 2 characters"
            group: Text
        slug:
            type: slug
            uses: [ title ]
        html:
            type: html
            height: 150px
        textarea:
            type: textarea
            postfix: "<p><em>This is a plain text area. the contents will not be processed.</em></p>"
        markdown:
            type: markdown
            postfix: "<p><em>This field gets parsed as <a href='https://help.github.com/articles/markdown-basics'>Markdown</a>, when rendered on the site.</em></p>"
        geolocation:
            type: geolocation
            group: Media
        embed:
            type: embed
        video:
            type: video
        image:
            type: image
            attrib: title # Note: retrieve this in your template with {{ record.values.image.title }}
            extensions: [ gif, jpg, png ]
            placeholder: https://source.unsplash.com/1280x768/?animal,koala,kitten,puppy,cute/__random__
        imagelist:
            type: imagelist
        file:
            type: file
            group: files
        filelist:
            type: filelist
        checkbox:
            type: checkbox
            label: "This is a checkbox"
            group: other
        datetime:
            type: datetime
            default: "2000-01-01"
            variant: inline
        date:
            type: date
            default: "first day of last month"
            variant: inline
        integerfield:
            type: integer
            index: true
        floatfield:
            type: float
        selectfield:
            type: select
            values: [ foo, bar, baz ]
        multiselect:
            type: select
            values: [ A-tuin, Donatello, Rafael, Leonardo, Michelangelo, Koopa, Squirtle ]
            multiple: true
            postfix: "Select your favourite turtle(s)."
        selectentry:
            type: select
            values: entries/id,title
            postfix: "Select an entry"
            autocomplete: true
            sort: title
        repeater:
            type: repeater
            group: repeater
            label: Simple repeater example
            icon: fa:repeat
            limit: 3
            prefix: "<p>This allows you to create multiple sets of fields. Use the add button at the bottom to create a new empty set.</p>"
            fields:
                repeattitle:
                    type: text
                repeatimage:
                    type: image
                    extensions: [ gif, jpg, png ]
                repeatcontent:
                    type: html
    relations:
        entries:
            multiple: false
            label: "Choose an entry"
            order: -id
            format: "{{ item.title|escape }} (โ„– {{ item.id }})"
            postfix: "By selecting an Entry, you're creating a bi-directional relationship to that Entry."
        pages:
            multiple: true
            order: title
            label: Select zero or more pages
    taxonomy: [ categories, tags ]
    show_on_dashboard: true
    default_status: published
    searchable: true
    icon_many: "fa:gift"
    icon_one: "fa:gift"


# The 'Blocks' ContentType is a so-called 'resource ContentType'. This means
# that it can be used to manage smaller pieces of content, like the 'about us'
# text, an 'our address' in the footer, or similar short blurbs of text.
# For more info, see: https://docs.bolt.cm/howto/resource-contenttype

blocks:
    name: Blocks
    singular_name: Block
    fields:
        title:
            type: text
            class: large
            group: "Block"
        slug:
            type: slug
            uses: [ title ]
        content:
            type: html
            height: 150px
        contentlink:
            type: text
            label: Link
            placeholder: 'contenttype/slug or http://example.org/'
            postfix: "Use this to add a link for this Block. This could either be an 'internal' link like <tt>page/about</tt>, if you use a contenttype/slug combination. Otherwise use a proper URL, like `http://example.org`."
        image:
            type: image
            attrib: title
            extensions: [ gif, jpg, png ]
    show_on_dashboard: true
    viewless: true
    default_status: published
    searchable: false
    icon_many: "fa:cubes"
    icon_one: "fa:cube"

# Possible field types:
#
# text - varchar(256) - input type text.
# integer - integer - Input field for integer numbers.
# float - double - Input field for floating numbers, stored as 'Double'.
# geolocation - text (65kb) - Input field for geolocation. Enter an address, and the location is geocoded to latitude/longitude coordinates
# imagelist - text (65kb) - Input type for imagelists. Add multiple images with a description. Useful for image sliders, galleries, etcetera.
# image - varchar(256) - image select/upload widget, stored as filename.
# file - varchar(256) - file select/upload widget, stored as filename.
# filelist - text (65kb) - Input type for a list of files. Including a description.
# video - varchar(256) - Video embed widget, stored as filename.
# html - text (65kb) - wysiwyg element.
# textarea - varchar(32768) - Simple, plain < textarea > field.
# markdown - varchar(32768) - Simple, plain < textarea > field, which is parsed as Markdown text.
# datetime - datetime - date and time selector widget.
# date - datetime - date selector widget.
# select - varchar(256) - select with predefined values
# templateselect - varchar(256) - select with template filenames
# checkbox - integer - checkbox-field which is 1 (checked) or 0 (unchecked)

# Using YAML repeated nodes
#
# YAML allows the defining of "repeated nodes". These allow you to define a 'node'
# with a 'key: &name' and referenced later with '<<: *name'
#
# Bolt allows you to define this with the special entry of '__nodes:' that itself
# won't create a ContentType, but will allow you to use it in actual ContentTypes
# to prevent repeating yourself.
#
# To achieve this, first create a key '__nodes:'
#__nodes:
#    field_defaults: &field_defaults
#        title:
#            type: text
#            class: large
#            group: main
#        slug:
#            type: slug
#            uses: title
#    template_defaults: &template_defaults
#        template:
#            type: templateselect
#            filter: '*.twig'
#            group: meta
#
# Then, as an example, you could create a ContentType with default fields, with
# an additional 'image' field.
#
#contenttype_abc:
#    name: ContentType Abc
#    fields:
#        <<: *field_defaults
#        image:
#            type: image
#            attrib: title
#            extensions: [ gif, jpg, png ]
#        <<: *template_defaults
#    taxonomy: [ chapters ]
#    recordsperpage: 10
#
# Alternatively, or additionally, you then can then create a ContentType with
# default fields, and a 'select' field, and a different 'templateselect' option.
#
#contenttype_xyz:
#    name: ContentType Xyz
#    fields:
#        <<: *field_defaults
#        selectfield:
#            type: select
#            values: [ none, foo, bar ]
#        template:
#            type: templateselect
#            filter: '*_xyz.twig'
#    taxonomy: [ tags ]
#    recordsperpage: 20

HTML5 Support

I spoke with Zend about DomDocument not being able to support HTML5. They said it has to do with the DomDocument maintainers, not PHP.
https://www.php.net/manual/en/class.domdocument.php

Apparently it has to do with the libxml2 maintainers.
https://bugzilla.gnome.org/show_bug.cgi?id=761534

There appears to be a PHP fix here, which looks to be a more bloated version of what LivingMarkup is currently doing. It checks for weird things like multiple <head> tags. Consider using, rather than reinventing the wheel with the Page element. And then removing the Component part to it's own processor.
https://github.com/ivopetkov/html5-dom-document-php

added dom escape function

need a way of escaping user provided data of instantiable tags for security.

This should prevent any instantiantiabled tag from being provided.

e.g. if there is an 'if' module then it should strip if tags.

ImageAPI

Other options could include:
flip/horizontally
flip/vertically
fliter/grayscale
filter/hsb
rotate/180
Hue, Saturation, Brightness

Arg type attribute

Add optional type to args, otherwise use type jugging.


<arg type="int">1</arg>
<arg type="bool">FALSE</arg>
<arg type="string">Hi</arg>
<arg type="json">{1,2,3}</arg>
<arg type="array">[1=>'c',2=>'b',3=>'a']</arg>

Else condition

Allow for condition else, e.g.


<condition>
<arg name="day_of_week">tuesday<arg>
<arg name="else">
 <p>You missed our sale<p>
</arg>
<p>Happy Tuesday, you'll receive 5% all goods.</p>
</condition>

DynamicElement Interaction

There should be a way for dynamic elements to interact.

A conditional statement may want to check if a variable is set in it's parent iteration.

$this->parent->id();
$this->child->id();
$this->self->id();
$this->element('23')->get_var('happy');

A variable will need to be able to check some scope for it's existence

This should be built into the DynamicElement abstract class.

Embed PXP in PHP file

Allow for a require to be placed at start of page that starts of a file. The require file would turn output buffering on,ob_start(), and then once completed, possible using __deconstruct(), the buffer is added to $page_builder->loadDom or similar.

e.g.


<?php require '../pxp/include/header.php';?>
<condition>
<arg name="day_of_week">tuesday</arg>
Happy Tuesday, <?php echo $_SESSION['username'];?>
</condition>

Exist in editable range

There should be a component setting to state whether or not a component can exist in an editable region.

For example, you don't want a web editor adding a <block name="MainMenu"/> to a <div> that is editable.

Not sure where this setting should reside. Probably within the Component itself. Perhaps ACL concerning the Component would suffice.

$component->allow_in_editable_region = false;

This would check if any parents featured an attribute that indicated whether or not it was editable. Perhaps <div editable="true"> or <div region="wysiwyg">, etc.

documentation rough

Docs should be polished to help others follow.

Also, it's important to clarify that PXP is fairly well built but DynamicElements are provided for example purposes, and ideally would be contributed by others.

getArg()

Calling $this->args['style'] seems problematic as the key could not be set. It's best to build a method for calling args,

e.g. $this->getArg('style');

APIs

In order to aid in package reuse the API needs to be solid and unchanging. Config should be able to be moved to being a property of the builder.

$kernel = new Kernel();
$builder = new DynamicBuilder();

// blueprints
$builder->instantiateXpath(string $xpath, string $class_name, array $properties); // addObject
$builder->orchestrateMethod(string $method_name, int $ranking_modifer = null); // addMethod

// materials
$builder->parseBuffer();
$builder->parseFile();
$builder->parseString();

echo $kernel->build($builder);

Condition time issue

This will not work as time spans multiple days

	<condition time_start="4:00am" time_end="3:59pm">
		<p>Good morning.</p>
	</condition>
	<condition time_start="4:00pm" time_end="3:59am">
		<p>Good evening</p>
	</condition>

Includes CSS and Javascript

DynamicElements should be able to register CSS and Javascript with parent element.

Things like async includes should be considered.

$dom->js_add('async'=>'','url'=>'example.js');
$dom->css_add('url'=>'example.css');

Code Component

A code component would make the examples clearer. Within the component things are rendered as is and are not instantiated.

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.