Permalink
Browse files

putting site under version control

  • Loading branch information...
0 parents commit d384bd4c7b9a9447280a1d342373eabdd7906e34 @cygri committed Nov 2, 2010
Showing with 3,619 additions and 0 deletions.
  1. +6 −0 .htaccess
  2. +13 −0 config.php
  3. +83 −0 db_schema/schema.sql
  4. +15 −0 db_schema/upgrade_mk2.sql
  5. BIN images/deri-logo-32px.png
  6. BIN images/deri-logo-50px.png
  7. BIN images/feed-icon-28x28.png
  8. BIN images/link-hover.png
  9. BIN images/link.png
  10. BIN images/nuig-logo-32px.png
  11. BIN images/nuig-logo-50px.png
  12. BIN images/vote-down-hover.png
  13. BIN images/vote-down.png
  14. BIN images/vote-up-hover.png
  15. BIN images/vote-up.png
  16. +80 −0 index.php
  17. +17 −0 lib/http_exception.class.php
  18. +251 −0 lib/namespaces.class.php
  19. +67 −0 lib/request.class.php
  20. +113 −0 lib/response.class.php
  21. +22 −0 lib/rss2_feed_with_namespaces.class.php
  22. +500 −0 lib/site.class.php
  23. +21 −0 maintenance.php
  24. +2 −0 php.ini
  25. +1 −0 robots.txt
  26. +80 −0 script.js
  27. +208 −0 style.css
  28. +28 −0 templates/footer.php
  29. +4 −0 templates/format/csv.php
  30. +8 −0 templates/format/ini.php
  31. +13 −0 templates/format/json.php
  32. +8 −0 templates/format/n3.php
  33. +19 −0 templates/format/rdfa.php
  34. +13 −0 templates/format/sparql.php
  35. +8 −0 templates/format/txt.php
  36. +20 −0 templates/format/vann.php
  37. +13 −0 templates/format/xml.php
  38. +8 −0 templates/format/xmlns.php
  39. +9 −0 templates/google-analytics.html
  40. +25 −0 templates/header.php
  41. +17 −0 templates/lookup-multi.php
  42. +22 −0 templates/lookup-term.php
  43. +8 −0 templates/message.php
  44. +16 −0 templates/page-about.php
  45. +11 −0 templates/page-formats.php
  46. +17 −0 templates/page-home.php
  47. +25 −0 templates/page-latest.php
  48. +18 −0 templates/page-popular.php
  49. +15 −0 templates/page-reverse.php
  50. +9 −0 templates/record-lookup-uri.php
  51. +1 −0 templates/source.php
  52. +7 −0 vendor/README.txt
  53. +1,779 −0 vendor/feedcreator/feedcreator.class.php
  54. +19 −0 vendor/jquery/jquery.js
@@ -0,0 +1,6 @@
+RewriteEngine On
+RewriteBase /
+RewriteRule ^jquery.js$ vendor/jquery/jquery.js
+RewriteCond %{REQUEST_URI} !/(robots\.txt|style\.css|.*\.js|images/.*)$
+#RewriteRule .* maintenance.php [L]
+RewriteRule .* index.php
@@ -0,0 +1,13 @@
+<?php
+
+error_reporting(E_ALL);
+$config = array(
+ 'site_base' => 'http://prefix.local/',
+// 'site_base' => 'http://prefix.cc/',
+ 'block_time' => 60, // seconds
+// 'block_time' => 60 * 60 * 16, // seconds
+ 'db_host' => 'localhost',
+ 'db_name' => 'prefixcc',
+ 'db_user' => 'root',
+ 'db_password' => '',
+);
@@ -0,0 +1,83 @@
+-- phpMyAdmin SQL Dump
+-- version 2.9.1.1
+-- http://www.phpmyadmin.net
+--
+-- Host: localhost
+-- Generation Time: Jan 05, 2010 at 01:58 PM
+-- Server version: 5.0.27
+-- PHP Version: 5.2.11
+--
+-- Database: `prefixcc`
+--
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `prefixcc_access`
+--
+
+CREATE TABLE `prefixcc_access` (
+ `prefix` varchar(10) NOT NULL,
+ `count` int(11) NOT NULL,
+ PRIMARY KEY (`prefix`),
+ KEY `count` (`count`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `prefixcc_ip_block`
+--
+
+CREATE TABLE `prefixcc_ip_block` (
+ `ip` varchar(15) NOT NULL,
+ `date` datetime NOT NULL,
+ `scope` int(11) NOT NULL,
+ PRIMARY KEY (`ip`,`scope`),
+ KEY `date` (`date`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `prefixcc_namespaces`
+--
+
+CREATE TABLE `prefixcc_namespaces` (
+ `prefix` varchar(10) NOT NULL,
+ `uri` varchar(100) character set utf8 collate utf8_bin NOT NULL,
+ `date` datetime NOT NULL,
+ `ip` varchar(15) NOT NULL,
+ `votes` int(11) NOT NULL default '0',
+ PRIMARY KEY (`prefix`,`uri`),
+ KEY `votes` (`votes`),
+ KEY `date` (`date`),
+ KEY `uri` (`uri`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `prefixcc_rejected_uris`
+--
+
+CREATE TABLE `prefixcc_rejected_uris` (
+ `prefix` varchar(10) NOT NULL,
+ `uri` varchar(100) NOT NULL,
+ `date` datetime NOT NULL,
+ `ip` varchar(15) NOT NULL,
+ `reason` varchar(10) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `prefixcc_vote_log`
+--
+
+CREATE TABLE `prefixcc_vote_log` (
+ `prefix` varchar(10) NOT NULL,
+ `uri` varchar(100) NOT NULL,
+ `date` datetime NOT NULL,
+ `ip` varchar(15) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@@ -0,0 +1,15 @@
+ALTER TABLE prefixcc_ip_block
+ ADD scope INT NOT NULL AFTER ip,
+ DROP PRIMARY KEY,
+ ADD PRIMARY KEY (ip, scope) ;
+UPDATE prefixcc_ip_block SET scope=1;
+INSERT INTO prefixcc_ip_block
+ SELECT ip, date, 2 AS scope from prefixcc_ip_block;
+ALTER TABLE prefixcc_namespaces
+ CHANGE uri uri VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;
+ALTER TABLE prefixcc_vote_log
+ ADD up BOOL NOT NULL DEFAULT '1';
+ALTER TABLE prefixcc_namespaces
+ CHANGE votes upvotes INT NOT NULL DEFAULT '0',
+ ADD downvotes INT NOT NULL DEFAULT '0';
+UPDATE prefixcc_namespaces SET upvotes=upvotes+4;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,80 @@
+<?php
+
+include "config.php";
+
+require_once('lib/namespaces.class.php');
+require_once('lib/response.class.php');
+require_once('lib/request.class.php');
+require_once('lib/site.class.php');
+require_once('lib/http_exception.class.php');
+
+// Main objects
+$namespaces = new Namespaces($config);
+$request = new Request();
+$response = new Response($config['site_base'], $request->uri);
+$site = new Site($request->uri, $response, $namespaces, $config['block_time']);
+set_exception_handler(array($site, 'exception_handler'));
+
+// Helper regexes
+$prefix_regex = $namespaces->get_prefix_regex();
+$relaxed_prefix_regex = '[a-zA-Z0-9]*';
+$extensions_regex = '(?:([a-z0-9]+)(\.plain)?|(file\.)?([a-z0-9]+))';
+
+// Dispatch based on URI and method
+if ($q = $request->matches('/^(robots|favicon)/')) {
+ // The “robots” and “favicon” prefixes do not exist, to avoid clashes with robots.txt and favicon.ico
+ $response->error(404);
+} else if ($q = $request->matches('/^$/', array('q'))) {
+ $request->enforce_get();
+ $site->action_query($q['q']);
+} else if ($q = $request->matches('/^$/')) {
+ $request->enforce_get();
+ $site->action_home();
+} else if ($q = $request->matches('/^about$/')) {
+ $request->enforce_get();
+ $site->action_about();
+} else if ($q = $request->matches('/^about\/formats$/')) {
+ $request->enforce_get();
+ $site->action_about_formats();
+} else if ($q = $request->matches("/^popular(\/all)?(\.$extensions_regex)?$/")) {
+ $request->enforce_get();
+ $site->action_popular(!empty($q[1]), @$q[3] . @$q[6], !empty($q[4]) || !empty($q[5]));
+} else if ($q = $request->matches("/^latest(\/([0-9]+))?$/")) {
+ $request->enforce_get();
+ $site->action_latest(@$q[2]);
+} else if ($q = $request->matches("/^latest\.rss$/")) {
+ $request->enforce_get();
+ $site->action_latest_feed();
+} else if ($q = $request->matches("/^google-coop.rss$/")) {
+ $request->enforce_get();
+ $site->action_google_feed();
+} else if ($q = $request->matches("/^reverse$/", array("uri"))) {
+ $request->enforce_get();
+ $site->action_reverse($q['uri'], @$_GET['format']);
+} else if ($q = $request->matches("/^reverse$/")) {
+ $request->enforce_get();
+ $site->action_page_reverse();
+} else if ($q = $request->matches("/^($prefix_regex)(:(.*)|\.$extensions_regex|)$/")) {
+ if ($request->is_get()) {
+ if (strlen(@$q[3]) > 0) {
+ $site->action_curie($q[1], $q[3]);
+ } else {
+ $site->action_prefix($q[1], @$q[4] . @$q[7], !empty($q[5]) || !empty($q[6]));
+ }
+ } else {
+ $request->enforce_post(array('create'));
+ $site->action_declare($q[1], @$q[3], $_POST['create']);
+ }
+} else if ($q = $request->matches("!^($prefix_regex)/vote$!")) {
+ $request->enforce_post(array('uri', 'vote'));
+ $site->action_vote($q[1], $_POST['uri'], $_POST['vote'] == 'up');
+} else if ($q = $request->matches("/^($relaxed_prefix_regex(,$relaxed_prefix_regex)+)(\.$extensions_regex)?$/")) {
+ // We use a forgiving regex here, and do a check against the full prefix regex for each
+ // prefix inside the method
+ $request->enforce_get();
+ $site->action_prefixes(explode(',', $q[1]), @$q[4] . @$q[7], !empty($q[5]) || !empty($q[6]));
+} else if ($q = $request->matches("/^([^\/?]+)$/")) {
+ $site->failed_lookup($q[1]);
+} else {
+ $response->error(404);
+}
@@ -0,0 +1,17 @@
+<?php
+
+class HTTPException extends Exception {
+
+ var $status_code;
+ var $options;
+
+ function __construct($status_code, $options = array()) {
+ parent::__construct("HTTP $status_code");
+ $this->status_code = $status_code;
+ $this->options = $options;
+ }
+
+ function respond($response) {
+ $response->error($this->status_code, $this->options);
+ }
+}
Oops, something went wrong.

0 comments on commit d384bd4

Please sign in to comment.