Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Welch <andrew@nystudio107.com>
  • Loading branch information
khalwat committed Nov 15, 2018
0 parents commit b486fb2
Show file tree
Hide file tree
Showing 13 changed files with 537 additions and 0 deletions.
1 change: 1 addition & 0 deletions .craftplugin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"pluginName":"iCalendar","pluginDescription":"Ensures that text conforms to the RFC 2445 iCalendar specification","pluginVersion":"1.0.0","pluginAuthorName":"nystudio107","pluginVendorName":"nystudio107","pluginAuthorUrl":"https://nystudio107.com","pluginAuthorGithub":"nystudio107","codeComments":"","pluginComponents":["services","twigextensions","variables"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"Convert","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# CRAFT ENVIRONMENT
.env.php
.env.sh
.env

# COMPOSER
/vendor

# BUILD FILES
/bower_components/*
/node_modules/*
/build/*
/yarn-error.log

# MISC FILES
.cache
.DS_Store
.idea
.project
.settings
*.esproj
*.sublime-workspace
*.sublime-project
*.tmproj
*.tmproject
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
config.codekit3
prepros-6.config
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# iCalendar Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.0.0 - 2018-11-14
### Added
- Initial release
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2018 nystudio107

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
103 changes: 103 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# iCalendar plugin for Craft CMS 3.x

Ensures that text conforms to the RFC 2445 iCalendar specification

## Requirements

This plugin requires Craft CMS 3.0.0 or later.

## Installation

To install the plugin, follow these instructions.

1. Open your terminal and go to your Craft project:

cd /path/to/project

2. Then tell Composer to load the plugin:

composer require nystudio107/craft-icalendar

3. In the Control Panel, go to Settings → Plugins and click the “Install” button for iCalendar.

Or you can just install the plugin via the Craft CMS Plugin Store in the AdminCP

## iCalendar Overview

iCalendar ensures that text conforms to the RFC 2445 [iCalendar specification](https://icalendar.org/) for `.ics` files. Specifically, it transforms text:

* to ensure the line endings are `\r\n` as opposed to Twig's default `\n`
* wrap long text to ensure that it is no more than 75 octets in length
* removes unnecessary whitespace
* strips all HTML tags from the text

## Configuring iCalendar

There's nothing to configure.

## Using iCalendar

To use iCalendar, just wrap your Twig code that outputs your iCalendar RFC 2445 text like so:

```twig
{% filter rfc2445 %}
BEGIN:VCALENDAR
PRODID:Camden Open House
CALSCALE:GREGORIAN
VERSION:2.0
METHOD:PUBLISH
TRANSP:TRANSPARENT
X-WR-CALNAME:Camden Open House
X-WR-TIMEZONE:America/New_York
BEGIN:VEVENT
UID:1119
DTSTAMP:20181201T120101Z
DTSTART:20181201T120101Z
DTEND:20181108T120101Z
LOCATION:On Campus Camden, SC
SUMMARY:OPEN HOUSE (ON CAMPUS) FOR PROSPECTIVE FAMILIES/CADETS
DESCRIPTION:This is a <strong>very long description</strong>, too long to fit inside of 75 octets, certainly! An on campus open house will be held on Saturday, December 1 2018 at 7pm.
URL:test
END:VEVENT
END:VCALENDAR
{% endfilter %}
```

This will output:
```
BEGIN:VCALENDAR
PRODID:Camden Open House
CALSCALE:GREGORIAN
VERSION:2.0
METHOD:PUBLISH
TRANSP:TRANSPARENT
X-WR-CALNAME:Camden Open House
X-WR-TIMEZONE:America/New_York
BEGIN:VEVENT
UID:1119
DTSTAMP:20181201T120101Z
DTSTART:20181201T120101Z
DTEND:20181108T120101Z
LOCATION:On Campus Camden, SC
SUMMARY:OPEN HOUSE (ON CAMPUS) FOR PROSPECTIVE FAMILIES/CADETS
DESCRIPTION:This is a very long description, too long to fit inside of 75 o
ctets, certainly! An on campus open house will be held on Saturday, Decemb
er 1 2018 at 7pm.
URL:test
END:VEVENT
END:VCALENDAR
```

Note that HTML code and whitespace have been stripped, and long lines have been wrapped. What you can't see is that the line endings are `\r\n` as per spec, as opposed to Twig's `\n` line ending.

You can put whatever Twig code you want inside of the filter to output your entries.

You can validate your `.ics` files using the [iCalendar validator](https://icalendar.org/validator.html)

## iCalendar Roadmap

Some things to do, and ideas for potential features:

* Release it

Brought to you by [nystudio107](https://nystudio107.com)
43 changes: 43 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "nystudio107/craft-icalendar",
"description": "Ensures that text conforms to the RFC 2445 iCalendar specification",
"type": "craft-plugin",
"version": "1.0.0",
"keywords": [
"craft",
"cms",
"craftcms",
"craft-plugin",
"icalendar"
],
"support": {
"docs": "https://github.com/nystudio107/craft-icalendar/blob/master/README.md",
"issues": "https://github.com/nystudio107/craft-icalendar/issues"
},
"license": "MIT",
"authors": [
{
"name": "nystudio107",
"homepage": "https://nystudio107.com"
}
],
"require": {
"craftcms/cms": "^3.0.0"
},
"autoload": {
"psr-4": {
"nystudio107\\icalendar\\": "src/"
}
},
"extra": {
"name": "iCalendar",
"handle": "icalendar",
"hasCpSettings": false,
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/nystudio107/craft-icalendar/master/CHANGELOG.md",
"components": {
"convert": "nystudio107\\icalendar\\services\\Convert"
},
"class": "nystudio107\\icalendar\\ICalendar"
}
}
Binary file added resources/img/plugin-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions src/ICalendar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/**
* iCalendar plugin for Craft CMS 3.x
*
* Ensures that text conforms to the RFC 2445 iCalendar specification
*
* @link https://nystudio107.com
* @copyright Copyright (c) 2018 nystudio107
*/

namespace nystudio107\icalendar;

use nystudio107\icalendar\services\Convert as ConvertService;
use nystudio107\icalendar\twigextensions\ICalendarTwigExtension;

use Craft;
use craft\base\Plugin;

/**
* Class ICalendar
*
* @author nystudio107
* @package ICalendar
* @since 1.0.0
*
* @property ConvertService $convert
*/
class ICalendar extends Plugin
{
// Static Properties
// =========================================================================

/**
* @var ICalendar
*/
public static $plugin;

// Public Properties
// =========================================================================

/**
* @var string
*/
public $schemaVersion = '1.0.0';

// Public Methods
// =========================================================================

/**
* @inheritdoc
*/
public function init()
{
parent::init();
self::$plugin = $this;

Craft::$app->view->registerTwigExtension(new ICalendarTwigExtension());

Craft::info(
Craft::t(
'icalendar',
'{name} plugin loaded',
['name' => $this->name]
),
__METHOD__
);
}

// Protected Methods
// =========================================================================
}
52 changes: 52 additions & 0 deletions src/icon-mask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions src/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b486fb2

Please sign in to comment.