Here's What's Been Going On Recently!

Hey everyone,

It's amazing how fast time flies by and if we neglect it then we should put the blame upon our shoulders. This is not only related to Chyrp but it relates to every aspect of this life. There's an important thing I learned between the time when we released 2.5 Beta 1 and now, that is I should never again set a release date. Sometimes keeping a promise varies due to other life circumstances which mostly are out of our competences and there's nothing we can do about it. I will seriously try to remember this hint everytime a new Chyrp version is about to come out.

Though the delay has it's pros and cons, I strongly believe we could pull more advantages off it than critically judging. Chyrp 2.5 has been cooking for a while now but if you've followed along with development, you (should) have realized by now the exciting new stuff this release will bring with.

The beginning of this year was a great start. If you recall from the last blog post Jack talked about Chyrp possibly being added to certain instant installers and yes we got in. The first one to support Chyrp was Softaculous by adding it to the list of web apps shipping with their instant installation script. This is very important for us, and Chyrp in particular because Softaculous happens to be used by the majority of web hosting providers and this might just bring Chyrp close to users that are yet unaware of its existence.

The second event that made us even happier was the cool generous deed by AppFog to include Chyrp in their PHPFog Jumpstart web apps list. PHPFog is an extremely flexible PHP Cloud Hosting provider with an extremely user-friendly interface and very convenient prices. I mean, they didn't only add it but after fiddling a bit with Chyrp and working to get it up there, @phyre5 was impressed with Chyrp's simplicity and how lightweight it actually is.

@phyre5: You're quite welcome! Thank you for making such a lightweight blogging engine with a one-step setup process. It was fun!

This in return is a bonus point comment and pushes our morale up high to keep working even harder and bring great results eventually.

And many other cool things which closely relate with the 2.5 release but I'll leave them for the follow-up post since it's going to be a bit longer.

The release of Chyrp 2.1.2

Last but not least, the good guys over at High-Tech Bridge Security Research Lab in Switzerland found a tiny potential XSS issue on Chyrp. There's no need to panic tho, normally the attacker would need to gain login access to your admin panel in order to execute malicious code, but anyhow we take your and Chyrp's security close to our heart thus we fixed the issue.

If you're running whatever version of Chyrp we recommend you go ahead and update it. The easiest way to patch your installation would be to grab the only changed file below and replace it in your server, that would do just fine. When I say 'whatever Chyrp version' I mean 2.5 Beta 1 users should do the same if they don't want to wait for the next beta to come out. Newer Chyrp versions, starting with 2.5 Beta 2 (due this weekend) will already be patched so if you haven't tried the last beta yet, hold on to what you currently have, Beta 2 brings the new Firecrest theme along. Until then, download below and go patch your Chyrp powered site. See you again very soon.

Download Patched File

ajax.php

• Arian

Instant Installers

Theres been some great news in the community today. Arian has just found out via twitter that chyrp will be an app installable via phpFog, which is cloud hosting service that provides its own instant cms installers. This in addition to instant install will be the second instant installer chyrp is available on. This is terrific news, and I hope that users of phpFog see how easy to use chyrp is.

In other related news, more work has been going for getting chyrp available in instant installers. These installers include softaculous and installatron. In addition, if anyone is using dreamhost, we would greatly appreciate it if you would go to your cpanel, click where it says click here to become an app developer" and then submit Chyrp through the panel.

The other app installer that we need help with is bitnami. If everyone would consider voting at bitnami, then we may be able to get listed as a bitnami installable app as well, earning you the everlasting gratitude of the chyrp team. Thanks!

How To: Use twig

Thanks to Matt-SD MattSD.com for this tutorial, originally posted in the forums.

PART 1: BLOCKS

Open the layouts/default.twig in a theme of your choice (I'll be using stardust). Look in the head & you'll see this line:

{% block title %}$site.name{% if title %} » ${ title | escape }{% endif %}{% endblock %}

What that does the {% block title %} does is declare a block & {% endblock %} ends it (obviously) the stuff in the middle is the fallback content for that block. It's the same for {% block content %} which you'll see often.

Now, open pages/index.twig. At the top you'll see this:

{% extends "layouts/default.twig" %}

which basically says this file (index.twig) fills in the blocks from layouts/default.twig. Below that you'll see this:

{% block content %} {% for post in posts.paginated %} {% include "feathers/" ~ post.feather ~ ".twig" %} {% else %}

${ "No Posts" | translate }

${ "Nothing here yet!" | translate }

{% endfor %} {% endblock %}

what this does is fill in the content block from default.twig. You following me? The layout (default.twig) declares the blocks, & index.twig tells default.twig what's in them.

I'll continue writting this tutorial in the next post.

PART 2: VARIABLES

One variable you will use often is the $site.url variable. In PHP this would be $site['url'] or $site->url whichever tickles your fancy. What that variable outputs is the URL of your Chyrp installation. For example, if your site was located at http://example.com/blog/ then that's exactly what $site.url would output.

$site.name

Here's a list of the variables you'll most likely use

  • Theme:
    • $theme.url = the theme's directory
    • $theme.feeds = the RSS feeds associated with your blog in (uses a tag)
    • $theme.stylesheets = a for every CSS file in the stylesheets directory
    • $theme.javascripts = Same as above, but with javascripts
  • Post (obvious explanations omitted):
    • $post.feather
    • $post.id
    • $post.paginated = require the Pagination module.
      • $post.paginated.prev_link = Previous page of the paginated entry
      • $post.paginated.next_link
      • $post.paginated.pages = Number of pages
    • $post.created_at
    • $post.url
    • Text feather:
      • $post.title
      • $post.body
    • Audio:
      • $post.description
      • $post.audio_player
    • $post.dialogue = requires chat feather
    • Link:
      • $post.source = the link
      • $post.name = name for the link
      • $post.description
    • Photo:
      • ${ feathers['photo'].image_link(post, 434) } = outputs photo at a max width of 434
      • $post.caption
    • Quote:
      • $post.quote
      • $post.source = Who said it
    • Video:
      • ${ feathers['video'].embed_tag_for(post, 440) } = video player at 440 px wide
      • $post.caption
  • Flash: Don't know ANYTHING about this one
  • Trigger: See this page: https://github.com/chyrp/chyrp/wiki/Triggers-%28List%29
  • Modules: All the active modules
  • Feathers: All the active feathers
  • Title: The title of the current page or post
  • Site: (I've excluded comments for the obvious ones)
    • $site.url
    • $site.name = Your blogs title
    • $site.description
    • $site.feed_url = The URL entered in the General Settings, Feed URL box
    • $site.email
    • $site.timezone
    • $site.can_register = If users are allowed to register or not
    • $site.comments_per_page
  • Version: The version of Chyrp you are using
  • Now: the current timestamp. Equivalent to PHP's time()
  • Post: same as $_POST
  • Get: same as $_GET

Of course, there a more, but these are the one's you'll use the most. If think there's a variable that isn't listed here, just ask on the IRC channel (#chyrp on irc.freenode.net)

PART 3: FILTERS

A filter works by first getting the variable then applying the filters to it. For example, no make your blogs title capitalized, you would do this:

${ site.name | upper }

To get the current date in dd/mm/yyyy format, you'd do this:

${ "now" | date("d/m/Y") }

The Inspect filter is like PHP's print_r() or var_dump(). This would output the $site.url, $site.name, $site.description, etc:

${ site | inspect }

You can also have multiple filters. For pagination, you could do something like this:

${ "Page %d of %d" | translate | format(posts.page, posts.pages) }

which would output something like "Page 2 of 5". And because of the translate filter, you would see this: "Seite 2 von 5" if your language was set to german (from Google Translate. Sorry if it's wrong.)

For a full list of filters, & further reading on Twig, go here: https://github.com/chyrp/chyrp/wiki/Twig-Reference

- Matt-SD MattSD.com

How To: Make a module with Chyrp

Introduction

Chyrp has a really great hook and filter system that can be built upon really easily with extensions. However if you are new to php then you might have some issues looking where to start. Because of the small size of Chyrp's community every extension is valuable, so the more people that can make modules and submit to the extend section the better!

Set up

Today we are going to make a really simple lorem ipsum module that you can use to dynamically insert lorem ipsum content into your website just by writing [ipsum] in a post, really useful when designing the page layout. We are going to be using the Lorem Ipsum Api to generate the text. First and foremost is the directory structure.

ipsum
    info.yaml
    ipsum.php

This is the bare essentials of what is required to get the plugin working. We have an outer directory named ipsum, and in it a file named ipsum.php. You can name the plugin whatever you want, but these two files must be named the same. Info.yaml contains information about the plugin showed on the install screen, like the plugin name.

Info.yaml

This file is formatted according to the Yaml file format. The basics of it are pretty simple.

name: Ipsum
url: http://chyrp.net/
version: 1.0
description: Generates Lorem Ipsum content.
author:
  name: the Chyrp Team
  url: http://chyrp.net/

The name of the plugin is ipsum, and the url is a link to the plugin page, which might be a blog entry by you about making the plugin. This will be the url that a user goes to if they click on the name of the module. If you don't have a plugin page feel free just to link to chyrp.net. Version is the version of the plugin, if its 1.0 it won't be shown but if you change the version to 2.0 it will be displayed on the extend screen as v2. The description will be shown when you click the little i icon next to a module on an extend screen. Author name will be displayed next to the plugin name on the extend screen in small print, and url is the link clicking the author name will take you too. Generally this is your personal blog.

ipsum.php

This is the main deal, the part that makes your plugin tick. Lets see the full code first, and then I'll explain what it means.

addAlias("markup_text", "ipsum");//whenever the filter markup_text is run we run the function ipsum
           $this->addAlias("markup_post_text","ipsum");
           $this->addAlias("preview", "ipsum");
           $this->addAlias("preview_post", "ipsum");
        }
        public function ipsum($text) {
            return str_replace('[ipsum]', file_get_contents('http://loripsum.net/api'), $text);
        }
    }

Thats not too bad, is it? Lets get the basics out. We have an opening php symbol and then this line

class Ipsum extends Modules {

This line declares this file is a module and that it is a module with a directory of ipsum. The directory part of this, Ipsum, should always be the CamelCased name of your directory. So if your directory was cool_module this line would be

class CoolModule extends Modules {

Next we have a couple of functions, then we close the bracket started on the second line. Easy peasy right? Lets look at the two functions inside this class.

        public function __init() {
           $this->addAlias("markup_text", "ipsum");
           $this->addAlias("markup_post_text","ipsum");
           $this->addAlias("preview", "ipsum");
           $this->addAlias("preview_post", "ipsum");
        }
        public function ipsum($text) {
            return str_replace('[ipsum]', file_get_contents('http://loripsum.net/api'), $text);
        }

Note that both functions are public functions, as opposed to just plain functions. The public allows the functions to be called from external files, and is always needed.
    First, the __init function. This function is a Magic Method, which is a whole other can of worms. Just know that this function is called whenever the ipsum.php file is loaded. In this function we are adding aliases, which basically means that whenever the a certain filter is called we run a function. The name of the filter is specified by the item in the parentheses before the comma, the function what after the comma. In this instance we are adding several aliases. Whenever the post is previewed, shown from a list of posts, or shown individually we run the function ipsum, which coincidentally is the name of our second function. The function that you specify from an alias should always exist in the same file, and should be a public function.
    The ipsum function accepts an argument - $text. This value is the content of the post that is being viewed. We need to check if $text has [ipsum] in it, and if so replace the [ipsum] with some randomly generated text and return the modified text, which is basically what we do in the next line. The return of the modified text is REQUIRED. If you don't return a value, all your posts will show up blank. So what exactly are we returning? First, we get the content from http://loripsum.net/api using file_get_contents. This page will automatically generate the content for us, so we just need to grab what it feeds us. To add in the ipsum, we do a str_replace on the post. What the str_replace does is if it finds [ipsum] in the post content ($text) then replace it with what we get from http://loripsum.net/api. If [ipsum] isn't found, then what we return is the same as what we get.
Thats it! Hope this was useful! If you make a module we'd love if you submit it to our extend section for others to use.

Feel free to download the module if you need an example.

Chyrp at Software Freedom Kosova 2011 Conference

Couple of days back, it was publicly announced on Twitter and Facebook that I will be talking about Chyrp at the Software Freedom Kosova 2011 event. I know I should have officially announced that with a blog post here, since it was totally worth it, I guess I must have been too excited and didn't really pay the necessary attention of doing that.

On that regard, however, I'm quickly sharing the slides that I used for introducing Chyrp to an audience of about 300 people, while hoping that I will publish the video material, once I get it from the organizers of the conference. Until then, have fun and enjoy navigating through the slides, and leave your feedback in the comments.