Skip to content

gRegorLove/mf2-to-iCalendar

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

mf2-to-iCalendar

Convert microformats h-event to iCalendar.

Note: This is currently very much an alpha version, doing the minimal amount I needed it to do. I plan to expand it, though. Issue reports are welcomed.

Requirements

Installation

It is recommended to install via Composer. This project is not listed on packagist yet, but will be once it's more stable. Until then, you can install by adding to your composer.json:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/gRegorLove/mf2-to-iCalendar"
        }
    ],
    "require": {
        "gregorlove/mf2-to-icalendar": "dev-master"
    }
}

Then in the project file you want to use it, import the namespace and add the Composer autoloader:

use GregorMorrill\Mf2toiCal;

require_once 'vendor/autoload.php';

Manual Installation

Alternately, you can manually install without using Composer.

You will need to first download the php-mf2 and php-mf-cleaner libraries linked above and include them in your project.

Then download the files in this project's directory src/GregorMorrill/Mf2toiCal/ and include them directly in your project:

use GregorMorrill\Mf2toiCal;

require_once 'src/GregorMorrill/Mf2toiCal/Mf2toiCal.php';
require_once 'src/GregorMorrill/Mf2toiCal/functions.php';

Specify the Domain

The generated iCalendar .ics file has a PRODID that includes a domain and the name/version of this script.

It's recommended to specify the domain you're using this on. If you don't, it will default to example.com.

To specify your domain, after installation define the constant:

define('PRODID_DOMAIN', 'example.com');

Usage

Mf2toiCal\convert('https://example.com/event');

Language and Character Set

This script defaults to language en and charset utf-8 for text content lines in the generated .ics file. You can specify different options when calling convert():

# parameters: $url, $lang, $charset
Mf2toiCal\convert('https://example.com/event', 'sv');

Detecting the language from the HTML and using that is on my TODO list.

Changelog

0.0.3

2020-12-23

  • No longer throws an Exception if no h-event microformats found when converting. Instead will generate an "empty" iCalendar.
  • Changed default domain to example.com

0.0.2

2018-03-29

  • Now prefers content h-event property over description
  • Adds support for dates with local time
  • Adds unit tests

0.0.1

2017-07-27

  • initial release

About

Convert microformats h-event to iCalendar

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages