Permalink
Browse files

first pass at phpmongotweet app:

  • Loading branch information...
dblado committed Dec 5, 2011
0 parents commit 066b891055226892b8b3b2d4b76d525875a5f453
@@ -0,0 +1,5 @@
+#!/bin/bash
+# This is a simple build script and will be executed on your CI system if
+# available. Otherwise it will execute while your application is stopped
+# before the deploy step. This script gets executed directly, so it
+# could be python, php, ruby, etc.
@@ -0,0 +1,5 @@
+#!/bin/bash
+# This deploy hook gets executed after dependencies are resolved and the
+# build hook has been run but before the application has been started back
+# up again. This script gets executed directly, so it could be python, php,
+# ruby, etc.
@@ -0,0 +1,4 @@
+#!/bin/bash
+# This is a simple post deploy hook executed after your application
+# is deployed and started. This script gets executed directly, so
+# it could be python, php, ruby, etc.
@@ -0,0 +1,5 @@
+#!/bin/bash
+# This is a simple script and will be executed on your CI system if
+# available. Otherwise it will execute while your application is stopped
+# before the build step. This script gets executed directly, so it
+# could be python, php, ruby, etc.
@@ -0,0 +1,7 @@
+Markers
+===========
+
+Adding marker files to this directory will have the following effects:
+
+force_clean_build - Will remove all previous php pears and start installing
+ required pears from scratch
58 README
@@ -0,0 +1,58 @@
+Feel free to change or remove this file, it is informational only.
+
+Repo layout
+===========
+php/ - Externally exposed php code goes here
+libs/ - Additional libraries
+misc/ - For not-externally exposed php code
+../data - For persistent data (full path in environment var: OPENSHIFT_DATA_DIR)
+deplist.txt - list of pears to install
+.openshift/action_hooks/pre_build - Script that gets run every git push before the build
+.openshift/action_hooks/build - Script that gets run every git push as part of the build process (on the CI system if available)
+.openshift/action_hooks/deploy - Script that gets run every git push after build but before the app is restarted
+.openshift/action_hooks/post_deploy - Script that gets run every git push after the app is restarted
+
+
+Notes about layout
+==================
+Please leave php, libs and data directories but feel free to create additional
+directories if needed.
+
+Note: Every time you push, everything in your remote repo dir gets recreated
+please store long term items (like an sqlite database) in ../data which will
+persist between pushes of your repo.
+
+
+Environment Variables
+=====================
+
+OpenShift Express provides several environment variables to reference for ease
+of use. The following list are some common variables but far from exhaustive:
+
+ $_ENV['OPENSHIFT_APP_NAME'] - Application name
+ $_ENV['OPENSHIFT_APP_DIR'] - Application dir
+ $_ENV['OPENSHIFT_DATA_DIR'] - For persistent storage (between pushes)
+ $_ENV['OPENSHIFT_TMP_DIR'] - Temp storage (unmodified files deleted after 10 days)
+
+When embedding a database using rhc-ctl-app, you can reference environment
+variables for username, host and password:
+
+ $_ENV['OPENSHIFT_DB_HOST'] - DB host
+ $_ENV['OPENSHIFT_DB_PORT'] - DB Port
+ $_ENV['OPENSHIFT_DB_USERNAME'] - DB Username
+ $_ENV['OPENSHIFT_DB_PASSWORD'] - DB Password
+
+To get a full list of environment variables, simply add a line in your
+.openshift/action_hooks/build script that says "export" and push.
+
+deplist.txt
+===========
+
+A list of pears to install, line by line on the server. This will happen when
+the user git pushes.
+
+
+Additional information
+======================
+
+Link to additional information will be here, when we have it :)
@@ -0,0 +1,44 @@
+PHPMongoTweet on OpenShift Express
+==================================
+
+This git repository helps you get up and running quickly w/ a PHP sample application
+that uses MongoDB on OpenShift Express
+
+Running on OpenShift
+--------------------
+
+Create an account at http://openshift.redhat.com/
+
+Create a php-5.3 application
+
+ rhc-create-app -a phpmongotweet -t php-5.3
+
+Add MongoDB support to your application
+
+ rhc-ctl-app -a phpmongotweet -e add-mongodb-2.0
+
+Add this upstream phpmongotweet repo
+
+ cd phpmongotweet
+ git remote add upstream -m master git://github.com/openshift/phpmongotweet-example.git
+ git pull -s recursive -X theirs upstream master
+
+
+Then push the repo upstream
+
+ git push
+
+That's it, you can now checkout your application at:
+ http://phpmongotweet-$yourlogin.rhcloud.com
+
+
+Repo layout
+-----------
+
+php/ - Externally exposed php code goes here
+libs/ - Additional libraries
+misc/ - For not-externally exposed php code
+../data - For persistent data
+deplist.txt - list of pears to install
+.openshift/action_hooks/* - Scripts that execute with every push
+
No changes.
No changes.
No changes.
@@ -0,0 +1,57 @@
+<?php
+
+ define("OPENSHIFT_DB", "phpmongotweet");
+ define("TWEETS_COLLECTION", "tweets");
+
+ function is_option_set($opts) {
+ foreach ($opts as $k => $v) {
+ if (true == isset($_GET[$v]) ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ function get_option_value($opts) {
+ foreach ($opts as $k => $v) {
+ if (true == isset($_GET[$v]) ) {
+ return $_GET[$v];
+ }
+ }
+
+ return NULL;
+ }
+
+ function convertToArray($zobject) {
+ if (is_object($zobject) )
+ return get_object_vars($zobject);
+ else if (is_array($zobject) )
+ /* Convert to object using __FUNCTION__ for recursive call. */
+ return array_map(__FUNCTION__, $zobject);
+ else
+ return $zobject;
+ }
+
+
+ function get_db_connection() {
+ $host = $_ENV["OPENSHIFT_NOSQL_DB_HOST"];
+ $user = $_ENV["OPENSHIFT_NOSQL_DB_USERNAME"];
+ $passwd = $_ENV["OPENSHIFT_NOSQL_DB_PASSWORD"];
+
+ $uri = "mongodb://" . $user . ":" . $passwd . "@" . $host;
+ $mongo = new Mongo($uri);
+ return $mongo;
+ }
+
+ function get_database($dbname) {
+ $conn = get_db_connection();
+ return $conn->$dbname;
+ }
+
+ function get_collection($collection) {
+ $db = get_database(OPENSHIFT_DB);
+ return $db->$collection;
+ }
+
+?>
@@ -0,0 +1,192 @@
+body {
+ background: #E6EAE9;
+ color: #4F6B70;
+ font: normal 10px auto "Trebuchet MS", Verdana, Helvetica, sans-serif;
+}
+
+.toolTip {
+ left : 100px;
+ position: relative;
+ top: 100px;
+ width: 600px;
+}
+
+.highlight {
+ background-color: #FDDC80 !important;
+}
+
+a {
+ color: #C75F3E;
+}
+
+#contentdiv {
+ margin: 20 auto;
+ text-align: left;
+}
+
+.floaterdiv {
+ float: left;
+ margin-right: 40px;
+}
+
+#clearalignment {
+ clear: left;
+}
+
+caption {
+ font: italic 11px "Trebuchet MS", Verdana, Helvetica, sans-serif;
+ padding: 0 0 5px 0;
+ text-align: right;
+ width: 900px;
+}
+
+#twtable {
+ margin: 0;
+ padding: 6px 6px 6px 20px;
+ width: 900px;
+}
+
+#trendtable {
+ border: 0px solid;
+ margin: 0;
+ padding: 6px 6px 6px 20px;
+}
+
+th {
+ background: #CAE8EA url(../images/bg_header.jpg) no-repeat;
+ border-bottom: 1px solid #C1DAD7;
+ border-right: 1px solid #C1DAD7;
+ border-top: 1px solid #C1DAD7;
+ color: #4F6B70;
+ font: bold 11px "Trebuchet MS", Verdana, Helvetica, sans-serif;
+ letter-spacing: 2px;
+ padding: 6px 6px 6px 12px;
+ text-align: left;
+}
+
+th.nobackground {
+ background: none;
+ border-left: 0;
+ border-right: 1px solid #C1DAD7;
+ border-top: 0;
+}
+
+td {
+ background: #FFFFFF;
+ border-bottom: 1px solid #C1DAD7;
+ border-right: 1px solid #C1DAD7;
+ color: #4F6B70;
+ padding: 6px 6px 6px 12px;
+}
+
+td.when, td.trend {
+ background: #FFFFFF url(../images/bullet2.gif) no-repeat;
+ border-left: 1px solid #C1DAD7;
+ border-top: 0;
+ font-size: 0.75em;
+}
+
+td.searchtag {
+ font-size: 0.8em;
+}
+
+td.who {
+ background: #FFFFFF;
+ border-left: 1px solid #C1DAD7;
+ border-top: 0;
+ font-color: #797268;
+ font-size: 0.9em;
+}
+
+td.username {
+ font-color: #797268;
+ font-size: 0.8em;
+}
+
+td.tweet {
+ background: #F5FAFA;
+ color: #797268;
+}
+
+p.hint {
+ color: #669900;
+ font: normal 10px auto "Trebuchet MS", Verdana, Helvetica, sans-serif;
+}
+
+/* loader bits. */
+#wip {
+ font: normal 10px auto Verdana;
+ text-align: left; margin:0;
+ padding: 10px 10px 5px 35px;
+ margin-left: 85px;
+}
+
+#loaddiv {
+ margin: 20px;
+}
+
+#q {
+ background: #FFFFFF;
+ border: solid 1px #D9D9D9;
+ border-top: solid 1px #C0C0C0;
+ border-right: none;
+ color: #333333;
+ float: left;
+ font-family: Arial, sans-serif;
+ font-size: 1em;
+ height: 27px;
+ line-height: 27px;
+ margin-left: 25px;
+ text-indent: 10px;
+ width: 300px;
+}
+
+#delete {
+ background: #FFFFFF;
+ border: solid 1px #D9D9D9;
+ border-left: none;
+ border-top: solid 1px #C0C0C0;
+ float: left;
+ font-family: "Lucida Sans", "Lucida Sans Unicode",sans-serif;
+ font-size: 22px;
+ height: 29px;
+ line-height: 27px;
+ margin-right: 15px;
+ padding: 0 10px 0 10px;
+ width: 16px;
+}
+
+#delete #x {
+ color: #A1B9ED;
+ cursor: pointer;
+ display: none;
+}
+
+#delete #x:hover {
+ color: #36c;
+}
+
+#submit {
+ background: url(../images/load.png) no-repeat #4D90FE center;
+ border: 1px solid #3079ED;
+ color: transparent;
+ cursor: pointer;
+ font-size: 0;
+ height: 31px;
+ line-height: 0;
+ text-indent: -999px;
+ width: 70px;
+ -moz-border-radius: 2px;
+ -webkit-border-radius: 2px;
+}
+
+#submit:hover {
+ background: url(../images/load.png) no-repeat center #357AE8;
+ border: 1px solid #2F5BB7;
+}
+
+.fclear {
+ clear:both
+}
+
+
Oops, something went wrong.

0 comments on commit 066b891

Please sign in to comment.