Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuzee committed Dec 27, 2014
0 parents commit 63d1293
Show file tree
Hide file tree
Showing 162 changed files with 31,514 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
app/tmp
app/reports
*.un~
.elasticbeanstalk
.elasticbeanstalk/
Plugin
Vendor
work
5 changes: 5 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Ryutaro YOSHIBA

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.
99 changes: 99 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Open Slideshare

This is simple open source slidesharing application. You can see the working demo at http://slide.meguro.ryuzee.com/

![Sample](https://gist.github.com/ryuzee/7b02a2a1026b57614835/raw/31d991a88532331bf7e55af4ba05ba8b6fad9dc8/openslideshare.png")

## Requirements

This application depends on following technologies.

- Amazon S3
- Amazon SQS
- Ubuntu 12 or higher with OpenOffice, xpdf, unoconv and so on

## Install

- Create two Amazon S3 buckets (cf. open-slideshare-slides, open-slideshare-images)
- Set CORS policy for bucket that will store the slide decks as follows

```
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
<ExposeHeader>Access-Control-Allow-Origin</ExposeHeader>
<MaxAgeSeconds>3000</MaxAgeSeconds>
</CORSRule>
</CORSConfiguration>
```

- Create SQS queue (cf. open-slideshare-convert) and note the url.
- Create database and its user (all tables will be created by Migration function).
- Install required php library by using composer as follows.

```
php composer.phar install
```

- Change permissions as follows

```
chmod -R 777 app/tmp
chmod 755 app/Console/cake
```

- Configure application.

This application uses Amazon S3 and SQS. You need to configure options. If you use environment variables, there's no need to change configuration of this file.

`app/Config/const.php`

```
$config['region'] = $_SERVER['REGION'];
$config['bucket_name'] = $_SERVER['BUCKET_NAME'];
$config['image_bucket_name'] = $_SERVER['IMAGE_BUCKET_NAME'];
$config['sqs_url'] = $_SERVER['SQS_URL'];
```

`app/Config/database.php`

For database connection, you need to change configuration if you do not use environment variables that start with `RDS_`.

```
if (!defined('DB_HOSTNAME')) {
$db_hostname = isset($_SERVER['RDS_HOSTNAME']) ? $_SERVER['RDS_HOSTNAME'] : "localhost";
define('DB_HOSTNAME', $db_hostname);
$db_username = isset($_SERVER['RDS_USERNAME']) ? $_SERVER['RDS_USERNAME'] : "webapp";
define('DB_USERNAME', $db_username);
$db_password = isset($_SERVER['RDS_PASSWORD']) ? $_SERVER['RDS_PASSWORD'] : "passw0rd";
define('DB_PASSWORD', $db_password);
$db_name = isset($_SERVER['RDS_DB_NAME']) ? $_SERVER['RDS_DB_NAME'] : "openslideshare";
define('DB_NAME', $db_name);
}
```

- Run migration tool to create tables.

```
app/Console/cake Migrations.migration run all
app/Console/cake Migrations.migration run all -p Tags
```

- Now you can login to the application by admin@example.com / passw0rd. After your first login, you must change your password.

## This application on Amazon EC2

- If you want to run the application on Amazon EC2 instance, you need to assign IAM Role to the instance when launching.

## License

This software is released under the MIT License, see LICENSE.txt.
5 changes: 5 additions & 0 deletions app/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
62 changes: 62 additions & 0 deletions app/Config/Migration/1400000000_create_tables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
class CreatePosts extends CakeMigration
{
/**
* Migration description
*
* @var string
*/
public $description = '';

/**
* Actions to be performed
*
* @var array $migration
*/
public $migration = array(
'up' => array(
'create_table' => array(
'users' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
'username' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => '32'),
'display_name' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => '128'),
'password' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => '255'),
'disabled' => array('type' => 'boolean', 'default' => false),
'created' => array('type' => 'datetime', 'null' => false, 'default' => null),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => true),
'idx_username_ukey' => array('column' => 'username', 'unique' => true),
),
),
),
),
'down' => array(
'drop_table' => array(
'users',
),
),
);

/**
* Before migration callback
*
* @param string $direction, up or down direction of migration process
* @return boolean Should process continue
*/
public function before($direction)
{
return true;
}

/**
* After migration callback
*
* @param string $direction, up or down direction of migration process
* @return boolean Should process continue
*/
public function after($direction)
{
return true;
}
}
61 changes: 61 additions & 0 deletions app/Config/Migration/1418187521_add_dummy_data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
class AddDummyData extends CakeMigration
{
/**
* Migration description
*
* @var string
*/
public $description = 'add_dummy_data';

/**
* Actions to be performed
*
* @var array $migration
*/
public $migration = array(
'up' => array(
),
'down' => array(
),
);

/**
* Before migration callback
*
* @param string $direction Direction of migration process (up or down)
* @return bool Should process continue
*/
public function before($direction)
{
return true;
}

/**
* After migration callback
*
* @param string $direction Direction of migration process (up or down)
* @return bool Should process continue
*/
public function after($direction)
{
// User data
$User = ClassRegistry::init('User');
if ($direction === 'up') {
// add admin account to user table
$data['User']['username'] = 'admin@example.com';
$data['User']['password'] = 'passw0rd';
$data['User']['display_name'] = 'Admin';

$User->create();
if ($User->save($data)) {
$this->callback->out('User data was created...');
} else {
echo "User data creation failed......";
}
} elseif ($direction === 'down') {
// do more work here
}
return true;
}
}
68 changes: 68 additions & 0 deletions app/Config/Migration/1418444125_add_slides.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
class AddSlide extends CakeMigration
{
/**
* Migration description
*
* @var string
*/
public $description = 'add_slide';

/**
* Actions to be performed
*
* @var array $migration
*/
public $migration = array(
'up' => array(
'create_table' => array(
'categories' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
'name' => array('type' => 'string', 'length' => 255, 'null' => false, 'default' => null),
),
'slides' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
'user_id' => array('type' => 'integer', 'null' => false, 'default' => null),
'name' => array('type' => 'string', 'length' => 255, 'null' => false, 'default' => null),
'description' => array('type' => 'text', 'null' => false, 'default' => null),
'category_id' => array('type' => 'integer', 'null' => false, 'default' => null),
'publish' => array('type' => 'boolean', 'null' => false, 'default' => false),
'created' => array('type' => 'datetime', 'null' => false, 'default' => null),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => null),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => true),
'idx_slides_user_id_key' => array('column' => 'user_id', 'unique' => false),
'idx_slides_category_id_key' => array('column' => 'category_id', 'unique' => false),
),
),
),
),
'down' => array(
'drop_table' => array(
'categories', 'slides'
),
),
);

/**
* Before migration callback
*
* @param string $direction Direction of migration process (up or down)
* @return bool Should process continue
*/
public function before($direction)
{
return true;
}

/**
* After migration callback
*
* @param string $direction Direction of migration process (up or down)
* @return bool Should process continue
*/
public function after($direction)
{
return true;
}
}

0 comments on commit 63d1293

Please sign in to comment.