I AM LISTENING TO
|
WHAT I LIKE
  • en
  • de
BLOG FILTER

Due to Google AMP (Accelerated Mobile Pages) , I have been looking for a way to effectively do Syntax Highlighting without Javascript in pure PHP.

I was about to write my own, when I found an older article from phoboslab. Thanks Dominic for saving me some time ;) Its not perfect, but close enough.

A simple Syntax Highlighting Class that does just that. The class was not working with PHP 5.4.x+, as it uses  preg_replace() with the /e modifier.

It will not cover all, but its better than nothing :) I will also add a section to my my AMP tweaks article to showcase the integration of Geshi.

Here an updated version using the preg_replace_callback() function.

THE SYNTAX HIGHLIGHT CLASS

THE CSS

USAGE

@GitHub portalzine/UtilityBelt/SyntaxHighlight

Enjoy coding …

readmore
29. February 2016

AMP-WP Tweaks & Tips

The AMP (Accelerated Mobile Pages Project) plugin for WordPress is still pretty young and under heavy development.

There are little things that can help to fix current validation problems. I have a couple of fresh AMP pages, that are already indexed by Google.

0. RESOURCES


1. MISSING IMAGE (schema.org-NewsArticle)

The currently registered Microformats template (schema.org-NewsArticle) requires an image.
The AMP-WP documentation explains how to add a featured image to your pages (documentation).

I extended that a bit,  to link a default attachment image, I uploaded before. This needs to be added to your themes functions.php.

Next we adjust the Microformats definition. This needs to be added to your themes functions.php.


2. ADD YOUR OWN AMP TEMPLATE

Read the AMP-WP documentation first :) This forces AMP-WP to override the core template with your own. Use the default template as a reference.


3. REMOVE NONE VALIDATING CONTENT

Normally the core sanitizer should take care of that.  I am sure a filter will be added in the future. For now, this is a quick workaround. You can use a RegExp or DOMDocument to alter the amp-content in your custom template and filter things that break validation.

I am using phpQuery for now, as it allows me to add quick fixes. DOMNode or QueryPath works nicely as well :) Will be looking at the core sanitizer and options later this week. All of this is currently added to the custom template.

  1. Remove REL attributes that are not allowed. Only registered Microformat rel attributes are allowed.
  2. Remove attribute ALIGN
  3. Fix TARGET Attribute

Finally output the fixed content as HTML.

The above examples need to be tweaked to your specific content requirements.

The custom template “post_amp_content” before:

The custom template “post_amp_content” after:


4. ADD PREVIOUS & NEXT POST NAVIGATION

From the AMP specification :”Note, that AMP document may also be linked to directly…”

This is being added to the custom template as well.

Next:

Previous:


5. SYNTAX HIGHLIGHTING

You can find a simple pure PHP highlighter here. Not perfect, but a start. Don not forget to include the CSS :)

 

I will extend on this as new validation errors or tweaks come up. The core sanitizer of AMP-WP still needs some work and should allow us to do some of the above directly, when the content is parsed / converted for AMP.


 

 6. OTHER AMP ARTICLES

Make Syntax Highlighting work in AMP-WP using GeSHi

Time to get AMP ready

 

Enjoy coding …

 

readmore

Structure opened its doors a couple of days ago.

Structure offers a simple and powerful IoT cloud platform for developing the next generation of connected experiences. They offer device management with robust data visualization that reacts in real-time.

They have a nice drag & drop workflow interface that allows you to forward data coming in, combine data or just store it.

I will be testing a builder kit with the platform, that includes the Adafruit Feather Huzzah, which offers native Wifi connectivity. My Raspberry Pi’s will also find their way into the system. The platform allows to consume REST Apis as well,  that will make it even more fun to build something unique.

If you are interested in IoT, you should really check it out. Its free :)

Structure / Adafruit Feather Huzzah

Enjoy coding …

readmore
26. February 2016

Time to get AMP ready

Google’s AMP is here to save us from slow mobile content delivery, by enforcing strict standards and limiting what is allowed within AMP pages. The pages only allow a subset of tags and introduce their own tags for fast prefetching of content (images, videos … AMP Specs)

THIS IS AMP

“The Accelerated Mobile Pages (“AMP”) Project is an open source initiative that came out of discussions between publishers and technology companies about the need to improve the entire mobile content ecosystem for everyone – publishers, consumer platforms, creators, and users.

Today, the expectation is that content should load super fast and be easy to explore. The reality is that content can take several seconds to load, or, because the user abandons the slow page, never fully loads at all. Accelerated Mobile Pages are web pages designed to load instantaneously – they are a step towards a better mobile web for all.”

AMP CACHE & VALIDATION

AMP pages are cached within the AMP Cache, providing even faster delivery of your content. The core libs validate your implementation and highlight any problems by pushing errors to the console.

INTEGRATION

The documentation lists all components currently supported within a page and experimental components in development as well.

  1. Introduction to AMP
  2. Video Introduction
  3. AMP for WordPress
  4. AMP Docs
  5. Q&A Video

I have already added AMP support to our blog posts:

  1. Standard page
  2. AMP page

Google’s Webmaster Tools also integrates a new section for AMP, to see how they perform.

WHAT AMP IS NOT

AMP is not supposed to replace your webpage, but offer a faster access point to presented content. It will not solve all use cases, but offer better performance for your simple reading pleasure for now. Its a start and lets see how it evolves ;)

Enjoy coding …

readmore
13. February 2016

Markdown editors

As I mentioned the usage of Markdown for the Slate documentation builder, here some Markdown editors:

ULYSSES FOR MAC/ IPAD

Highly customizable editor.

http://www.ulyssesapp.com/

STACKEDIT INBROWSER SOLUTION

Use it anywhere and sync to dropbox if you like.

https://stackedit.io/

MARKDOWN PAD FOR WINDOWS

Nice split-screen setup, that shows you how the html conversion looks like.

http://markdownpad.com/

MARKMYWORDS FOR LINUX

A nice minimal editor that was developed for Elementary OS.

https://github.com/voldyman/MarkMyWords

Enjoy coding …

readmore

Slate helps you create beautiful, intelligent, responsive API documentation. All documentation is written in Markdown and than converted into a responsive layout.

Markdown is a lightweight markup language with plain text formatting syntax designed so that it can be converted to HTML and many other formats.

Slate @ Github

Have used it on multiple projects and I love it.

Enjoy coding …

readmore

Alertify.js is a small library which provides light-weight, high performance browser dialogs.

Alertify @Github

readmore

jQuery.sheet is spreadsheet plugin, that offers creation, viewing and editing. All combined with a nice API.

jQuery.sheet

readmore
2. February 2016

LMS meets SaaS

As I said before, Learning Management is really taking off and I get many client requests to do some kind of  integration or custom solution for them.

In one of my latest articles I started listing solutions for WordPress, WordPress and the LMS universe.

But those solutions might not always be the best fit for your project. Many of them actually try too hard to be everything. The amount of cross linked functionality is getting insane and increases the point of failure.

In some cases a trimmed down solid solution might be the better way to go. SaaS (Software as a Service), part of the cloud trend, is providing more and more options, this includes the LMS arena. Stop worrying about the software and concentrate on your content again. The SaaS provider takes care of functionality, support, updates and delivery. This is nothing new, solutions like TalentLMS or Litmos LMS offer this for some time now.

Modern SaaS solutions provide Public APIs, that allow you to seamlessly integrate them with your current solution. So in case of a LMS, that part of your project could be handled by the SaaS provider, while e-commerce, social and other content areas remain under your full control.

One solution I am currently looking at is Intuo, which is a fresh startup out of Gent / Belgium. They provide a solid set of features and a clean API to handle single signons and content access. That would allow a seamless integration into WordPress for example :)

We are looking at a very crowded LMS market, but always nice to have options :)

Enjoy coding …

readmore
1. February 2016

Parse Alternatives

Now that Parse is phasing out (01/2017), people are looking for alternatives that offer:

  • Data Storage
  • Push Notifications
  • Usage Analytics
  • Dashboard
  • Social Integration
  • User Administration
  • Cloud Code Integration
  • Multiple Mobile Platform SDKs
  • Background Jobs
  • Crash Report

Collaborative list of Parse alternative backend service providers @ GitHub

readmore