Merge remote-tracking branch 'origin/master'
authorGregg Kellogg <gregg@kellogg-assoc.com>
Wed, 13 Jul 2011 16:19:17 -0700
changeset 65 4e2d52fd450b
parent 62 e2554fe441d9 (current diff)
parent 64 b03c4e4a4b0f (diff)
child 66 87962421e8a5
Merge remote-tracking branch 'origin/master'
--- a/README.rst	Mon Jul 11 10:45:26 2011 -0700
+++ b/README.rst	Wed Jul 13 16:19:17 2011 -0700
@@ -1,7 +1,6 @@
 Introduction
 ------------
 
-
 JSON-LD (JavaScript Object Notation for Linked Data) is a lightweight Linked
 Data format. It is easy for humans to read and write. It is easy for machines
 to parse and generate. It is based on the already successful JSON format and
@@ -17,12 +16,13 @@
 
 A simple example of a JSON object with added semantics::
 
-  {
-    "#": {"foaf": "http://xmlns.com/foaf/0.1/"},
-    "@": "<http://example.org/people#john>",
-    "a": "foaf:Person",
-    "foaf:name" : "John Lennon"
-  }
+{ 
+  "@context": "http://purl.org/jsonld/Person"
+  "@subject": "http://dbpedia.org/resource/John_Lennon",
+  "name": "John Lennon",
+  "birthday": "10-09",
+  "member": "http://dbpedia.org/resource/The_Beatles"
+}
 
 The example above describes a person whose name is John Lennon. The difference
 between regular JSON and JSON-LD is that the JSON-LD object above uniquely
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/utils/README	Wed Jul 13 16:19:17 2011 -0700
@@ -0,0 +1,13 @@
+Usage
+-----
+
+In order to use the git.php file, you must create a file called 
+remote-update-token.txt and place a value in there. You must then call
+the git.php file with a URL parameter named 'token' set to the value in
+the file. For example:
+
+http://json-ld.org/utils/git.php?token=7384724849
+
+While this is not a fool-proof security solution, it'll be good enough
+for now. Updates are throttled, even in the event of a DDoS, the update
+rate is once every 5 seconds.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/utils/git.php	Wed Jul 13 16:19:17 2011 -0700
@@ -0,0 +1,45 @@
+<?php
+
+// open the token file
+$tfile = fopen('remote-update-token.txt', 'r');
+
+// Acquire the lock in a non-blocking manner
+if($tfile == FALSE)
+{
+   echo 'ERROR: You must create a file called remote-update-token.txt and ' .
+      'place a secret token in that file. See the README for more information.';
+}
+else if(flock($tfile, LOCK_EX | LOCK_NB))
+{
+   $token = trim(fgets($tfile));
+   
+   // check to make sure that the token value is correct
+   if(array_key_exists('token', $_GET) and $token === $_GET['token'])
+   {
+      // perform a git pull
+      chdir('..');
+      $gitdir = getcwd() . "/.git";
+      system("git --git-dir $gitdir pull");
+      
+      echo 'git update successful';
+      
+      // Sleep for 5 seconds to throttle the update rate to 12 per minute
+      sleep(5);
+   }
+   else
+   {
+      echo 'ERROR: Invalid secret token provided. ' .
+         'See the README for more information.';
+   }
+   
+   // Release the lock file
+   flock($tfile, LOCK_UN); // release the lock
+}
+else 
+{
+   echo 'ERROR: An update is currently being performed, ' .
+      'this request has been rejected.';
+}
+
+fclose($tfile);
+?>