Skip to content

Commit

Permalink
Initial project commit.
Browse files Browse the repository at this point in the history
Based on https://github.com/mvriel/joind.in-experimental, with additional Joind.in API class and autoloader (and added documentation)
  • Loading branch information
Clair committed Jan 19, 2013
1 parent 99fb7d0 commit 632b83a
Show file tree
Hide file tree
Showing 840 changed files with 57,187 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .gitignore
@@ -0,0 +1,10 @@
.idea/.name
.idea/codeStyleSettings.xml
.idea/encodings.xml
.idea/joind.in-responsive.iml
.idea/misc.xml
.idea/modules.xml
.idea/vcs.xml
.idea/workspace.xml
.idea/libraries/sass_stdlib.xml
.idea/scopes/scope_settings.xml
25 changes: 25 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,25 @@
# CONTRIBUTING

## RESOURCES

If you wish to contribute to joind.in, please be sure to
read/subscribe to the following resources:

- Contributor's Guide:
https://github.com/joindin/joind.in/wiki/How-to-Contribute-Code
- Contributor's mailing list:
http://groups.google.com/group/joindin-developers
- Contributor's IRC channel:
#joind.in on Freenode.net

## What to work on

You should work on what you want to. Our bug tracker is
here: https://joindin.jira.com

Any issues that have the "hackathon" or "easypick" label are ones that we think
are a good starting point. This [JIRA filter](https://joindin.jira.com/issues/?jql=project%20%3D%20JOINDIN%20AND%20labels%20in%20(hackathon%2C%20%22OR%22%2C%20easypick)) will give you the list of all
current issues with the "hackathon" or "easypick" issues.

If you have any problems, ask on the IRC channel or send an email to
the mailing list.
32 changes: 32 additions & 0 deletions Controller/Application.php
@@ -0,0 +1,32 @@
<?php
namespace Joindin\Controller;

class Application extends Base
{
protected function defineRoutes(\Slim $app)
{
$app->get('/', array($this, 'index'));
$app->get('/oauth/callback', array($this, 'oauth_callback'));
}

public function index()
{
$event_collection = new \Joindin\Model\Collection\Event();
$hot_events = $event_collection->retrieve(5, 1, 'hot');
$upcoming_events = $event_collection->retrieve(5, 1, 'upcoming');

echo $this->application->render(
'Application/index.html.twig',
array(
'hot_events' => $hot_events,
'upcoming_events' => $upcoming_events
)
);
}

public function oauth_callback()
{
$_SESSION['access_token'] = $this->application->request()->params('access_token');
$this->application->redirect('/');
}
}
16 changes: 16 additions & 0 deletions Controller/Base.php
@@ -0,0 +1,16 @@
<?php
namespace Joindin\Controller;

abstract class Base
{
/** @var \Slim */
protected $application = null;

function __construct(\Slim $app)
{
$this->application = $app;
$this->defineRoutes($app);
}

abstract protected function defineRoutes(\Slim $app);
}
34 changes: 34 additions & 0 deletions Controller/Event.php
@@ -0,0 +1,34 @@
<?php
namespace Joindin\Controller;

class Event extends Base
{
protected function defineRoutes(\Slim $app)
{
$app->get('/event', array($this, 'index'));
$app->get('/event/view/:id', array($this, 'show'));

}

public function index()
{
$event = new \Joindin\Model\Collection\Event();
$result = $event->retrieve(10, 1, 'hot');

echo $this->application->render(
'Event/index.html.twig',
array('events' => $result)
);
}

public function show($id)
{
$event = new \Joindin\Model\Event();
$event->load($id);

echo $this->application->render(
'Event/show.html.twig',
array('event' => $event)
);
}
}
18 changes: 18 additions & 0 deletions Model/API/JoindIn.php
@@ -0,0 +1,18 @@
<?php
namespace Joindin\Model\API;

class JoindIn
{
protected $baseApiUrl = 'http://api.joind.in';

protected function apiGet($url)
{
$result = file_get_contents($url);

if (false === $result) {
throw new \Exception('Unable to connect to API');
}

return $result;
}
}
23 changes: 23 additions & 0 deletions Model/Collection/Event.php
@@ -0,0 +1,23 @@
<?php
namespace Joindin\Model\Collection;

class Event extends \Joindin\Model\API\JoindIn
{
public function retrieve($limit = 10, $page = 1, $filter = null)
{
$url = $this->baseApiUrl.'/v2.1/events'
.'?resultsperpage='.$limit
.'&page='.$page;
if ($filter) {
$url .= '&filter='.$filter;
}

$events = (array)json_decode(
$this->apiGet($url)
);
$meta = array_pop($events);

return $events['events'];
}

}
42 changes: 42 additions & 0 deletions Model/Event.php
@@ -0,0 +1,42 @@
<?php
namespace Joindin\Model;

/**
* @property string $name
* @property string $start_date
* @property string $end_date
* @property string $description
* @property string $href
* @property string $attendee_count
* @property string $icon
* @property string $latitude
* @property string $longitude
* @property string $tz_continent
* @property string $tz_place
* @property string $location
* @property string $comments_enabled
* @property string $event_comment_count
* @property string $cfp_start_date
* @property string $cfp_end_date
*/
class Event extends \Joindin\Model\API\JoindIn
{
public function load($id)
{
$event = current(current((array)json_decode(
$this->apiGet(
$this->baseApiUrl
.'/v2.1/events/'.$id.'?format=json&verbose=yes'
)
)));

$event->comments = current((array)json_decode(
$this->apiGet($event->comments_uri))
);

// import properties
foreach($event as $key => $value) {
$this->$key = $value;
}
}
}
141 changes: 138 additions & 3 deletions README.md
@@ -1,4 +1,139 @@
responsive
==========
# Joind.in

This is the source code for the next generation of the Joind.in website - a resource set up to allow
events to get real-time feedback from those attending. It also gives speakers a
way to claim and track their presentations over time.

This version is the next generation version, providing a responsive cross-device site for screens of all devices

You can either install joind.in on an existing PHP platform, or use our vagrant setup.

## Quick Start - Using Vagrant

You can set up a development virtual machine running joind.in by following these simple instructions.

1. Install requirements. (Note: these are not required by joind.in itself, but are required for this quick start guide.)
- VirtualBox (https://www.virtualbox.org/) (versions 4.0 and 4.1 are currently supported)
- Ruby (http://www.ruby-lang.org/)
- Vagrant (http://vagrantup.com/)

2. Clone repository to any location and fetch required submodules (containing Puppet manifests).

git clone https://github.com/joindin/responsive --recursive
cd joind.in

or

git clone https://github.com/joindin/responsive && cd joind.in
git submodule init
git submodule update

3. Start the process by running Vagrant.

vagrant up

4. Add hostname to /etc/hosts.

echo "127.0.0.1 responsive.dev.joind.in" | sudo tee -a /etc/hosts

5. Browse to the newly provisioned development copy of joind.in.

open http://responsive.dev.joind.in:8080

*Notes:*

- HTTP and SSH ports on the VM are forwarded to localhost (22 -> 2222, 80 -> 8080)
- The joind.in directory you cloned will be mounted inside the VM at `/vagrant`
- You can develop by editing the files you cloned in the IDE of you choice.
- The database is running inside the VM. You can get to it by doing the following:

you@you> vagrant ssh
vagrant@vm> sudo su
root@vm> mysql joindin

- To stop the VM do one of the following:
`vagrant suspend` if you plan on running it later
`vagrant destroy` if you wish to delete the VM completely

- Also, when any of of the Puppet manifests change, it is a good idea to rerun them:

vagrant provision

## Quick Start - Existing Platforms

1. Create a vhost entry for the site. The docroot should be `/web`.

<VirtualHost *:80>
ServerName joindin.local

DocumentRoot "/home/exampleuser/www/joind.in/web"

<Directory "/home/exampleuser/www/joind.in">
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>

2. Create a MySQL database with username and password.
Use a database name of 'joindin'

3. Initialise, patch, and populate the database.

src/scripts/patchdb.sh -t /path/to/joind.in -d joindin -u username -p password -i

(use the correct username and password)

4. Create directories for user-added content.

mkdir src/system/cache/ctokens && chown apache:apache src/system/cache/ctokens

(or whatever user and group your web server runs as)

5. Create configuration files for database and config (based on the .dist templates):

cp src/system/application/config/database.php.dist src/system/application/config/database.php
cp src/system/application/config/config.php.dist src/system/application/config/config.php

Edit these files as appropriate!

6. Create some sample data to get you started - see `/doc/dbgen/README` for information about this excellent tool

7. To enable useful error messages, add the following to your `.htaccess`

SetEnv JOINDIN_DEBUG On
8. Enjoy the site!

## Other Resources

* The main website http://joind.in
* Issues list: http://joindin.jira.com/ (good bug reports ALWAYS welcome!)
* CI Environment: lots of output and information about tests, deploys etc: http://jenkins.joind.in
* Community: We hang out on IRC, pop in with questions or comments! #joind.in on Freenode

See LICENSE file for license information for this software
(located in /doc/LICENSE)

## Extensions

### API Tests

To run the frisby tests (frisby.js), you will first need to install node.js and
npm. Then run:

npm install -g frisby jasmine-node

I also found that I needed:

export NODE_PATH=/usr/local/lib/node_modules

Then run the tests by going to `/src/tests/api_tests` and running:

jasmine-node newapi_spec.js

### Unit Tests

There are some tests set up, which use PHPUnit; these can be found in the
src/tests directory. There is a phing task configured to run them - from the
root directory simply run "phing phpunit" to run the tests.

Next generation website for joind.in
45 changes: 45 additions & 0 deletions Vendor/Slim/Exception/Pass.php
@@ -0,0 +1,45 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@joshlockhart.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 1.5.0
*
* MIT LICENSE
*
* 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.
*/

/**
* Pass Exception
*
* This Exception will cause the Router::dispatch method
* to skip the current matching route and continue to the next
* matching route. If no subsequent routes are found, a
* HTTP 404 Not Found response will be sent to the client.
*
* @package Slim
* @author Josh Lockhart <info@joshlockhart.com>
* @since Version 1.0
*/
class Slim_Exception_Pass extends Exception {}

0 comments on commit 632b83a

Please sign in to comment.