repo
string | commit
string | message
string | diff
string |
---|---|---|---|
synewaves/starlight
|
53d2d72df67ab16145e06bb681856c04bf131da8
|
Work on router/dispatcher
|
diff --git a/src/Starlight/Component/Dispatcher/Context/Context.php b/src/Starlight/Component/Dispatcher/Context/Context.php
new file mode 100644
index 0000000..27195a6
--- /dev/null
+++ b/src/Starlight/Component/Dispatcher/Context/Context.php
@@ -0,0 +1,16 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\Dispatcher\Context;
+
+
+class Context
+{
+};
diff --git a/src/Starlight/Component/Dispatcher/Dispatcher.php b/src/Starlight/Component/Dispatcher/Dispatcher.php
new file mode 100644
index 0000000..6b4d5a2
--- /dev/null
+++ b/src/Starlight/Component/Dispatcher/Dispatcher.php
@@ -0,0 +1,25 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\Dispatcher;
+use Starlight\Component\Dispatcher\Context\Context;
+
+
+abstract class Dispatcher
+{
+ public $context;
+
+ public function __construct(Context $context)
+ {
+ $this->context = $context;
+ }
+
+ abstract public function dispatch();
+};
diff --git a/src/Starlight/Component/Dispatcher/HttpDispatcher.php b/src/Starlight/Component/Dispatcher/HttpDispatcher.php
index 2e21bb5..2b0bb51 100755
--- a/src/Starlight/Component/Dispatcher/HttpDispatcher.php
+++ b/src/Starlight/Component/Dispatcher/HttpDispatcher.php
@@ -1,23 +1,19 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Starlight\Component\Dispatcher;
-use \Starlight\Component\Http as Http;
-class HttpDispatcher
+class HttpDispatcher extends Dispatcher
{
- protected $request;
-
- public function dispatch(Http\Request $request)
+ public function dispatch()
{
- $this->request = $request;
}
};
diff --git a/src/Starlight/Component/Http/HeaderBucket.php b/src/Starlight/Component/Http/HeaderBucket.php
index c496acd..bf383c0 100755
--- a/src/Starlight/Component/Http/HeaderBucket.php
+++ b/src/Starlight/Component/Http/HeaderBucket.php
@@ -1,282 +1,297 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Starlight\Component\Http;
/**
* Wrapper class for request/response headers
*/
class HeaderBucket
{
/**
* Headers
* @var array
*/
protected $headers;
// /**
// * Wrapper class for request/response headers
// */
// protected $cache_control;
/**
* Type (request, response)
* @var string
*/
protected $type;
/**
* Constructor
* @param array $headers An array of HTTP headers
* @param string $type The type (null, request, or response)
*/
public function __construct(array $headers = array(), $type = null)
{
$this->replace($headers);
if ($type !== null && !in_array($type, array('request', 'response'))) {
throw new \InvalidArgumentException(sprintf('The "%s" type is not supported by the HeaderBucket.', $type));
}
$this->type = $type;
}
/**
* Returns the headers
* @return array An array of headers
*/
public function all()
{
return $this->headers;
}
/**
* Returns the parameter keys
* @return array An array of parameter keys
*/
public function keys()
{
return array_keys($this->headers);
}
/**
* Replaces the current HTTP headers by a new set
* @param array $headers An array of HTTP headers
+ * @return HeaderBucket this instance
*/
public function replace(array $headers = array())
{
$this->cache_control = null;
$this->headers = array();
foreach ($headers as $key => $values) {
$this->set($key, $values);
}
+
+ return $this;
}
/**
* Returns a header value by name
* @param string $key The header name
* @param Boolean $first Whether to return the first value or all header values
* @return string|array The first header value if $first is true, an array of values otherwise
*/
public function get($key, $first = true)
{
$key = static::normalizeHeaderName($key);
if (!array_key_exists($key, $this->headers)) {
return $first ? null : array();
}
if ($first) {
return count($this->headers[$key]) ? $this->headers[$key][0] : '';
} else {
return $this->headers[$key];
}
}
/**
* Sets a header by name
* @param string $key The key
* @param string|array $values The value or an array of values
* @param boolean $replace Whether to replace the actual value of not (true by default)
+ * @return HeaderBucket this instance
*/
public function set($key, $values, $replace = true)
{
$key = static::normalizeHeaderName($key);
if (!is_array($values)) {
$values = array($values);
}
if ($replace === true || !isset($this->headers[$key])) {
$this->headers[$key] = $values;
} else {
$this->headers[$key] = array_merge($this->headers[$key], $values);
}
+
+ return $this;
}
/**
* Returns true if the HTTP header is defined
* @param string $key The HTTP header
* @return Boolean true if the parameter exists, false otherwise
*/
public function has($key)
{
return array_key_exists(static::normalizeHeaderName($key), $this->headers);
}
/**
* Returns true if the given HTTP header contains the given value
* @param string $key The HTTP header name
* @param string $value The HTTP value
* @return Boolean true if the value is contained in the header, false otherwise
*/
public function contains($key, $value)
{
return in_array($value, $this->get($key, false));
}
/**
* Deletes a header
* @param string $key The HTTP header name
+ * @return HeaderBucket this instance
*/
public function delete($key)
{
unset($this->headers[static::normalizeHeaderName($key)]);
+
+ return $this;
}
// /**
// * Returns an instance able to manage the Cache-Control header.
// *
// * @return CacheControl A CacheControl instance
// */
// public function getCacheControl()
// {
// if (null === $this->cacheControl) {
// $this->cacheControl = new CacheControl($this, $this->get('Cache-Control'), $this->type);
// }
//
// return $this->cacheControl;
// }
/**
* Set cookie variable
*
* Available options:
*
* <ul>
* <li><b>expires</b> <i>(integer)</i>: cookie expiration time (default: 0 [end of session])</li>
* <li><b>path</b> <i>(string)</i>: path cookie is valid for (default: '')</li>
* <li><b>domain</b> <i>(string)</i>: domain cookie is valid for (default: '')</li>
* <li><b>secure/b> <i>(boolean)</i>: should cookie only be used on a secure connection (default: false)</li>
* <li><b>http_only</b> <i>(string)</i>: cookie only valid over http? [not supported by all browsers] (default: true)</li>
* <li><b>encode</b> <i>(boolean)</i>: urlencode cookie value (default: true)</li>
* </ul>
* @param string $key cookie key
* @param mixed $value value
* @param array $options options hash (see above)
+ * @return HeaderBucket this instance
*/
public function setCookie($name, $value, $options = array())
{
$default_options = array(
'expires' => null,
'path' => '',
'domain' => '',
'secure' => false,
'http_only' => true,
);
$options += $default_options;
if (preg_match("/[=,; \t\r\n\013\014]/", $key)) {
throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $key));
}
if (preg_match("/[,; \t\r\n\013\014]/", $value)) {
throw new \InvalidArgumentException(sprintf('The cookie value "%s" contains invalid characters.', $value));
}
if (!$name) {
throw new \InvalidArgumentException('The cookie name cannot be empty');
}
$cookie = sprintf('%s=%s', $name, urlencode($value));
if ($this->type == 'request') {
$this->set('Cookie', $cookie);
return;
}
if ($options['expires'] !== null) {
if (is_numeric($options['expires'])) {
$options['expires'] = (int) $options['expires'];
} elseif ($options['expires'] instanceof \DateTime) {
$options['expires'] = $options['expires']->getTimestamp();
} else {
$expires = strtotime($options['expires']);
if ($expires === false || $expires == -1) {
throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid.', $expires));
}
}
$cookie .= '; expires=' . substr(\DateTime::createFromFormat('U', $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5);
}
if ($options['domain']) {
$cookie .= '; domain=' . $options['domain'];
}
if ($options['path'] !== '/') {
$cookie .= '; path=' . $path;
}
if ($options['secure']) {
$cookie .= '; secure';
}
if ($options['httponly']) {
$cookie .= '; httponly';
}
- $this->set('Set-Cookie', $cookie, false);
+ $this->set('Set-Cookie', $cookie, false);
+
+ return $this;
}
/**
* Expire a cookie variable
* @param string $key cookie key
+ * @return HeaderBucket this instance
*/
public function expireCookie($key)
{
if ($this->type == 'request') {
return;
}
if (preg_match("/[=,; \t\r\n\013\014]/", $key)) {
throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $key));
}
if (!$name) {
throw new \InvalidArgumentException('The cookie name cannot be empty');
}
$cookie = sprintf('%s=; expires=', $name, substr(\DateTime::createFromFormat('U', time() - 3600, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5));
$this->set('Set-Cookie', $cookie, false);
+
+ return $this;
}
/**
* Normalizes an HTTP header name
* @param string $key The HTTP header name
* @return string The normalized HTTP header name
*/
static public function normalizeHeaderName($key)
{
return strtr(strtolower($key), '_', '-');
}
};
diff --git a/src/Starlight/Component/Http/HttpContext.php b/src/Starlight/Component/Http/HttpContext.php
new file mode 100644
index 0000000..d45f120
--- /dev/null
+++ b/src/Starlight/Component/Http/HttpContext.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\Http;
+use Starlight\Component\Dispatcher\Context\Context;
+
+
+class HttpContext extends Context
+{
+ public $request;
+ public $response;
+
+
+ public function __construct()
+ {
+ $this->request = new Request();
+ $this->response = new Response();
+ }
+};
diff --git a/src/Starlight/Component/Http/ParameterBucket.php b/src/Starlight/Component/Http/ParameterBucket.php
index 47e18ef..1be30fa 100755
--- a/src/Starlight/Component/Http/ParameterBucket.php
+++ b/src/Starlight/Component/Http/ParameterBucket.php
@@ -1,111 +1,123 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Starlight\Component\Http;
/**
* Wrapper class request parameters
* @see Request
*/
class ParameterBucket
{
/**
* Parameters
* @var array
*/
protected $parameters;
/**
* Constructor
* @param array $parameters Parameters
*/
public function __construct(array $parameters = array())
{
$this->replace($parameters);
}
/**
* Returns the parameters
* @return array Parameters
*/
public function all()
{
return $this->parameters;
}
/**
* Returns the parameter keys
* @return array Parameter keys
*/
public function keys()
{
return array_keys($this->parameters);
}
/**
* Replaces the current parameters by a new set
* @param array $parameters parameters
+ * @return HeaderBucket this instance
*/
public function replace(array $parameters = array())
{
$this->parameters = $parameters;
+
+ return $this;
}
/**
* Adds parameters
* @param array $parameters parameters
+ * @return HeaderBucket this instance
*/
public function add(array $parameters = array())
{
$this->parameters = array_replace($this->parameters, $parameters);
+
+ return $this;
}
/**
* Returns a parameter by name
* @param string $key The key
* @param mixed $default default value
* @return mixed value
*/
public function get($key, $default = null)
{
return array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default;
}
/**
* Sets a parameter by name
* @param string $key The key
* @param mixed $value value
+ * @return HeaderBucket this instance
*/
public function set($key, $value)
{
$this->parameters[$key] = $value;
+
+ return $this;
}
/**
* Returns true if the parameter is defined
* @param string $key The key
* @return boolean true if the parameter exists, false otherwise
*/
public function has($key)
{
return array_key_exists($key, $this->parameters);
}
/**
* Deletes a parameter
* @param string $key key
+ * @return HeaderBucket this instance
*/
public function delete($key)
{
unset($this->parameters[$key]);
+
+ return $this;
}
};
diff --git a/src/Starlight/Component/Http/Response.php b/src/Starlight/Component/Http/Response.php
new file mode 100644
index 0000000..973b4a0
--- /dev/null
+++ b/src/Starlight/Component/Http/Response.php
@@ -0,0 +1,98 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\Http;
+
+/**
+ * HTTP Response
+ */
+class Response
+{
+ /**
+ * Standard HTTP status codes and default messages
+ * @link http://www.iana.org/assignments/http-status-codes
+ * @var array
+ */
+ protected static $status_codes = array(
+ 100 => 'Continue',
+ 101 => 'Switching Protocols',
+ 102 => 'Processing',
+ 200 => 'OK',
+ 201 => 'Created',
+ 202 => 'Accepted',
+ 203 => 'Non-Authoritative Information',
+ 204 => 'No Content',
+ 205 => 'Reset Content',
+ 206 => 'Partial Content',
+ 207 => 'Multi-Status',
+ 226 => 'IM Used',
+ 300 => 'Multiple Choices',
+ 301 => 'Moved Permanently',
+ 302 => 'Found',
+ 303 => 'See Other',
+ 304 => 'Not Modified',
+ 305 => 'Use Proxy',
+ 307 => 'Temporary Redirect',
+ 400 => 'Bad Request',
+ 401 => 'Unauthorized',
+ 402 => 'Payment Required',
+ 403 => 'Forbidden',
+ 404 => 'Not Found',
+ 405 => 'Method Not Allowed',
+ 406 => 'Not Acceptable',
+ 407 => 'Proxy Authentication Required',
+ 408 => 'Request Timeout',
+ 409 => 'Conflict',
+ 410 => 'Gone',
+ 411 => 'Length Required',
+ 412 => 'Precondition Failed',
+ 413 => 'Request Entity Too Large',
+ 414 => 'Request-URI Too Long',
+ 415 => 'Unsupported Media Type',
+ 416 => 'Requested Range Not Satisfiable',
+ 417 => 'Expectation Failed',
+ 422 => 'Unprocessable Entity',
+ 423 => 'Locked',
+ 424 => 'Failed Dependency',
+ 426 => 'Upgrade Required',
+ 500 => 'Internal Server Error',
+ 501 => 'Not Implemented',
+ 502 => 'Bad Gateway',
+ 503 => 'Service Unavailable',
+ 504 => 'Gateway Timeout',
+ 505 => 'HTTP Version Not Supported',
+ 507 => 'Insufficient Storage',
+ 510 => 'Not Extended'
+ );
+
+
+ protected $content;
+ protected $status;
+
+
+ public function __construct($content = '', $status = 200)
+ {
+ $this->content($content)->status($status);
+ }
+
+ public function content($content)
+ {
+ $this->content = $content;
+
+ return $this;
+ }
+
+ public function status($status)
+ {
+ $this->status = $status;
+
+ return $this;
+ }
+};
diff --git a/src/Starlight/Component/Routing/Resource.php b/src/Starlight/Component/Routing/Resource.php
index 414c97b..27e122e 100644
--- a/src/Starlight/Component/Routing/Resource.php
+++ b/src/Starlight/Component/Routing/Resource.php
@@ -1,127 +1,152 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Starlight\Component\Routing;
use Starlight\Component\Inflector\Inflector;
/**
* Route
*/
class Resource implements Compilable
{
/**
* RESTful routing map; maps actions to methods
* @var array
*/
protected static $resources_map = array(
'index' => array('method' => 'get', 'path' => '/'),
'add' => array('method' => 'get', 'path' => '/:action'),
'create' => array('method' => 'post', 'path' => '/'),
'show' => array('method' => 'get', 'path' => '/:id'),
'edit' => array('method' => 'get', 'path' => '/:id/:action'),
'update' => array('method' => 'put', 'path' => '/:id'),
'delete' => array('method' => 'get', 'path' => '/:id/:action'),
'destroy' => array('method' => 'delete', 'path' => '/:id'),
);
+ protected static $resource_names = array(
+ 'add' => 'add',
+ 'edit' => 'edit',
+ 'delete' => 'delete',
+ );
+
public $resource;
public $except;
public $only;
public $controller;
public $constraints;
public $name;
public $path_names;
// member, collection, resources (nested)
/**
*
*/
public function __construct($resource)
{
$this->resource = $resource;
+ $this->controller = $this->resource;
}
/**
*
*/
public function except(array $except)
{
$this->only = null;
$this->except = $except;
- // array_diff_key(static::$resources_map, array_fill_keys($except, true));
-
return $this;
}
/**
*
*/
public function only(array $only)
{
$this->except = null;
$this->only = $only;
- // array_intersect_key(static::$resources_map, array_fill_keys($except, true));
-
return $this;
}
/**
*
*/
public function controller($controller)
{
$this->controller = $controller;
return $this;
}
/**
*
*/
public function constraints($constraints)
{
$this->constraints = $constraints;
return $this;
}
/**
- *
+ * (as)
*/
public function name($name)
{
$this->name = $name;
return $this;
}
/**
*
*/
public function pathNames(array $names)
{
$this->path_names = $names;
return $this;
}
/**
*
*/
public function compile()
{
+ $generators = self::$resources_map;
+ if ($this->except) {
+ $generators = array_diff_key($generators, array_fill_keys($this->except, true));
+ } elseif ($this->only) {
+ $generators = array_intersect_key($generators, array_fill_keys($this->only, true));
+ }
+
+ $this->path_names += self::$resource_names;
+
+ $routes = array();
+ foreach ($generators as $action => $parts) {
+ $path = $parts['path'];
+ if (strpos($path, ':action') !== false) {
+ $path = str_replace(':action', $this->path_names[$action], $path);
+ }
+
+ $r = new Route('/' . $this->resource . $path, $this->controller . '#' . $action);
+ $r->methods(array($parts['method']))->name($this->name);
+ $routes[] = $r;
+ }
+
+ dump($routes);
}
};
diff --git a/src/Starlight/Component/Routing/Route.php b/src/Starlight/Component/Routing/Route.php
index 0355600..5ff1dff 100644
--- a/src/Starlight/Component/Routing/Route.php
+++ b/src/Starlight/Component/Routing/Route.php
@@ -1,149 +1,167 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Starlight\Component\Routing;
/**
* Route
*/
class Route implements Routable, Compilable
{
/**
* URL path separators regex
* '\' and '.'
* @var string
*/
- protected static $separator_regex = '/([\/\.])/i';
+ protected static $separators = array('\/', '\.');
/**
* Base default values for route parameters
* @var array
*/
protected static $base_defaults = array(
'controller' => null,
'action' => null,
'id' => null,
);
public $path;
public $endpoint;
- public $patterns = array();
public $regex;
public $parameters;
public $constraints;
public $methods;
public $name;
public $namespace;
/**
*
*/
public function __construct($path, $endpoint)
{
$this->path = $path;
$this->endpoint = $endpoint;
-
- // $elements = preg_split(static::$separator_regex, trim($this->path, '/'), -1, PREG_SPLIT_DELIM_CAPTURE);
- // if (count($elements) == 0) {
- // return;
- // }
- //
- // array_unshift($elements, '/');
- // $count = count($elements);
- // $names = array();
- //
- // for ($i=0; $i<$count; $i = $i+2) {
- // $sep = $elements[$i];
- // $elm = $elements[$i+1];
- //
- // if (preg_match('/^\*(.+)$/', $elm, $match)) {
- // // is the glob character:
- // $this->patterns[] = '(?:\\' . $sep . '(.*+))?';
- // $names[$match[1]] = null;
- // } elseif (preg_match('/^:(.+)$/', $elm, $match)) {
- // // is a named element:
- // $this->patterns[] = '(?:\\' . $sep . '([^\/\.]+))?';
- // $names[$match[1]] = null;
- // } else {
- // // just plain text:
- // $this->patterns[] = '\\' . $sep . $elm;
- // }
- // }
- //
- // // $this->regex = '/^' . implode($patterns) . '\/?$/i';
- // $this->parameters = static::$base_defaults + $names;
- //
- // list($this->parameters['controller'], $this->parameters['action']) = explode('#', $this->endpoint);
}
/**
*
*/
public function defaults(array $defaults)
{
foreach ($defaults as $key => $value) {
if (trim($this->parameters[$key]) == '') {
$this->parameters[$key] = $value;
}
}
return $this;
}
/**
*
*/
public function constraints($constraints)
{
$this->constraints = $constraints;
return $this;
}
/**
*
*/
public function methods(array $methods)
{
$this->methods = $methods;
return $this;
}
/**
*
*/
public function name($name)
{
$this->name = $name;
return $this;
}
+ /**
+ *
+ */
public function namespaced($namespace)
{
$this->namespace = $namespace;
- // array_unshift($this->patterns, '\\/' . $namespace);
+ //
return $this;
}
+ /**
+ *
+ */
public function compile()
{
+ $elements = preg_split('/([' . implode(static::$separators) . '])/i', trim($this->path, '/'), -1, PREG_SPLIT_DELIM_CAPTURE);
+ if (count($elements) == 0) {
+ return;
+ }
+
+ array_unshift($elements, '/');
+ $patterns = array();
+ $count = count($elements);
+ $names = array();
+
+ for ($i=0; $i<$count; $i = $i+2) {
+ $sep = $elements[$i];
+ $elm = $elements[$i+1];
+
+ if (preg_match('/^\*(.+)$/', $elm, $match)) {
+ // glob character:
+ $patterns[] = '(?:\\' . $sep . '(.*+))?';
+ $names[$match[1]] = null;
+ } elseif (preg_match('/^:(.+)$/', $elm, $match)) {
+ // named element:
+ $patterns[] = '(?:\\' . $sep . '([^\/\.]+))?';
+ $names[$match[1]] = null;
+ } else {
+ // normal element:
+ $patterns[] = '\\' . $sep . $elm;
+ }
+ }
+
+ if ($this->namespace) {
+ array_unshift($patterns, '\\/' . $this->namespace);
+ if ($this->name != '') {
+ $this->name = $this->namespace . '_' . $this->name;
+ }
+ }
+
+ $this->regex = '/^' . implode($patterns) . '\/?$/i';
+ $this->parameters = static::$base_defaults + $names;
+ list($this->parameters['controller'], $this->parameters['action']) = explode('#', $this->endpoint);
+
+ return $this;
}
- public function match($path)
+ /**
+ *
+ */
+ public function match($context)
{
-
+ // if (preg_match($this->regex, $path, $matches)) {
+ // dump($matches);
+ // }
}
};
diff --git a/src/Starlight/Component/Routing/Router.php b/src/Starlight/Component/Routing/Router.php
index dbc54c1..8416d0e 100644
--- a/src/Starlight/Component/Routing/Router.php
+++ b/src/Starlight/Component/Routing/Router.php
@@ -1,37 +1,63 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Starlight\Component\Routing;
/**
* Router
*/
class Router
{
protected static $routes = array();
- protected static $resources = array();
+ protected static $compiled = array();
- public static function match($path, $endpoint)
+ public static function map($path, $endpoint)
{
static::$routes[] = new Route($path, $endpoint);
return static::$routes[count(static::$routes) - 1];
}
public static function resources($resource)
{
- static::$resources[] = new Resource($resource);
+ static::$routes[] = new Resource($resource);
- return static::$resources[count(static::$resources) - 1];
+ return static::$routes[count(static::$routes) - 1];
+ }
+
+ public static function compile()
+ {
+ static::$compiled = array();
+
+ foreach (self::$routes as $route) {
+ $c = $route->compile();
+ if (is_array($c)) {
+ static::$compiled += $c;
+ } else {
+ static::$compiled [] = $c;
+ }
+ }
+ }
+
+ public static function match($url)
+ {
+ foreach (static::$compiled as $r) {
+ if ($r->match($url)) {
+ //
+ return;
+ }
+ }
+
+ // nothing matched:
}
};
diff --git a/src/Starlight/Framework/bootloader.php b/src/Starlight/Framework/bootloader.php
index c6a20ef..9dfb433 100755
--- a/src/Starlight/Framework/bootloader.php
+++ b/src/Starlight/Framework/bootloader.php
@@ -1,51 +1,64 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
error_reporting(-1);
-require_once __DIR__ . DIRECTORY_SEPARATOR . 'Support' . DIRECTORY_SEPARATOR . 'UniversalClassLoader.php';
+require_once __DIR__ . '/Support/UniversalClassLoader.php';
$autoloader = new \Starlight\Framework\Support\UniversalClassLoader();
$autoloader->registerNamespaces(array(
'Starlight' => __DIR__ . '/../../',
));
$autoloader->register();
function dump()
{
foreach (func_get_args() as $arg) {
echo '<pre>' . print_r($arg, true) . '</pre>';
echo '<hr />';
}
}
+
+$dispatcher = new \Starlight\Component\Dispatcher\HttpDispatcher(new \Starlight\Component\Http\HttpContext());
+$dispatcher->dispatch();
+
+
// $dispatcher = new \Starlight\Component\Dispatcher\HttpDispatcher();
// $dispatcher->dispatch(new \Starlight\Component\Http\Request());
// dump($dispatcher);
//\Starlight\Framework\Kernel::initialize();
// $r->match('/some/url/to/match', 'controller#hellyeah');
-// $route = \Starlight\Component\Routing\Router::match('/pages/*junk/anything/:id', 'pages#view')
-// ->defaults(array('controller' => 'anything'))
-// ->methods(array('post', 'get'))
-// ->constraints(array('id' => '/[0-9]+/i'))
-// ->name('junk_stuff')
-// ->namespaced('admin')
+// $route = \Starlight\Component\Routing\Router::map('/pages/:id', 'pages#view')
+// // ->defaults(array('controller' => 'anything'))
+// // ->methods(array('post', 'get'))
+// // ->constraints(array('id' => '/[0-9]+/i'))
+// // ->name('junk_stuff')
+// // ->namespaced('admin')
// ;
// // ->constraints(function($request){
// // return false;
// // });
+
// $route = \Starlight\Component\Routing\Router::resources('photos')
-// ->except(array('index'))
+// ->only(array('edit'))
+// ->pathNames(array('edit' => 'editon'))
+// ->controller('images')
+// ->name('images')
// ;
//
-// dump($route);
+// $route->compile();
+
+// \Starlight\Component\Routing\Router::compile();
+// //\Starlight\Component\Routing\Router::match('/pages/this-is-some-junk/and-some-more-junk/adsf/anything/100asd');
+// \Starlight\Component\Routing\Router::match('/pages/100asd');
|
synewaves/starlight
|
5a4319eeea4e1700ef5d0a636005ff0c4913ea38
|
Beginnings of test structure and routing
|
diff --git a/.gitignore b/.gitignore
index 32a36c2..a75b755 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
-.eprj
\ No newline at end of file
+.eprj
+phpunit.xml
+autoload.php
+coverage
\ No newline at end of file
diff --git a/README.markdown b/README.markdown
index 9d9a88d..c454b19 100644
--- a/README.markdown
+++ b/README.markdown
@@ -1,11 +1,11 @@
# Starlight
Starlight is a full-stack web application framework for PHP 5.3.
It runs on anything that can run PHP.
-
+
LICENSE
-------
see LICENSE file
\ No newline at end of file
diff --git a/autoload.php.dist b/autoload.php.dist
new file mode 100644
index 0000000..98f6134
--- /dev/null
+++ b/autoload.php.dist
@@ -0,0 +1,17 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+require_once __DIR__ . '/src/Starlight/Framework/Support/UniversalClassLoader.php';
+
+$autoloader = new \Starlight\Framework\Support\UniversalClassLoader();
+$autoloader->registerNamespaces(array(
+ 'Starlight' => __DIR__ . '/src',
+));
+$autoloader->register();
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 0000000..676a62a
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit backupGlobals="false"
+ backupStaticAttributes="true"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="true"
+ stopOnFailure="false"
+ syntaxCheck="false"
+ bootstrap="tests/bootstrap.php"
+>
+ <testsuites>
+ <testsuite name="Starlight Test Suite">
+ <directory>./tests/Starlight/</directory>
+ </testsuite>
+ </testsuites>
+
+ <filter>
+ <whitelist>
+ <directory>./src/Starlight/</directory>
+ </whitelist>
+ </filter>
+</phpunit>
diff --git a/src/Starlight/Component/Http/HeaderBucket.php b/src/Starlight/Component/Http/HeaderBucket.php
index 69ad3fa..c496acd 100755
--- a/src/Starlight/Component/Http/HeaderBucket.php
+++ b/src/Starlight/Component/Http/HeaderBucket.php
@@ -1,282 +1,282 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Starlight\Component\Http;
/**
* Wrapper class for request/response headers
*/
class HeaderBucket
{
/**
* Headers
* @var array
*/
protected $headers;
// /**
// * Wrapper class for request/response headers
// */
// protected $cache_control;
/**
* Type (request, response)
* @var string
*/
protected $type;
/**
* Constructor
* @param array $headers An array of HTTP headers
* @param string $type The type (null, request, or response)
*/
public function __construct(array $headers = array(), $type = null)
{
$this->replace($headers);
if ($type !== null && !in_array($type, array('request', 'response'))) {
throw new \InvalidArgumentException(sprintf('The "%s" type is not supported by the HeaderBucket.', $type));
}
$this->type = $type;
}
/**
* Returns the headers
* @return array An array of headers
*/
public function all()
{
return $this->headers;
}
/**
* Returns the parameter keys
* @return array An array of parameter keys
*/
public function keys()
{
return array_keys($this->headers);
}
/**
* Replaces the current HTTP headers by a new set
* @param array $headers An array of HTTP headers
*/
public function replace(array $headers = array())
{
$this->cache_control = null;
$this->headers = array();
foreach ($headers as $key => $values) {
$this->set($key, $values);
}
}
/**
* Returns a header value by name
* @param string $key The header name
* @param Boolean $first Whether to return the first value or all header values
* @return string|array The first header value if $first is true, an array of values otherwise
*/
public function get($key, $first = true)
{
- $key = self::normalizeHeaderName($key);
+ $key = static::normalizeHeaderName($key);
if (!array_key_exists($key, $this->headers)) {
return $first ? null : array();
}
if ($first) {
return count($this->headers[$key]) ? $this->headers[$key][0] : '';
} else {
return $this->headers[$key];
}
}
/**
* Sets a header by name
* @param string $key The key
* @param string|array $values The value or an array of values
* @param boolean $replace Whether to replace the actual value of not (true by default)
*/
public function set($key, $values, $replace = true)
{
- $key = self::normalizeHeaderName($key);
+ $key = static::normalizeHeaderName($key);
if (!is_array($values)) {
$values = array($values);
}
if ($replace === true || !isset($this->headers[$key])) {
$this->headers[$key] = $values;
} else {
$this->headers[$key] = array_merge($this->headers[$key], $values);
}
}
/**
* Returns true if the HTTP header is defined
* @param string $key The HTTP header
* @return Boolean true if the parameter exists, false otherwise
*/
public function has($key)
{
- return array_key_exists(self::normalizeHeaderName($key), $this->headers);
+ return array_key_exists(static::normalizeHeaderName($key), $this->headers);
}
/**
* Returns true if the given HTTP header contains the given value
* @param string $key The HTTP header name
* @param string $value The HTTP value
* @return Boolean true if the value is contained in the header, false otherwise
*/
public function contains($key, $value)
{
return in_array($value, $this->get($key, false));
}
/**
* Deletes a header
* @param string $key The HTTP header name
*/
public function delete($key)
{
- unset($this->headers[self::normalizeHeaderName($key)]);
+ unset($this->headers[static::normalizeHeaderName($key)]);
}
// /**
// * Returns an instance able to manage the Cache-Control header.
// *
// * @return CacheControl A CacheControl instance
// */
// public function getCacheControl()
// {
// if (null === $this->cacheControl) {
// $this->cacheControl = new CacheControl($this, $this->get('Cache-Control'), $this->type);
// }
//
// return $this->cacheControl;
// }
/**
* Set cookie variable
*
* Available options:
*
* <ul>
* <li><b>expires</b> <i>(integer)</i>: cookie expiration time (default: 0 [end of session])</li>
* <li><b>path</b> <i>(string)</i>: path cookie is valid for (default: '')</li>
* <li><b>domain</b> <i>(string)</i>: domain cookie is valid for (default: '')</li>
* <li><b>secure/b> <i>(boolean)</i>: should cookie only be used on a secure connection (default: false)</li>
* <li><b>http_only</b> <i>(string)</i>: cookie only valid over http? [not supported by all browsers] (default: true)</li>
* <li><b>encode</b> <i>(boolean)</i>: urlencode cookie value (default: true)</li>
* </ul>
* @param string $key cookie key
* @param mixed $value value
* @param array $options options hash (see above)
*/
public function setCookie($name, $value, $options = array())
{
$default_options = array(
'expires' => null,
'path' => '',
'domain' => '',
'secure' => false,
'http_only' => true,
);
$options += $default_options;
if (preg_match("/[=,; \t\r\n\013\014]/", $key)) {
throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $key));
}
if (preg_match("/[,; \t\r\n\013\014]/", $value)) {
throw new \InvalidArgumentException(sprintf('The cookie value "%s" contains invalid characters.', $value));
}
if (!$name) {
throw new \InvalidArgumentException('The cookie name cannot be empty');
}
$cookie = sprintf('%s=%s', $name, urlencode($value));
if ($this->type == 'request') {
$this->set('Cookie', $cookie);
return;
}
if ($options['expires'] !== null) {
if (is_numeric($options['expires'])) {
$options['expires'] = (int) $options['expires'];
} elseif ($options['expires'] instanceof \DateTime) {
$options['expires'] = $options['expires']->getTimestamp();
} else {
$expires = strtotime($options['expires']);
if ($expires === false || $expires == -1) {
throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid.', $expires));
}
}
$cookie .= '; expires=' . substr(\DateTime::createFromFormat('U', $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5);
}
if ($options['domain']) {
$cookie .= '; domain=' . $options['domain'];
}
if ($options['path'] !== '/') {
$cookie .= '; path=' . $path;
}
if ($options['secure']) {
$cookie .= '; secure';
}
if ($options['httponly']) {
$cookie .= '; httponly';
}
$this->set('Set-Cookie', $cookie, false);
}
/**
* Expire a cookie variable
* @param string $key cookie key
*/
public function expireCookie($key)
{
if ($this->type == 'request') {
return;
}
if (preg_match("/[=,; \t\r\n\013\014]/", $key)) {
throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $key));
}
if (!$name) {
throw new \InvalidArgumentException('The cookie name cannot be empty');
}
$cookie = sprintf('%s=; expires=', $name, substr(\DateTime::createFromFormat('U', time() - 3600, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5));
$this->set('Set-Cookie', $cookie, false);
}
/**
* Normalizes an HTTP header name
* @param string $key The HTTP header name
* @return string The normalized HTTP header name
*/
static public function normalizeHeaderName($key)
{
return strtr(strtolower($key), '_', '-');
}
};
diff --git a/src/Starlight/Component/Http/Request.php b/src/Starlight/Component/Http/Request.php
index b72e032..6392155 100755
--- a/src/Starlight/Component/Http/Request.php
+++ b/src/Starlight/Component/Http/Request.php
@@ -1,276 +1,276 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Starlight\Component\Http;
/**
* HTTP Request
*/
class Request
{
public $post;
public $get;
public $cookies;
public $files;
public $server;
public $headers;
protected $host;
protected $port;
protected $remote_ip;
/**
* Constructor
* @param array $post POST values
* @param array $get GET values
* @param array $cookies COOKIE values
* @param array $files FILES values
* @param array $server SERVER values
*/
public function __construct(array $post = null, array $get = null, array $cookies = null, array $files = null, array $server = null)
{
$this->post = new ParameterBucket($post ?: $_POST);
$this->get = new ParameterBucket($get ?: $_GET);
$this->cookies = new ParameterBucket($cookies ?: $_COOKIE);
$this->files = new ParameterBucket($files ?: $_FILES);
$this->server = new ParameterBucket($server ?: $_SERVER);
$this->headers = new HeaderBucket($this->initializeHeaders(), 'request');
}
/**
* Clone
*/
public function __clone()
{
$this->post = clone $this->post;
$this->get = clone $this->get;
$this->cookies = clone $this->cookies;
$this->files = clone $this->files;
$this->server = clone $this->server;
$this->headers = clone $this->headers;
}
/**
* Get a value from the request
*
* Order or precedence: GET, POST, COOKIE
*/
public function get($key, $default = null)
{
return $this->get->get($key, $this->post->get($key, $this->cookies->get($key, $default)));
}
/**
* Gets request method, lowercased
*
* Method can come from three places in this order:
* <ol>
* <li>$_POST[_method]</li>
* <li>$_SERVER[X_HTTP_METHOD_OVERRIDE]</li>
* <li>$_SERVER[REQUEST_METHOD]</li>
* </ol>
* @return string request method
*/
public function getMethod()
{
return strtolower($this->post->get('_method', $this->server->get('X_HTTP_METHOD_OVERRIDE', $this->server->get('REQUEST_METHOD'))));
}
/**
* Is this a DELETE request
* @return boolean is DELETE request
*/
public function isDelete()
{
return $this->getMethod() == 'delete';
}
/**
* Is this a GET request
* @see head()
* @return boolean is GET request
*/
public function isGet()
{
return $this->isHead();
}
/**
* Is this a POST request
* @return boolean is POST request
*/
public function isPost()
{
return $this->getMethod() == 'post';
}
/**
* Is this a HEAD request
*
* Functionally equivalent to get()
* @return boolean is HEAD request
*/
public function isHead()
{
return $this->getMethod() == 'head' || $this->getMethod() == 'get';
}
/**
* Is this a PUT request
* @return boolean is PUT request
*/
public function isPut()
{
return $this->getMethod() == 'put';
}
/**
* Is this an SSL request
* @return boolean is SSL request
*/
public function isSsl()
{
return strtolower($this->server->get('HTTPS')) == 'on';
}
/**
* Gets server protocol
* @return string protocol
*/
public function getProtocol()
{
return $this->isSsl() ? 'https://' : 'http://';
}
/**
* Gets the server host
* @return string host
*/
public function getHost()
{
if ($this->host === null) {
$host = $this->server->get('HTTP_X_FORWARDED_HOST', $this->server->get('HTTP_HOST'));
$pos = strpos($host, ':');
if ($pos !== false) {
$this->host = substr($host, 0, $pos);
$this->port = $this->port === null ? substr($host, $pos + 1) : null;
} else {
$this->host = $host;
}
}
return $this->host;
}
/**
* Gets the server port
* @return integer port
*/
- public static function getPort()
+ public function getPort()
{
if ($this->port === null) {
$this->port = $this->server->get('SERVER_PORT', $this->getStandardPort());
}
return $this->port;
}
/**
* Gets the standard port number for the current protocol
* @return integer port (443, 80)
*/
- public static function getStandardPort()
+ public function getStandardPort()
{
return $this->isSsl() ? 443 : 80;
}
/**
* Gets the port string with colon delimiter if not standard port
* @return string port
*/
public function getPortString()
{
return (in_array($this->getPort(), array(443, 80))) ? '' : ':' . $this->getPort();
}
/**
* Gets the host with the port
* @return string host with port
*/
public function getHostWithPort()
{
return $this->getHost() . $this->getPortString();
}
/**
* Gets the client's remote ip
* @return string IP
*/
public function getRemoteIp()
{
if ($this->remote_ip === null) {
$remote_ips = null;
if ($x_forward = $this->server->get('HTTP_X_FORWARDED_FOR')) {
$remote_ips = array_map('trim', explode(',', $x_forward));
}
$client_ip = $this->server->get('HTTP_CLIENT_IP');
if ($client_ip) {
if (is_array($remote_ips) && !in_array($client_ip, $remote_ips)) {
// don't know which came from the proxy, and which from the user
throw new Exception\IpSpoofingException(sprintf("IP spoofing attack?!\nHTTP_CLIENT_IP=%s\nHTTP_X_FORWARDED_FOR=%s", $this->server->get('HTTP_CLIENT_IP'), $this->server->get('HTTP_X_FORWARDED_FOR')));
}
$this->remote_ip = $client_ip;
} elseif (is_array($remote_ips)) {
$this->remote_ip = $remote_ips[0];
} else {
$this->remote_ip = $this->server->get('REMOTE_ADDR');
}
}
return $this->remote_ip;
}
/**
* Check if the request is an XMLHttpRequest (AJAX)
* @return boolean is XHR (AJAX) request
*/
public function isXmlHttpRequest()
{
return (bool) preg_match('/XMLHttpRequest/i', $this->server->get('HTTP_X_REQUESTED_WITH'));
}
/**
* Gets the full server url with protocol and port
* @return string server path
*/
public function getServer()
{
return $this->getProtocol() . $this->getHostWithPort();
}
/**
* Initialize request headers for HeaderBucket
* @return array headers
*/
protected function initializeHeaders()
{
$headers = array();
foreach ($this->server->all() as $key => $value) {
if (strtolower(substr($key, 0, 5)) === 'http_') {
$headers[substr($key, 5)] = $value;
}
}
return $headers;
}
};
diff --git a/src/Starlight/Component/Inflector/Inflector.php b/src/Starlight/Component/Inflector/Inflector.php
new file mode 100644
index 0000000..1f3b6be
--- /dev/null
+++ b/src/Starlight/Component/Inflector/Inflector.php
@@ -0,0 +1,312 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\Inflector;
+
+
+/**
+ * Inflector
+ */
+class Inflector
+{
+ /**
+ * Plural inflections
+ * @var array
+ */
+ protected static $plurals = array();
+
+ /**
+ * Singular inflections
+ * @var array
+ */
+ protected static $singulars = array();
+
+ /**
+ * Uncountable item reflections
+ * @var array
+ */
+ protected static $uncountables = array();
+
+
+ /**
+ * Adds a plural inflection
+ * @param string $rule regex rule
+ * @param string $replacement regex replacement
+ */
+ public static function plural($rule, $replacement)
+ {
+ if (!preg_match('/^\//', $rule)) {
+ // looks like a string
+ // TODO: make string vs regex detection better
+ static::$uncountables = array_diff(static::$uncountables, array($rule));
+ $rule = '/' . $rule . '/i';
+ }
+
+ static::$uncountables = array_diff(static::$uncountables, array($replacement));
+ array_unshift(static::$plurals, array($rule, $replacement));
+ }
+
+ /**
+ * Adds a singular inflection
+ * @param string $rule regex rule
+ * @param string $replacement regex replacement
+ */
+ public static function singular($rule, $replacement)
+ {
+ if (!preg_match('/^\//', $rule)) {
+ // looks like a string
+ // TODO: make string vs regex detection better
+ static::$uncountables = array_diff(static::$uncountables, array($rule));
+ $rule = '/' . $rule . '/i';
+ }
+
+ static::$uncountables = array_diff(static::$uncountables, array($replacement));
+ array_unshift(static::$singulars, array($rule, $replacement));
+ }
+
+ /**
+ * Adds an irregular inflection
+ * @param string $singular singular rule
+ * @param string $plural plural rule
+ */
+ public static function irregular($singular, $plural)
+ {
+ static::plural('/(' . $singular[0] . ')' . substr($singular, 1) . '$/i', '\1' . substr($plural, 1));
+ static::singular('/(' . $plural[0] . ')' . substr($plural, 1) . '$/i', '\1' . substr($singular, 1));
+ }
+
+ /**
+ * Adds an uncountable word(s)
+ * @param string|array single word or array of words
+ */
+ public static function uncountable($words)
+ {
+ static::$uncountables += !is_array($words) ? array($words) : $words;
+ }
+
+ /**
+ * Pluralizes a word
+ * @param string $str word
+ * @return string pluralized word
+ */
+ public static function pluralize($str)
+ {
+ $str = strval($str);
+
+ if (!in_array(strtolower($str), static::$uncountables) && $str != '') {
+ foreach (static::$plurals as $pair) {
+ if (preg_match($pair[0], $str)) {
+ return preg_replace($pair[0], $pair[1], $str);
+ }
+ }
+ }
+
+ return $str;
+ }
+
+ /**
+ * Singularizes a word
+ * @param string $str word
+ * @return string singularized word
+ */
+ public static function singularize($str)
+ {
+ $str = strval($str);
+
+ if (!in_array(strtolower($str), static::$uncountables) && $str != '') {
+ foreach (static::$singulars as $pair) {
+ if (preg_match($pair[0], $str)) {
+ return preg_replace($pair[0], $pair[1], $str);
+ }
+ }
+ }
+
+ return $str;
+ }
+
+ /**
+ * Normalizes a string for a url
+ *
+ * This removes any non alphanumeric character, dash, space or underscore
+ * with supplied separator
+ *
+ * <code>
+ * echo Inflector::normalize('This is an example');
+ * > this-is-an-example
+ * </code>
+ * @param string $str string to normalize
+ * @param string $sep string separator
+ * @return normalized string
+ */
+ public static function normalize($str, $sep = '-')
+ {
+ return strtolower(preg_replace(array('/[^a-zA-Z0-9\_ \-]/', '/\s+/',), array('', $sep), strval($str)));
+ }
+
+ /**
+ * Humanizes an underscored string
+ *
+ * <code>
+ * echo Inflector::humanize('this_is_an_example');
+ * > This is an example
+ * </code>
+ * @param string $str string to humanize (underscored)
+ * @return string humanized string
+ */
+ public static function humanize($str)
+ {
+ return ucfirst(strtolower(preg_replace('/_/', ' ', preg_replace('/_id$/', '', strval($str)))));
+ }
+
+ /**
+ * Titleizes an underscored string
+ *
+ * <code>
+ * echo Inflector::titleize('this_is_an_example');
+ * > This Is An Example
+ * </code>
+ * @param string $str string to titleize (underscored)
+ * @return string titleized string
+ */
+ public static function titleize($str)
+ {
+ return ucwords(static::humanize(static::underscore($str)));
+ }
+
+ /**
+ * Creates a table name from a class name
+ *
+ * <code>
+ * echo Inflector::tableize('ExampleWord');
+ * > example_words
+ * </code>
+ * @param string $str string to tableize (underscored)
+ * @return string humanized string
+ */
+ public static function tableize($str)
+ {
+ return static::pluralize(static::underscore($str));
+ }
+
+ /**
+ * Creates a class name from a table name
+ *
+ * <code>
+ * echo Inflector::classify('example_words');
+ * > ExampleWord
+ * </code>
+ * @param string $str string to classify (camel-cased, pluralized)
+ * @return string classified string
+ */
+ public static function classify($str)
+ {
+ return static::camelize(static::singularize(preg_replace('/.*\./', '', $str)));
+ }
+
+ /**
+ * Camelizes a string
+ *
+ * <code>
+ * echo Inflector::camelize('This is an example');
+ * > ThisIsAnExample
+ * </code>
+ * @param string $str string to camelize
+ * @param boolean $uc_first uppercase first letter
+ * @return camelized string
+ */
+ public static function camelize($str, $uc_first = true)
+ {
+ $base = str_replace(' ', '', ucwords(str_replace('_', ' ', strval($str))));
+
+ return !$uc_first ? strtolower(substr($base, 0, 1)) . substr($base, 1) : $base;
+ }
+
+ /**
+ * Underscores a camelized string
+ *
+ * <code>
+ * echo Inflector::underscore('thisIsAnExample');
+ * > this_is_an_example
+ * </code>
+ * @param string $str string to underscore (camelized)
+ * @return string underscored string
+ */
+ public static function underscore($str)
+ {
+ $str = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\\1_\\2', strval($str));
+ $str = preg_replace('/([a-z\d])([A-Z])/', '\\1_\\2', $str);
+ $str = str_replace('-', '_', $str);
+
+ return strtolower($str);
+ }
+
+ /**
+ * Dasherizes a string
+ *
+ * <code>
+ * echo Inflector::dasherize('this_is_an_example');
+ * > this-is-an-example
+ * </code>
+ * @param string $str string to dasherize
+ * @return dasherized string
+ */
+ public static function dasherize($str)
+ {
+ return str_replace('_', '-', strval($str));
+ }
+
+ /**
+ * Ordinalizes a number
+ *
+ * <code>
+ * echo Inflector::ordinalize(10);
+ * > 10th
+ * </code>
+ * @param integer $number number
+ * @return string ordinalized number
+ */
+ public static function ordinalize($number)
+ {
+ if (in_array(($number % 100), array(11, 12, 13))) {
+ return $number . 'th';
+ } else {
+ $mod = $number % 10;
+ if ($mod == 1) {
+ return $number . 'st';
+ } elseif ($mod == 2) {
+ return $number . 'nd';
+ } elseif ($mod == 3) {
+ return $number . 'rd';
+ } else {
+ return $number . 'th';
+ }
+ }
+ }
+
+ /**
+ * Creates a foreign key name from a class name
+ *
+ * <code>
+ * echo Inflector::foreignKey('Example');
+ * > example_id
+ * </code>
+ * @param string $str string to make foreign key for
+ * @param boolean $underscore use underscore delimiter
+ * @return string foreign key string
+ */
+ public static function foreignKey($str, $underscore = true)
+ {
+ return static::underscore($str) . ($underscore ? '_id' : 'id');
+ }
+};
+
+
+// include default inflections
+require_once __DIR__ . '/inflections.php';
diff --git a/src/Starlight/Component/Inflector/inflections.php b/src/Starlight/Component/Inflector/inflections.php
new file mode 100644
index 0000000..d38898c
--- /dev/null
+++ b/src/Starlight/Component/Inflector/inflections.php
@@ -0,0 +1,65 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\Inflector;
+
+
+Inflector::plural('/$/', 's');
+Inflector::plural('/s$/i', 's');
+Inflector::plural('/(ax|test)is$/i', '\1es');
+Inflector::plural('/(octop|vir)us$/i', '\1i');
+Inflector::plural('/(alias|status)$/i', '\1es');
+Inflector::plural('/(bu)s$/i', '\1ses');
+Inflector::plural('/(buffal|tomat)o$/i', '\1oes');
+Inflector::plural('/([ti])um$/i', '\1a');
+Inflector::plural('/sis$/i', 'ses');
+Inflector::plural('/(?:([^f])fe|([lr])f)$/i', '\1\2ves');
+Inflector::plural('/(hive)$/i', '\1s');
+Inflector::plural('/([^aeiouy]|qu)y$/i', '\1ies');
+Inflector::plural('/(x|ch|ss|sh)$/i', '\1es');
+Inflector::plural('/(matr|vert|ind)(?:ix|ex)$/i', '\1ices');
+Inflector::plural('/([m|l])ouse$/i', '\1ice');
+Inflector::plural('/^(ox)$/i', '\1en');
+Inflector::plural('/(quiz)$/i', '\1zes');
+
+Inflector::singular('/s$/i', '');
+Inflector::singular('/(n)ews$/i', '\1ews');
+Inflector::singular('/([ti])a$/i', '\1um');
+Inflector::singular('/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i', '\1\2sis');
+Inflector::singular('/(^analy)ses$/i', '\1sis');
+Inflector::singular('/([^f])ves$/i', '\1fe');
+Inflector::singular('/(hive)s$/i', '\1');
+Inflector::singular('/(tive)s$/i', '\1');
+Inflector::singular('/([lr])ves$/i', '\1f');
+Inflector::singular('/([^aeiouy]|qu)ies$/i', '\1y');
+Inflector::singular('/(s)eries$/i', '\1eries');
+Inflector::singular('/(m)ovies$/i', '\1ovie');
+Inflector::singular('/(x|ch|ss|sh)es$/i', '\1');
+Inflector::singular('/([m|l])ice$/i', '\1ouse');
+Inflector::singular('/(bus)es$/i', '\1');
+Inflector::singular('/(o)es$/i', '\1');
+Inflector::singular('/(shoe)s$/i', '\1');
+Inflector::singular('/(cris|ax|test)es$/i', '\1is');
+Inflector::singular('/(octop|vir)i$/i', '\1us');
+Inflector::singular('/(alias|status)es$/i', '\1');
+Inflector::singular('/^(ox)en/i', '\1');
+Inflector::singular('/(vert|ind)ices$/i', '\1ex');
+Inflector::singular('/(matr)ices$/i', '\1ix');
+Inflector::singular('/(quiz)zes$/i', '\1');
+Inflector::singular('/(database)s$/i', '\1');
+
+Inflector::irregular('person', 'people');
+Inflector::irregular('man', 'men');
+Inflector::irregular('child', 'children');
+Inflector::irregular('sex', 'sexes');
+Inflector::irregular('move', 'moves');
+Inflector::irregular('cow', 'cattle');
+
+Inflector::uncountable(array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans'));
diff --git a/src/Starlight/Component/Routing/Compilable.php b/src/Starlight/Component/Routing/Compilable.php
new file mode 100644
index 0000000..0aa1c82
--- /dev/null
+++ b/src/Starlight/Component/Routing/Compilable.php
@@ -0,0 +1,20 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\Routing;
+
+
+/**
+ * Compilable interface
+ */
+interface Compilable
+{
+ public function compile();
+};
\ No newline at end of file
diff --git a/src/Starlight/Component/Routing/Resource.php b/src/Starlight/Component/Routing/Resource.php
new file mode 100644
index 0000000..414c97b
--- /dev/null
+++ b/src/Starlight/Component/Routing/Resource.php
@@ -0,0 +1,127 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\Routing;
+use Starlight\Component\Inflector\Inflector;
+
+
+/**
+ * Route
+ */
+class Resource implements Compilable
+{
+ /**
+ * RESTful routing map; maps actions to methods
+ * @var array
+ */
+ protected static $resources_map = array(
+ 'index' => array('method' => 'get', 'path' => '/'),
+ 'add' => array('method' => 'get', 'path' => '/:action'),
+ 'create' => array('method' => 'post', 'path' => '/'),
+ 'show' => array('method' => 'get', 'path' => '/:id'),
+ 'edit' => array('method' => 'get', 'path' => '/:id/:action'),
+ 'update' => array('method' => 'put', 'path' => '/:id'),
+ 'delete' => array('method' => 'get', 'path' => '/:id/:action'),
+ 'destroy' => array('method' => 'delete', 'path' => '/:id'),
+ );
+
+
+ public $resource;
+ public $except;
+ public $only;
+ public $controller;
+ public $constraints;
+ public $name;
+ public $path_names;
+ // member, collection, resources (nested)
+
+
+ /**
+ *
+ */
+ public function __construct($resource)
+ {
+ $this->resource = $resource;
+ }
+
+ /**
+ *
+ */
+ public function except(array $except)
+ {
+ $this->only = null;
+ $this->except = $except;
+
+ // array_diff_key(static::$resources_map, array_fill_keys($except, true));
+
+ return $this;
+ }
+
+ /**
+ *
+ */
+ public function only(array $only)
+ {
+ $this->except = null;
+ $this->only = $only;
+
+ // array_intersect_key(static::$resources_map, array_fill_keys($except, true));
+
+ return $this;
+ }
+
+ /**
+ *
+ */
+ public function controller($controller)
+ {
+ $this->controller = $controller;
+
+ return $this;
+ }
+
+ /**
+ *
+ */
+ public function constraints($constraints)
+ {
+ $this->constraints = $constraints;
+
+ return $this;
+ }
+
+ /**
+ *
+ */
+ public function name($name)
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ /**
+ *
+ */
+ public function pathNames(array $names)
+ {
+ $this->path_names = $names;
+
+ return $this;
+ }
+
+
+ /**
+ *
+ */
+ public function compile()
+ {
+ }
+};
diff --git a/src/Starlight/Component/Routing/Routable.php b/src/Starlight/Component/Routing/Routable.php
new file mode 100644
index 0000000..0bebc32
--- /dev/null
+++ b/src/Starlight/Component/Routing/Routable.php
@@ -0,0 +1,20 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\Routing;
+
+
+/**
+ * Route
+ */
+interface Routable
+{
+ public function match($path);
+};
diff --git a/src/Starlight/Component/Routing/Route.php b/src/Starlight/Component/Routing/Route.php
new file mode 100644
index 0000000..0355600
--- /dev/null
+++ b/src/Starlight/Component/Routing/Route.php
@@ -0,0 +1,149 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\Routing;
+
+
+/**
+ * Route
+ */
+class Route implements Routable, Compilable
+{
+ /**
+ * URL path separators regex
+ * '\' and '.'
+ * @var string
+ */
+ protected static $separator_regex = '/([\/\.])/i';
+
+ /**
+ * Base default values for route parameters
+ * @var array
+ */
+ protected static $base_defaults = array(
+ 'controller' => null,
+ 'action' => null,
+ 'id' => null,
+ );
+
+
+ public $path;
+ public $endpoint;
+ public $patterns = array();
+ public $regex;
+ public $parameters;
+ public $constraints;
+ public $methods;
+ public $name;
+ public $namespace;
+
+
+ /**
+ *
+ */
+ public function __construct($path, $endpoint)
+ {
+ $this->path = $path;
+ $this->endpoint = $endpoint;
+
+ // $elements = preg_split(static::$separator_regex, trim($this->path, '/'), -1, PREG_SPLIT_DELIM_CAPTURE);
+ // if (count($elements) == 0) {
+ // return;
+ // }
+ //
+ // array_unshift($elements, '/');
+ // $count = count($elements);
+ // $names = array();
+ //
+ // for ($i=0; $i<$count; $i = $i+2) {
+ // $sep = $elements[$i];
+ // $elm = $elements[$i+1];
+ //
+ // if (preg_match('/^\*(.+)$/', $elm, $match)) {
+ // // is the glob character:
+ // $this->patterns[] = '(?:\\' . $sep . '(.*+))?';
+ // $names[$match[1]] = null;
+ // } elseif (preg_match('/^:(.+)$/', $elm, $match)) {
+ // // is a named element:
+ // $this->patterns[] = '(?:\\' . $sep . '([^\/\.]+))?';
+ // $names[$match[1]] = null;
+ // } else {
+ // // just plain text:
+ // $this->patterns[] = '\\' . $sep . $elm;
+ // }
+ // }
+ //
+ // // $this->regex = '/^' . implode($patterns) . '\/?$/i';
+ // $this->parameters = static::$base_defaults + $names;
+ //
+ // list($this->parameters['controller'], $this->parameters['action']) = explode('#', $this->endpoint);
+ }
+
+ /**
+ *
+ */
+ public function defaults(array $defaults)
+ {
+ foreach ($defaults as $key => $value) {
+ if (trim($this->parameters[$key]) == '') {
+ $this->parameters[$key] = $value;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ *
+ */
+ public function constraints($constraints)
+ {
+ $this->constraints = $constraints;
+
+ return $this;
+ }
+
+ /**
+ *
+ */
+ public function methods(array $methods)
+ {
+ $this->methods = $methods;
+
+ return $this;
+ }
+
+ /**
+ *
+ */
+ public function name($name)
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ public function namespaced($namespace)
+ {
+ $this->namespace = $namespace;
+ // array_unshift($this->patterns, '\\/' . $namespace);
+
+ return $this;
+ }
+
+ public function compile()
+ {
+ }
+
+ public function match($path)
+ {
+
+ }
+};
diff --git a/src/Starlight/Component/Routing/Router.php b/src/Starlight/Component/Routing/Router.php
new file mode 100644
index 0000000..dbc54c1
--- /dev/null
+++ b/src/Starlight/Component/Routing/Router.php
@@ -0,0 +1,37 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\Routing;
+
+
+/**
+ * Router
+ */
+class Router
+{
+ protected static $routes = array();
+ protected static $resources = array();
+
+
+ public static function match($path, $endpoint)
+ {
+ static::$routes[] = new Route($path, $endpoint);
+
+ return static::$routes[count(static::$routes) - 1];
+ }
+
+
+ public static function resources($resource)
+ {
+ static::$resources[] = new Resource($resource);
+
+ return static::$resources[count(static::$resources) - 1];
+ }
+};
diff --git a/src/Starlight/Framework/Support/UniversalClassLoader.php b/src/Starlight/Framework/Support/UniversalClassLoader.php
index 12d4c86..51b7aa2 100755
--- a/src/Starlight/Framework/Support/UniversalClassLoader.php
+++ b/src/Starlight/Framework/Support/UniversalClassLoader.php
@@ -1,149 +1,150 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Starlight\Framework\Support;
/**
* UniversalClassLoader implements a "universal" autoloader for PHP 5.3.
*
* It is able to load classes that use either:
*
* * The technical interoperability standards for PHP 5.3 namespaces and
* class names (http://groups.google.com/group/php-standards/web/psr-0-final-proposal);
*
* * The PEAR naming convention for classes (http://pear.php.net/).
*
* Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be
* looked for in a list of locations to ease the vendoring of a sub-set of
* classes for large projects.
*
* Example usage:
*
* $loader = new UniversalClassLoader();
*
* // register classes with namespaces
* $loader->registerNamespaces(array(
* 'Starlight\Support' => __DIR__.'/component',
* 'Starlight' => __DIR__.'/framework',
* ));
*
* // register a library using the PEAR naming convention
* $loader->registerPrefixes(array(
* 'Swift_' => __DIR__.'/Swift',
* ));
*
* // activate the autoloader
* $loader->register();
*
* In this example, if you try to use a class in the Starlight\Support
* namespace or one of its children (Starlight\Support\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*/
class UniversalClassLoader
{
/**
* Current namespaces
* @var array
*/
protected $namespaces = array();
/**
* Current prefixes
* @var array
*/
protected $prefixes = array();
/**
* Get current namespaces
*
* @return array current namespaces
*/
public function getNamespaces()
{
return $this->namespaces;
}
/**
* Get current prefixes
*
* @return array current prefixes
*/
public function getPrefixes()
{
return $this->prefixes;
}
/**
* Registers an array of namespaces
*
* @param array $namespaces An array of namespaces (namespaces as keys and locations as values)
*/
public function registerNamespaces(array $namespaces)
{
$this->namespaces = array_merge($this->namespaces, $namespaces);
}
/**
* Registers a namespace.
*
* @param string $namespace The namespace
* @param string $path The location of the namespace
*/
public function registerNamespace($namespace, $path)
{
$this->namespaces[$namespace] = $path;
}
/**
* Register with the php autoload subsystem
*/
public function register()
{
spl_autoload_register(array($this, 'load'));
}
/**
* Loads the given class/interface
*
* @param string $class fully-qualified class name to load
*/
public function load($class)
{
if (($pos = stripos($class, '\\')) !== false) {
// namespace
$namespace = substr($class, 0, $pos);
foreach ($this->namespaces as $ns => $dir) {
if (strpos($namespace, $ns) === 0) {
- $file = $dir . DIRECTORY_SEPARATOR . str_replace(array('\\', '_'), DIRECTORY_SEPARATOR, $class) . '.php';
+ $class = substr($class, $pos + 1);
+ $file = $dir . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
if (file_exists($file)) {
- require $file;
+ require_once $file;
}
-
+
return;
}
}
} else {
// PEAR style
foreach ($this->prefixes as $prefix => $dir) {
if (strpos($class, $prefix) === 0) {
$file = $dir . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
if (file_exists($file)) {
- require $file;
+ require_once $file;
}
return;
}
}
}
}
};
diff --git a/src/Starlight/Framework/bootloader.php b/src/Starlight/Framework/bootloader.php
index e862732..c6a20ef 100755
--- a/src/Starlight/Framework/bootloader.php
+++ b/src/Starlight/Framework/bootloader.php
@@ -1,31 +1,51 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
-require __DIR__ . DIRECTORY_SEPARATOR . 'Support' . DIRECTORY_SEPARATOR . 'UniversalClassLoader.php';
+error_reporting(-1);
+
+require_once __DIR__ . DIRECTORY_SEPARATOR . 'Support' . DIRECTORY_SEPARATOR . 'UniversalClassLoader.php';
$autoloader = new \Starlight\Framework\Support\UniversalClassLoader();
$autoloader->registerNamespaces(array(
- 'Starlight' => realpath(dirname(__FILE__) . '/../../'),
+ 'Starlight' => __DIR__ . '/../../',
));
$autoloader->register();
function dump()
{
foreach (func_get_args() as $arg) {
echo '<pre>' . print_r($arg, true) . '</pre>';
echo '<hr />';
}
}
-$dispatcher = new \Starlight\Component\Dispatcher\HttpDispatcher();
-$dispatcher->dispatch(new \Starlight\Component\Http\Request());
-dump($dispatcher);
+// $dispatcher = new \Starlight\Component\Dispatcher\HttpDispatcher();
+// $dispatcher->dispatch(new \Starlight\Component\Http\Request());
+// dump($dispatcher);
+
+//\Starlight\Framework\Kernel::initialize();
+
+// $r->match('/some/url/to/match', 'controller#hellyeah');
-//\Starlight\Framework\Kernel::initialize();
\ No newline at end of file
+// $route = \Starlight\Component\Routing\Router::match('/pages/*junk/anything/:id', 'pages#view')
+// ->defaults(array('controller' => 'anything'))
+// ->methods(array('post', 'get'))
+// ->constraints(array('id' => '/[0-9]+/i'))
+// ->name('junk_stuff')
+// ->namespaced('admin')
+// ;
+// // ->constraints(function($request){
+// // return false;
+// // });
+// $route = \Starlight\Component\Routing\Router::resources('photos')
+// ->except(array('index'))
+// ;
+//
+// dump($route);
diff --git a/tests/Starlight/Component/Inflector/InflectorTest.php b/tests/Starlight/Component/Inflector/InflectorTest.php
new file mode 100644
index 0000000..08bbacc
--- /dev/null
+++ b/tests/Starlight/Component/Inflector/InflectorTest.php
@@ -0,0 +1,367 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Tests\Component\Inflector;
+use Starlight\Component\Inflector\Inflector;
+
+
+/**
+ */
+class InflectorTest extends \PHPUnit_Framework_TestCase
+{
+ protected static $singular_to_plural = array(
+ 'search' => 'searches',
+ 'switch' => 'switches',
+ 'fix' => 'fixes',
+ 'box' => 'boxes',
+ 'process' => 'processes',
+ 'address' => 'addresses',
+ 'case' => 'cases',
+ 'stack' => 'stacks',
+ 'wish' => 'wishes',
+ 'fish' => 'fish',
+ 'category' => 'categories',
+ 'query' => 'queries',
+ 'ability' => 'abilities',
+ 'agency' => 'agencies',
+ 'movie' => 'movies',
+ 'archive' => 'archives',
+ 'index' => 'indices',
+ 'wife' => 'wives',
+ 'safe' => 'saves',
+ 'half' => 'halves',
+ 'move' => 'moves',
+ 'salesperson' => 'salespeople',
+ 'person' => 'people',
+ 'spokesman' => 'spokesmen',
+ 'man' => 'men',
+ 'woman' => 'women',
+ 'basis' => 'bases',
+ 'diagnosis' => 'diagnoses',
+ 'diagnosis_a' => 'diagnosis_as',
+ 'datum' => 'data',
+ 'medium' => 'media',
+ 'analysis' => 'analyses',
+ 'node_child' => 'node_children',
+ 'child' => 'children',
+ 'experience' => 'experiences',
+ 'day' => 'days',
+ 'comment' => 'comments',
+ 'foobar' => 'foobars',
+ 'newsletter' => 'newsletters',
+ 'old_news' => 'old_news',
+ 'news' => 'news',
+ 'series' => 'series',
+ 'species' => 'species',
+ 'quiz' => 'quizzes',
+ 'perspective' => 'perspectives',
+ 'ox' => 'oxen',
+ 'photo' => 'photos',
+ 'buffalo' => 'buffaloes',
+ 'tomato' => 'tomatoes',
+ 'dwarf' => 'dwarves',
+ 'elf' => 'elves',
+ 'information' => 'information',
+ 'equipment' => 'equipment',
+ 'bus' => 'buses',
+ 'status' => 'statuses',
+ 'status_code' => 'status_codes',
+ 'mouse' => 'mice',
+ 'louse' => 'lice',
+ 'house' => 'houses',
+ 'octopus' => 'octopi',
+ 'virus' => 'viri',
+ 'alias' => 'aliases',
+ 'portfolio' => 'portfolios',
+ 'vertex' => 'vertices',
+ 'matrix' => 'matrices',
+ 'matrix_fu' => 'matrix_fus',
+ 'axis' => 'axes',
+ 'testis' => 'testes',
+ 'crisis' => 'crises',
+ 'rice' => 'rice',
+ 'shoe' => 'shoes',
+ 'horse' => 'horses',
+ 'prize' => 'prizes',
+ 'edge' => 'edges',
+ 'cow' => 'cattle',
+ 'database' => 'databases',
+ );
+
+ protected static $string_to_normalized = array(
+ 'Donald E. Knuth' => 'donald-e-knuth',
+ 'Random text with *(bad)* characters' => 'random-text-with-bad-characters',
+ 'Allow_Under_Scores' => 'allow_under_scores',
+ 'Trailing bad characters!@#' => 'trailing-bad-characters',
+ '!@#Leading bad characters' => 'leading-bad-characters',
+ 'Squeeze separators' => 'squeeze-separators',
+ );
+
+ protected static $string_to_normalized_no_sep = array(
+ 'Donald E. Knuth' => 'donaldeknuth',
+ 'Random text with *(bad)* characters' => 'randomtextwithbadcharacters',
+ 'Trailing bad characters!@#' => 'trailingbadcharacters',
+ '!@#Leading bad characters' => 'leadingbadcharacters',
+ 'Squeeze separators' => 'squeezeseparators',
+ );
+
+ protected static $string_to_normalized_with_underscore = array(
+ 'Donald E. Knuth' => 'donald_e_knuth',
+ 'Random text with *(bad)* characters' => 'random_text_with_bad_characters',
+ 'Trailing bad characters!@#' => 'trailing_bad_characters',
+ '!@#Leading bad characters' => 'leading_bad_characters',
+ 'Squeeze separators' => 'squeeze_separators',
+ );
+
+ protected static $string_to_title = array(
+ 'starlight_base' => 'Starlight Base',
+ 'StarlightBase' => 'Starlight Base',
+ 'starlight base code' => 'Starlight Base Code',
+ 'Starlight base Code' => 'Starlight Base Code',
+ 'Starlight Base Code' => 'Starlight Base Code',
+ 'starlightbasecode' => 'Starlightbasecode',
+ 'Starlightbasecode' => 'Starlightbasecode',
+ 'Person\'s stuff' => 'Person\'s Stuff',
+ 'person\'s Stuff' => 'Person\'s Stuff',
+ 'Person\'s Stuff' => 'Person\'s Stuff',
+ );
+
+ protected static $camel_to_underscore = array(
+ 'Product' => 'product',
+ 'SpecialGuest' => 'special_guest',
+ 'ApplicationController' => 'application_controller',
+ 'Area51Controller' => 'area51_controller',
+ );
+
+ protected static $camel_to_underscore_wo_rev = array(
+ 'HTMLTidy' => 'html_tidy',
+ 'HTMLTidyGenerator' => 'html_tidy_generator',
+ 'FreeBSD' => 'free_bsd',
+ 'HTML' => 'html',
+ );
+
+ protected static $class_to_fk_underscore = array(
+ 'Person' => 'person_id',
+ );
+
+ protected static $class_to_fk_no_underscore = array(
+ 'Person' => 'personid',
+ );
+
+ protected static $class_to_table = array(
+ 'PrimarySpokesman' => 'primary_spokesmen',
+ 'NodeChild' => 'node_children',
+ );
+
+ protected static $underscore_to_human = array(
+ 'employee_salary' => 'Employee salary',
+ 'employee_id' => 'Employee',
+ 'underground' => 'Underground',
+ );
+
+ protected static $ordinals = array(
+ '0' => '0th',
+ '1' => '1st',
+ '2' => '2nd',
+ '3' => '3rd',
+ '4' => '4th',
+ '5' => '5th',
+ '6' => '6th',
+ '7' => '7th',
+ '8' => '8th',
+ '9' => '9th',
+ '10' => '10th',
+ '11' => '11th',
+ '12' => '12th',
+ '13' => '13th',
+ '14' => '14th',
+ '20' => '20th',
+ '21' => '21st',
+ '22' => '22nd',
+ '23' => '23rd',
+ '24' => '24th',
+ '100' => '100th',
+ '101' => '101st',
+ '102' => '102nd',
+ '103' => '103rd',
+ '104' => '104th',
+ '110' => '110th',
+ '111' => '111th',
+ '112' => '112th',
+ '113' => '113th',
+ '1000' => '1000th',
+ '1001' => '1001st',
+ );
+
+ protected static $underscores_to_dashes = array(
+ 'street' => 'street',
+ 'street_address' => 'street-address',
+ 'person_street_address' => 'person-street-address',
+ );
+
+ protected static $underscores_to_lower_camel = array(
+ 'product' => 'product',
+ 'special_guest' => 'specialGuest',
+ 'application_controller' => 'applicationController',
+ 'area51_controller' => 'area51Controller',
+ );
+
+
+ public function testPluralizePlurals()
+ {
+ $this->assertEquals('plurals', Inflector::pluralize('plurals'));
+ $this->assertEquals('Plurals', Inflector::pluralize('Plurals'));
+ }
+
+ public function testPluralizeEmptyString()
+ {
+ $this->assertEquals('', Inflector::pluralize(''));
+ }
+
+ public function testSingularToPlural()
+ {
+ foreach (self::$singular_to_plural as $singular => $plural) {
+ $this->assertEquals($plural, Inflector::pluralize($singular));
+ $this->assertEquals(ucfirst($plural), Inflector::pluralize(ucfirst($singular)));
+ $this->assertEquals($singular, Inflector::singularize($plural));
+ $this->assertEquals(ucfirst($singular), Inflector::singularize(ucfirst($plural)));
+ }
+ }
+
+ public function testCamelize()
+ {
+ foreach (self::$camel_to_underscore as $camel => $underscore) {
+ $this->assertEquals($camel, Inflector::camelize($underscore));
+ }
+ }
+
+ public function testOverwritePreviousInflectors()
+ {
+ $this->assertEquals('series', Inflector::singularize('series'));
+ Inflector::singular('series', 'serie');
+ $this->assertEquals('serie', Inflector::singularize('series'));
+ Inflector::uncountable('series');
+
+ $this->assertEquals('series', Inflector::pluralize('series'));
+ Inflector::plural('series', 'seria');
+ $this->assertEquals('seria', Inflector::pluralize('series'));
+ Inflector::uncountable('series');
+
+ $this->assertEquals('dies', Inflector::pluralize('die'));
+ Inflector::irregular('die', 'dice');
+ $this->assertEquals('dice', Inflector::pluralize('die'));
+ $this->assertEquals('die', Inflector::singularize('dice'));
+ }
+
+ public function testTitleize()
+ {
+ foreach (self::$string_to_title as $before => $title) {
+ $this->assertEquals($title, Inflector::titleize($before));
+ }
+ }
+
+ public function testNormalize()
+ {
+ foreach (self::$string_to_normalized as $string => $normalized) {
+ $this->assertEquals($normalized, Inflector::normalize($string));
+ }
+ }
+
+ public function testNormalizeWithNoSeparator()
+ {
+ foreach (self::$string_to_normalized_no_sep as $string => $normalized) {
+ $this->assertEquals($normalized, Inflector::normalize($string, ''));
+ }
+ }
+
+ public function testNormalizeWithUnderscore()
+ {
+ foreach (self::$string_to_normalized_with_underscore as $string => $normalized) {
+ $this->assertEquals($normalized, Inflector::normalize($string, '_'));
+ }
+ }
+
+ public function testCamelizeLowercasesFirstLetter()
+ {
+ $this->assertEquals('capitalPlayersLeague', Inflector::camelize('Capital_players_League', false));
+ }
+
+ public function testUnderscore()
+ {
+ foreach (self::$camel_to_underscore as $camel => $underscore) {
+ $this->assertEquals($underscore, Inflector::underscore($camel));
+ }
+
+ foreach (self::$camel_to_underscore_wo_rev as $camel => $underscore) {
+ $this->assertEquals($underscore, Inflector::underscore($camel));
+ }
+ }
+
+ public function testforeignKey()
+ {
+ foreach (self::$class_to_fk_underscore as $klass => $fk) {
+ $this->assertEquals($fk, Inflector::foreignKey($klass));
+ }
+
+ foreach (self::$class_to_fk_no_underscore as $klass => $fk) {
+ $this->assertEquals($fk, Inflector::foreignKey($klass, false));
+ }
+ }
+
+ public function testTableize()
+ {
+ foreach (self::$class_to_table as $klass => $table) {
+ $this->assertEquals($table, Inflector::tableize($klass));
+ }
+ }
+
+ public function testClassify()
+ {
+ foreach (self::$class_to_table as $klass => $table) {
+ $this->assertEquals($klass, Inflector::classify($table));
+ $this->assertEquals($klass, Inflector::classify('prefix.' . $table));
+ }
+ }
+
+ public function testHumanize()
+ {
+ foreach (self::$underscore_to_human as $underscore => $human) {
+ $this->assertEquals($human, Inflector::humanize($underscore));
+ }
+ }
+
+ public function testOrdinal()
+ {
+ foreach (self::$ordinals as $number => $ordinal) {
+ $this->assertEquals($ordinal, Inflector::ordinalize($number));
+ }
+ }
+
+ public function testDasherize()
+ {
+ foreach (self::$underscores_to_dashes as $underscored => $dashes) {
+ $this->assertEquals($dashes, Inflector::dasherize($underscored));
+ }
+ }
+
+ public function testUnderscoreAsReverseOfDasherize()
+ {
+ foreach (self::$underscores_to_dashes as $underscored => $dashes) {
+ $this->assertEquals($underscored, Inflector::underscore(Inflector::dasherize($underscored)));
+ }
+ }
+
+ public function testUnderscoreToLowerCamel()
+ {
+ foreach (self::$underscores_to_lower_camel as $underscored => $lower_camel) {
+ $this->assertEquals($lower_camel, Inflector::camelize($underscored, false));
+ }
+ }
+};
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
new file mode 100644
index 0000000..4a8c49c
--- /dev/null
+++ b/tests/bootstrap.php
@@ -0,0 +1,15 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+if (file_exists($file = __DIR__ . '/../autoload.php')) {
+ require_once $file;
+} elseif (file_exists($file = __DIR__ . '/../autoload.php.dist')) {
+ require_once $file;
+}
\ No newline at end of file
|
synewaves/starlight
|
3dd0e813934a1294e7f47ae1c7c1c6fd4fe7dc95
|
Remove array_merge to use + operator
|
diff --git a/src/Starlight/Component/Http/HeaderBucket.php b/src/Starlight/Component/Http/HeaderBucket.php
index 2ac828f..69ad3fa 100755
--- a/src/Starlight/Component/Http/HeaderBucket.php
+++ b/src/Starlight/Component/Http/HeaderBucket.php
@@ -1,282 +1,282 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Starlight\Component\Http;
/**
* Wrapper class for request/response headers
*/
class HeaderBucket
{
/**
* Headers
* @var array
*/
protected $headers;
// /**
// * Wrapper class for request/response headers
// */
// protected $cache_control;
/**
* Type (request, response)
* @var string
*/
protected $type;
/**
* Constructor
* @param array $headers An array of HTTP headers
* @param string $type The type (null, request, or response)
*/
public function __construct(array $headers = array(), $type = null)
{
$this->replace($headers);
if ($type !== null && !in_array($type, array('request', 'response'))) {
throw new \InvalidArgumentException(sprintf('The "%s" type is not supported by the HeaderBucket.', $type));
}
$this->type = $type;
}
/**
* Returns the headers
* @return array An array of headers
*/
public function all()
{
return $this->headers;
}
/**
* Returns the parameter keys
* @return array An array of parameter keys
*/
public function keys()
{
return array_keys($this->headers);
}
/**
* Replaces the current HTTP headers by a new set
* @param array $headers An array of HTTP headers
*/
public function replace(array $headers = array())
{
$this->cache_control = null;
$this->headers = array();
foreach ($headers as $key => $values) {
$this->set($key, $values);
}
}
/**
* Returns a header value by name
* @param string $key The header name
* @param Boolean $first Whether to return the first value or all header values
* @return string|array The first header value if $first is true, an array of values otherwise
*/
public function get($key, $first = true)
{
$key = self::normalizeHeaderName($key);
if (!array_key_exists($key, $this->headers)) {
return $first ? null : array();
}
if ($first) {
return count($this->headers[$key]) ? $this->headers[$key][0] : '';
} else {
return $this->headers[$key];
}
}
/**
* Sets a header by name
* @param string $key The key
* @param string|array $values The value or an array of values
* @param boolean $replace Whether to replace the actual value of not (true by default)
*/
public function set($key, $values, $replace = true)
{
$key = self::normalizeHeaderName($key);
if (!is_array($values)) {
$values = array($values);
}
if ($replace === true || !isset($this->headers[$key])) {
$this->headers[$key] = $values;
} else {
$this->headers[$key] = array_merge($this->headers[$key], $values);
}
}
/**
* Returns true if the HTTP header is defined
* @param string $key The HTTP header
* @return Boolean true if the parameter exists, false otherwise
*/
public function has($key)
{
return array_key_exists(self::normalizeHeaderName($key), $this->headers);
}
/**
* Returns true if the given HTTP header contains the given value
* @param string $key The HTTP header name
* @param string $value The HTTP value
* @return Boolean true if the value is contained in the header, false otherwise
*/
public function contains($key, $value)
{
return in_array($value, $this->get($key, false));
}
/**
* Deletes a header
* @param string $key The HTTP header name
*/
public function delete($key)
{
unset($this->headers[self::normalizeHeaderName($key)]);
}
// /**
// * Returns an instance able to manage the Cache-Control header.
// *
// * @return CacheControl A CacheControl instance
// */
// public function getCacheControl()
// {
// if (null === $this->cacheControl) {
// $this->cacheControl = new CacheControl($this, $this->get('Cache-Control'), $this->type);
// }
//
// return $this->cacheControl;
// }
/**
* Set cookie variable
*
* Available options:
*
* <ul>
* <li><b>expires</b> <i>(integer)</i>: cookie expiration time (default: 0 [end of session])</li>
* <li><b>path</b> <i>(string)</i>: path cookie is valid for (default: '')</li>
* <li><b>domain</b> <i>(string)</i>: domain cookie is valid for (default: '')</li>
* <li><b>secure/b> <i>(boolean)</i>: should cookie only be used on a secure connection (default: false)</li>
* <li><b>http_only</b> <i>(string)</i>: cookie only valid over http? [not supported by all browsers] (default: true)</li>
* <li><b>encode</b> <i>(boolean)</i>: urlencode cookie value (default: true)</li>
* </ul>
* @param string $key cookie key
* @param mixed $value value
* @param array $options options hash (see above)
*/
public function setCookie($name, $value, $options = array())
{
$default_options = array(
'expires' => null,
'path' => '',
'domain' => '',
'secure' => false,
'http_only' => true,
);
- $options = array_merge($default_options, $options);
+ $options += $default_options;
if (preg_match("/[=,; \t\r\n\013\014]/", $key)) {
throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $key));
}
if (preg_match("/[,; \t\r\n\013\014]/", $value)) {
throw new \InvalidArgumentException(sprintf('The cookie value "%s" contains invalid characters.', $value));
}
if (!$name) {
throw new \InvalidArgumentException('The cookie name cannot be empty');
}
$cookie = sprintf('%s=%s', $name, urlencode($value));
if ($this->type == 'request') {
$this->set('Cookie', $cookie);
return;
}
if ($options['expires'] !== null) {
if (is_numeric($options['expires'])) {
$options['expires'] = (int) $options['expires'];
} elseif ($options['expires'] instanceof \DateTime) {
$options['expires'] = $options['expires']->getTimestamp();
} else {
$expires = strtotime($options['expires']);
if ($expires === false || $expires == -1) {
throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid.', $expires));
}
}
$cookie .= '; expires=' . substr(\DateTime::createFromFormat('U', $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5);
}
if ($options['domain']) {
$cookie .= '; domain=' . $options['domain'];
}
if ($options['path'] !== '/') {
$cookie .= '; path=' . $path;
}
if ($options['secure']) {
$cookie .= '; secure';
}
if ($options['httponly']) {
$cookie .= '; httponly';
}
$this->set('Set-Cookie', $cookie, false);
}
/**
* Expire a cookie variable
* @param string $key cookie key
*/
public function expireCookie($key)
{
if ($this->type == 'request') {
return;
}
if (preg_match("/[=,; \t\r\n\013\014]/", $key)) {
throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $key));
}
if (!$name) {
throw new \InvalidArgumentException('The cookie name cannot be empty');
}
$cookie = sprintf('%s=; expires=', $name, substr(\DateTime::createFromFormat('U', time() - 3600, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5));
$this->set('Set-Cookie', $cookie, false);
}
/**
* Normalizes an HTTP header name
* @param string $key The HTTP header name
* @return string The normalized HTTP header name
*/
static public function normalizeHeaderName($key)
{
return strtr(strtolower($key), '_', '-');
}
};
diff --git a/src/Starlight/Component/Http/Request.php b/src/Starlight/Component/Http/Request.php
index a919cc9..b72e032 100755
--- a/src/Starlight/Component/Http/Request.php
+++ b/src/Starlight/Component/Http/Request.php
@@ -1,276 +1,276 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Starlight\Component\Http;
/**
* HTTP Request
*/
class Request
{
public $post;
public $get;
public $cookies;
public $files;
public $server;
public $headers;
protected $host;
protected $port;
protected $remote_ip;
/**
* Constructor
* @param array $post POST values
* @param array $get GET values
* @param array $cookies COOKIE values
* @param array $files FILES values
* @param array $server SERVER values
*/
public function __construct(array $post = null, array $get = null, array $cookies = null, array $files = null, array $server = null)
{
$this->post = new ParameterBucket($post ?: $_POST);
$this->get = new ParameterBucket($get ?: $_GET);
$this->cookies = new ParameterBucket($cookies ?: $_COOKIE);
$this->files = new ParameterBucket($files ?: $_FILES);
$this->server = new ParameterBucket($server ?: $_SERVER);
$this->headers = new HeaderBucket($this->initializeHeaders(), 'request');
}
/**
* Clone
*/
public function __clone()
{
$this->post = clone $this->post;
$this->get = clone $this->get;
$this->cookies = clone $this->cookies;
$this->files = clone $this->files;
$this->server = clone $this->server;
$this->headers = clone $this->headers;
}
/**
* Get a value from the request
*
* Order or precedence: GET, POST, COOKIE
*/
public function get($key, $default = null)
{
return $this->get->get($key, $this->post->get($key, $this->cookies->get($key, $default)));
}
/**
* Gets request method, lowercased
*
* Method can come from three places in this order:
* <ol>
* <li>$_POST[_method]</li>
* <li>$_SERVER[X_HTTP_METHOD_OVERRIDE]</li>
* <li>$_SERVER[REQUEST_METHOD]</li>
* </ol>
* @return string request method
*/
public function getMethod()
{
return strtolower($this->post->get('_method', $this->server->get('X_HTTP_METHOD_OVERRIDE', $this->server->get('REQUEST_METHOD'))));
}
/**
* Is this a DELETE request
* @return boolean is DELETE request
*/
public function isDelete()
{
return $this->getMethod() == 'delete';
}
/**
* Is this a GET request
* @see head()
* @return boolean is GET request
*/
public function isGet()
{
return $this->isHead();
}
/**
* Is this a POST request
* @return boolean is POST request
*/
public function isPost()
{
return $this->getMethod() == 'post';
}
/**
* Is this a HEAD request
*
* Functionally equivalent to get()
* @return boolean is HEAD request
*/
public function isHead()
{
return $this->getMethod() == 'head' || $this->getMethod() == 'get';
}
/**
* Is this a PUT request
* @return boolean is PUT request
*/
public function isPut()
{
return $this->getMethod() == 'put';
}
/**
* Is this an SSL request
* @return boolean is SSL request
*/
public function isSsl()
{
return strtolower($this->server->get('HTTPS')) == 'on';
}
/**
* Gets server protocol
* @return string protocol
*/
public function getProtocol()
{
return $this->isSsl() ? 'https://' : 'http://';
}
/**
* Gets the server host
* @return string host
*/
public function getHost()
{
if ($this->host === null) {
$host = $this->server->get('HTTP_X_FORWARDED_HOST', $this->server->get('HTTP_HOST'));
$pos = strpos($host, ':');
if ($pos !== false) {
$this->host = substr($host, 0, $pos);
$this->port = $this->port === null ? substr($host, $pos + 1) : null;
} else {
$this->host = $host;
}
}
return $this->host;
}
/**
* Gets the server port
* @return integer port
*/
public static function getPort()
{
if ($this->port === null) {
$this->port = $this->server->get('SERVER_PORT', $this->getStandardPort());
}
return $this->port;
}
/**
* Gets the standard port number for the current protocol
* @return integer port (443, 80)
*/
public static function getStandardPort()
{
return $this->isSsl() ? 443 : 80;
}
/**
* Gets the port string with colon delimiter if not standard port
* @return string port
*/
public function getPortString()
{
return (in_array($this->getPort(), array(443, 80))) ? '' : ':' . $this->getPort();
}
/**
* Gets the host with the port
* @return string host with port
*/
public function getHostWithPort()
{
return $this->getHost() . $this->getPortString();
}
/**
* Gets the client's remote ip
* @return string IP
*/
public function getRemoteIp()
{
- // if ($this->remote_ip === null) {
- // $remote_ips = null;
- // if ($x_forward = $this->server->get('HTTP_X_FORWARDED_FOR')) {
- // $remote_ips = array_map('trim', explode(',', $x_forward));
- // }
- //
- // $client_ip = $this->server->get('HTTP_CLIENT_IP');
- // if ($client_ip) {
- // if (is_array($remote_ips) && !in_array($client_ip, $remote_ips)) {
- // // don't know which came from the proxy, and which from the user
+ if ($this->remote_ip === null) {
+ $remote_ips = null;
+ if ($x_forward = $this->server->get('HTTP_X_FORWARDED_FOR')) {
+ $remote_ips = array_map('trim', explode(',', $x_forward));
+ }
+
+ $client_ip = $this->server->get('HTTP_CLIENT_IP');
+ if ($client_ip) {
+ if (is_array($remote_ips) && !in_array($client_ip, $remote_ips)) {
+ // don't know which came from the proxy, and which from the user
throw new Exception\IpSpoofingException(sprintf("IP spoofing attack?!\nHTTP_CLIENT_IP=%s\nHTTP_X_FORWARDED_FOR=%s", $this->server->get('HTTP_CLIENT_IP'), $this->server->get('HTTP_X_FORWARDED_FOR')));
- // }
- //
- // $this->remote_ip = $client_ip;
- // } elseif (is_array($remote_ips)) {
- // $this->remote_ip = $remote_ips[0];
- // } else {
- // $this->remote_ip = $this->server->get('REMOTE_ADDR');
- // }
- // }
- //
- // return $this->remote_ip;
+ }
+
+ $this->remote_ip = $client_ip;
+ } elseif (is_array($remote_ips)) {
+ $this->remote_ip = $remote_ips[0];
+ } else {
+ $this->remote_ip = $this->server->get('REMOTE_ADDR');
+ }
+ }
+
+ return $this->remote_ip;
}
/**
* Check if the request is an XMLHttpRequest (AJAX)
* @return boolean is XHR (AJAX) request
*/
public function isXmlHttpRequest()
{
return (bool) preg_match('/XMLHttpRequest/i', $this->server->get('HTTP_X_REQUESTED_WITH'));
}
/**
* Gets the full server url with protocol and port
* @return string server path
*/
public function getServer()
{
return $this->getProtocol() . $this->getHostWithPort();
}
/**
* Initialize request headers for HeaderBucket
* @return array headers
*/
protected function initializeHeaders()
{
$headers = array();
foreach ($this->server->all() as $key => $value) {
if (strtolower(substr($key, 0, 5)) === 'http_') {
$headers[substr($key, 5)] = $value;
}
}
return $headers;
}
};
diff --git a/src/Starlight/Framework/bootloader.php b/src/Starlight/Framework/bootloader.php
index ed05c16..e862732 100755
--- a/src/Starlight/Framework/bootloader.php
+++ b/src/Starlight/Framework/bootloader.php
@@ -1,32 +1,31 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
require __DIR__ . DIRECTORY_SEPARATOR . 'Support' . DIRECTORY_SEPARATOR . 'UniversalClassLoader.php';
$autoloader = new \Starlight\Framework\Support\UniversalClassLoader();
$autoloader->registerNamespaces(array(
'Starlight' => realpath(dirname(__FILE__) . '/../../'),
));
$autoloader->register();
function dump()
{
foreach (func_get_args() as $arg) {
echo '<pre>' . print_r($arg, true) . '</pre>';
echo '<hr />';
}
}
$dispatcher = new \Starlight\Component\Dispatcher\HttpDispatcher();
$dispatcher->dispatch(new \Starlight\Component\Http\Request());
dump($dispatcher);
-
//\Starlight\Framework\Kernel::initialize();
\ No newline at end of file
|
synewaves/starlight
|
8c23c101ad5ca53eac2aea37786f0f47dd2ac967
|
Added cookie handling to header
|
diff --git a/src/Starlight/Component/Dispatcher/HttpDispatcher.php b/src/Starlight/Component/Dispatcher/HttpDispatcher.php
old mode 100644
new mode 100755
diff --git a/src/Starlight/Component/Http/Exception/IpSpoofingException.php b/src/Starlight/Component/Http/Exception/IpSpoofingException.php
new file mode 100755
index 0000000..9d799d2
--- /dev/null
+++ b/src/Starlight/Component/Http/Exception/IpSpoofingException.php
@@ -0,0 +1,20 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\Http\Exception;
+
+
+/**
+ * IP Spoofing exception
+ * @see \Starlight\Component\Http\Request::getRemoteIp()
+ */
+class IpSpoofingException extends \Exception
+{
+};
\ No newline at end of file
diff --git a/src/Starlight/Component/Http/HeaderBucket.php b/src/Starlight/Component/Http/HeaderBucket.php
old mode 100644
new mode 100755
index 9765ace..2ac828f
--- a/src/Starlight/Component/Http/HeaderBucket.php
+++ b/src/Starlight/Component/Http/HeaderBucket.php
@@ -1,267 +1,282 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
-namespace Starlight\Component\HTTP;
+namespace Starlight\Component\Http;
/**
* Wrapper class for request/response headers
*/
class HeaderBucket
{
/**
* Headers
* @var array
*/
protected $headers;
// /**
// * Wrapper class for request/response headers
// */
// protected $cache_control;
/**
* Type (request, response)
* @var string
*/
protected $type;
/**
* Constructor
* @param array $headers An array of HTTP headers
* @param string $type The type (null, request, or response)
*/
public function __construct(array $headers = array(), $type = null)
{
$this->replace($headers);
if ($type !== null && !in_array($type, array('request', 'response'))) {
throw new \InvalidArgumentException(sprintf('The "%s" type is not supported by the HeaderBucket.', $type));
}
$this->type = $type;
}
/**
* Returns the headers
* @return array An array of headers
*/
public function all()
{
return $this->headers;
}
/**
* Returns the parameter keys
* @return array An array of parameter keys
*/
public function keys()
{
return array_keys($this->headers);
}
/**
* Replaces the current HTTP headers by a new set
* @param array $headers An array of HTTP headers
*/
public function replace(array $headers = array())
{
$this->cache_control = null;
$this->headers = array();
foreach ($headers as $key => $values) {
$this->set($key, $values);
}
}
/**
* Returns a header value by name
* @param string $key The header name
* @param Boolean $first Whether to return the first value or all header values
* @return string|array The first header value if $first is true, an array of values otherwise
*/
public function get($key, $first = true)
{
$key = self::normalizeHeaderName($key);
if (!array_key_exists($key, $this->headers)) {
return $first ? null : array();
}
if ($first) {
return count($this->headers[$key]) ? $this->headers[$key][0] : '';
} else {
return $this->headers[$key];
}
}
/**
* Sets a header by name
* @param string $key The key
* @param string|array $values The value or an array of values
* @param boolean $replace Whether to replace the actual value of not (true by default)
*/
public function set($key, $values, $replace = true)
{
$key = self::normalizeHeaderName($key);
if (!is_array($values)) {
$values = array($values);
}
if ($replace === true || !isset($this->headers[$key])) {
$this->headers[$key] = $values;
} else {
$this->headers[$key] = array_merge($this->headers[$key], $values);
}
}
/**
* Returns true if the HTTP header is defined
* @param string $key The HTTP header
* @return Boolean true if the parameter exists, false otherwise
*/
public function has($key)
{
return array_key_exists(self::normalizeHeaderName($key), $this->headers);
}
/**
* Returns true if the given HTTP header contains the given value
* @param string $key The HTTP header name
* @param string $value The HTTP value
* @return Boolean true if the value is contained in the header, false otherwise
*/
public function contains($key, $value)
{
return in_array($value, $this->get($key, false));
}
/**
* Deletes a header
* @param string $key The HTTP header name
*/
public function delete($key)
{
unset($this->headers[self::normalizeHeaderName($key)]);
}
// /**
// * Returns an instance able to manage the Cache-Control header.
// *
// * @return CacheControl A CacheControl instance
// */
// public function getCacheControl()
// {
// if (null === $this->cacheControl) {
// $this->cacheControl = new CacheControl($this, $this->get('Cache-Control'), $this->type);
// }
//
// return $this->cacheControl;
// }
- //
- // /**
- // * Sets a cookie.
- // *
- // * @param string $name The cookie name
- // * @param string $value The value of the cookie
- // * @param string $domain The domain that the cookie is available
- // * @param string $expire The time the cookie expires
- // * @param string $path The path on the server in which the cookie will be available on
- // * @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client
- // * @param bool $httponly When TRUE the cookie will not be made accessible to JavaScript, preventing XSS attacks from stealing cookies
- // *
- // * @throws \InvalidArgumentException When the cookie expire parameter is not valid
- // */
- // public function setCookie($name, $value, $domain = null, $expires = null, $path = '/', $secure = false, $httponly = true)
- // {
- // // from PHP source code
- // if (preg_match("/[=,; \t\r\n\013\014]/", $name)) {
- // throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name));
- // }
- //
- // if (preg_match("/[,; \t\r\n\013\014]/", $value)) {
- // throw new \InvalidArgumentException(sprintf('The cookie value "%s" contains invalid characters.', $name));
- // }
- //
- // if (!$name) {
- // throw new \InvalidArgumentException('The cookie name cannot be empty');
- // }
- //
- // $cookie = sprintf('%s=%s', $name, urlencode($value));
- //
- // if ('request' === $this->type) {
- // return $this->set('Cookie', $cookie);
- // }
- //
- // if (null !== $expires) {
- // if (is_numeric($expires)) {
- // $expires = (int) $expires;
- // } elseif ($expires instanceof \DateTime) {
- // $expires = $expires->getTimestamp();
- // } else {
- // $expires = strtotime($expires);
- // if (false === $expires || -1 == $expires) {
- // throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid.', $expires));
- // }
- // }
- //
- // $cookie .= '; expires='.substr(\DateTime::createFromFormat('U', $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5);
- // }
- //
- // if ($domain) {
- // $cookie .= '; domain='.$domain;
- // }
- //
- // if ('/' !== $path) {
- // $cookie .= '; path='.$path;
- // }
- //
- // if ($secure) {
- // $cookie .= '; secure';
- // }
- //
- // if ($httponly) {
- // $cookie .= '; httponly';
- // }
- //
- // $this->set('Set-Cookie', $cookie, false);
- // }
- //
- // /**
- // * Returns the HTTP header value converted to a date.
- // *
- // * @param string $key The parameter key
- // * @param \DateTime $default The default value
- // *
- // * @return \DateTime The filtered value
- // */
- // public function getDate($key, \DateTime $default = null)
- // {
- // if (null === $value = $this->get($key)) {
- // return $default;
- // }
- //
- // if (false === $date = \DateTime::createFromFormat(DATE_RFC2822, $value)) {
- // throw new \RuntimeException(sprintf('The %s HTTP header is not parseable (%s).', $key, $value));
- // }
- //
- // return $date;
- // }
+
+ /**
+ * Set cookie variable
+ *
+ * Available options:
+ *
+ * <ul>
+ * <li><b>expires</b> <i>(integer)</i>: cookie expiration time (default: 0 [end of session])</li>
+ * <li><b>path</b> <i>(string)</i>: path cookie is valid for (default: '')</li>
+ * <li><b>domain</b> <i>(string)</i>: domain cookie is valid for (default: '')</li>
+ * <li><b>secure/b> <i>(boolean)</i>: should cookie only be used on a secure connection (default: false)</li>
+ * <li><b>http_only</b> <i>(string)</i>: cookie only valid over http? [not supported by all browsers] (default: true)</li>
+ * <li><b>encode</b> <i>(boolean)</i>: urlencode cookie value (default: true)</li>
+ * </ul>
+ * @param string $key cookie key
+ * @param mixed $value value
+ * @param array $options options hash (see above)
+ */
+ public function setCookie($name, $value, $options = array())
+ {
+ $default_options = array(
+ 'expires' => null,
+ 'path' => '',
+ 'domain' => '',
+ 'secure' => false,
+ 'http_only' => true,
+ );
+ $options = array_merge($default_options, $options);
+
+ if (preg_match("/[=,; \t\r\n\013\014]/", $key)) {
+ throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $key));
+ }
+
+ if (preg_match("/[,; \t\r\n\013\014]/", $value)) {
+ throw new \InvalidArgumentException(sprintf('The cookie value "%s" contains invalid characters.', $value));
+ }
+
+ if (!$name) {
+ throw new \InvalidArgumentException('The cookie name cannot be empty');
+ }
+
+ $cookie = sprintf('%s=%s', $name, urlencode($value));
+
+ if ($this->type == 'request') {
+ $this->set('Cookie', $cookie);
+ return;
+ }
+
+ if ($options['expires'] !== null) {
+ if (is_numeric($options['expires'])) {
+ $options['expires'] = (int) $options['expires'];
+ } elseif ($options['expires'] instanceof \DateTime) {
+ $options['expires'] = $options['expires']->getTimestamp();
+ } else {
+ $expires = strtotime($options['expires']);
+ if ($expires === false || $expires == -1) {
+ throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid.', $expires));
+ }
+ }
+
+ $cookie .= '; expires=' . substr(\DateTime::createFromFormat('U', $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5);
+ }
+
+ if ($options['domain']) {
+ $cookie .= '; domain=' . $options['domain'];
+ }
+
+ if ($options['path'] !== '/') {
+ $cookie .= '; path=' . $path;
+ }
+
+ if ($options['secure']) {
+ $cookie .= '; secure';
+ }
+
+ if ($options['httponly']) {
+ $cookie .= '; httponly';
+ }
+
+ $this->set('Set-Cookie', $cookie, false);
+ }
+
+ /**
+ * Expire a cookie variable
+ * @param string $key cookie key
+ */
+ public function expireCookie($key)
+ {
+ if ($this->type == 'request') {
+ return;
+ }
+
+ if (preg_match("/[=,; \t\r\n\013\014]/", $key)) {
+ throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $key));
+ }
+
+ if (!$name) {
+ throw new \InvalidArgumentException('The cookie name cannot be empty');
+ }
+
+ $cookie = sprintf('%s=; expires=', $name, substr(\DateTime::createFromFormat('U', time() - 3600, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5));
+
+ $this->set('Set-Cookie', $cookie, false);
+ }
/**
* Normalizes an HTTP header name
* @param string $key The HTTP header name
* @return string The normalized HTTP header name
*/
static public function normalizeHeaderName($key)
{
return strtr(strtolower($key), '_', '-');
}
};
diff --git a/src/Starlight/Component/Http/ParameterBucket.php b/src/Starlight/Component/Http/ParameterBucket.php
index 5939455..47e18ef 100755
--- a/src/Starlight/Component/Http/ParameterBucket.php
+++ b/src/Starlight/Component/Http/ParameterBucket.php
@@ -1,110 +1,111 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
-namespace Starlight\Component\HTTP;
+namespace Starlight\Component\Http;
/**
* Wrapper class request parameters
* @see Request
*/
class ParameterBucket
{
/**
* Parameters
* @var array
*/
protected $parameters;
/**
* Constructor
* @param array $parameters Parameters
*/
public function __construct(array $parameters = array())
{
$this->replace($parameters);
}
/**
* Returns the parameters
* @return array Parameters
*/
public function all()
{
return $this->parameters;
}
/**
* Returns the parameter keys
* @return array Parameter keys
*/
public function keys()
{
return array_keys($this->parameters);
}
/**
* Replaces the current parameters by a new set
* @param array $parameters parameters
*/
public function replace(array $parameters = array())
{
$this->parameters = $parameters;
}
/**
* Adds parameters
* @param array $parameters parameters
*/
public function add(array $parameters = array())
{
$this->parameters = array_replace($this->parameters, $parameters);
}
/**
* Returns a parameter by name
* @param string $key The key
* @param mixed $default default value
+ * @return mixed value
*/
public function get($key, $default = null)
{
return array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default;
}
/**
* Sets a parameter by name
* @param string $key The key
* @param mixed $value value
*/
public function set($key, $value)
{
$this->parameters[$key] = $value;
}
/**
* Returns true if the parameter is defined
* @param string $key The key
- * @return Boolean true if the parameter exists, false otherwise
+ * @return boolean true if the parameter exists, false otherwise
*/
public function has($key)
{
return array_key_exists($key, $this->parameters);
}
/**
* Deletes a parameter
* @param string $key key
*/
public function delete($key)
{
unset($this->parameters[$key]);
}
};
diff --git a/src/Starlight/Component/Http/Request.php b/src/Starlight/Component/Http/Request.php
index 38d32cc..a919cc9 100755
--- a/src/Starlight/Component/Http/Request.php
+++ b/src/Starlight/Component/Http/Request.php
@@ -1,277 +1,276 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
-namespace Starlight\Component\HTTP;
+namespace Starlight\Component\Http;
/**
* HTTP Request
*/
class Request
{
public $post;
public $get;
public $cookies;
public $files;
public $server;
public $headers;
protected $host;
protected $port;
protected $remote_ip;
/**
* Constructor
* @param array $post POST values
* @param array $get GET values
* @param array $cookies COOKIE values
* @param array $files FILES values
* @param array $server SERVER values
*/
public function __construct(array $post = null, array $get = null, array $cookies = null, array $files = null, array $server = null)
{
$this->post = new ParameterBucket($post ?: $_POST);
$this->get = new ParameterBucket($get ?: $_GET);
$this->cookies = new ParameterBucket($cookies ?: $_COOKIE);
$this->files = new ParameterBucket($files ?: $_FILES);
$this->server = new ParameterBucket($server ?: $_SERVER);
$this->headers = new HeaderBucket($this->initializeHeaders(), 'request');
}
/**
* Clone
*/
public function __clone()
{
$this->post = clone $this->post;
$this->get = clone $this->get;
$this->cookies = clone $this->cookies;
$this->files = clone $this->files;
$this->server = clone $this->server;
$this->headers = clone $this->headers;
}
/**
* Get a value from the request
*
* Order or precedence: GET, POST, COOKIE
*/
public function get($key, $default = null)
{
return $this->get->get($key, $this->post->get($key, $this->cookies->get($key, $default)));
}
- /**
- * Gets request method, lowercased
- *
- * Method can come from three places in this order:
- * <ol>
- * <li>$_POST[_method]</li>
- * <li>$_SERVER[X_HTTP_METHOD_OVERRIDE]</li>
- * <li>$_SERVER[REQUEST_METHOD]</li>
- * </ol>
- * @return string request method
- */
+ /**
+ * Gets request method, lowercased
+ *
+ * Method can come from three places in this order:
+ * <ol>
+ * <li>$_POST[_method]</li>
+ * <li>$_SERVER[X_HTTP_METHOD_OVERRIDE]</li>
+ * <li>$_SERVER[REQUEST_METHOD]</li>
+ * </ol>
+ * @return string request method
+ */
public function getMethod()
{
return strtolower($this->post->get('_method', $this->server->get('X_HTTP_METHOD_OVERRIDE', $this->server->get('REQUEST_METHOD'))));
}
- /**
- * Is this a DELETE request
- * @return boolean is DELETE request
- */
+ /**
+ * Is this a DELETE request
+ * @return boolean is DELETE request
+ */
public function isDelete()
{
return $this->getMethod() == 'delete';
}
- /**
- * Is this a GET request
- * @see head()
- * @return boolean is GET request
- */
+ /**
+ * Is this a GET request
+ * @see head()
+ * @return boolean is GET request
+ */
public function isGet()
{
return $this->isHead();
}
- /**
- * Is this a POST request
- * @return boolean is POST request
- */
+ /**
+ * Is this a POST request
+ * @return boolean is POST request
+ */
public function isPost()
{
return $this->getMethod() == 'post';
}
- /**
- * Is this a HEAD request
- *
- * Functionally equivalent to get()
- * @return boolean is HEAD request
- */
+ /**
+ * Is this a HEAD request
+ *
+ * Functionally equivalent to get()
+ * @return boolean is HEAD request
+ */
public function isHead()
{
return $this->getMethod() == 'head' || $this->getMethod() == 'get';
}
- /**
- * Is this a PUT request
- * @return boolean is PUT request
- */
+ /**
+ * Is this a PUT request
+ * @return boolean is PUT request
+ */
public function isPut()
{
return $this->getMethod() == 'put';
}
/**
- * Is this an SSL request
- * @return boolean is SSL request
- */
- public function isSsl()
- {
- return strtolower($this->server->get('HTTPS')) == 'on';
- }
+ * Is this an SSL request
+ * @return boolean is SSL request
+ */
+ public function isSsl()
+ {
+ return strtolower($this->server->get('HTTPS')) == 'on';
+ }
- /**
- * Gets server protocol
- * @return string protocol
- */
- public function getProtocol()
- {
- return $this->isSsl() ? 'https://' : 'http://';
- }
-
- /**
- * Gets the server host
- * @return string host
- */
- public function getHost()
- {
- if ($this->host === null) {
- $host = $this->server->get('HTTP_X_FORWARDED_HOST', $this->server->get('HTTP_HOST'));
- $pos = strpos($host, ':');
- if ($pos !== false) {
- $this->host = substr($host, 0, $pos);
- $this->port = $this->port === null ? substr($host, $pos + 1) : null;
- } else {
- $this->host = $host;
- }
- }
-
- return $this->host;
- }
-
- /**
- * Gets the server port
- * @return integer port
- */
- public static function getPort()
- {
- if ($this->port === null) {
- $this->port = $this->server->get('SERVER_PORT', $this->getStandardPort());
- }
-
- return $this->port;
- }
+ /**
+ * Gets server protocol
+ * @return string protocol
+ */
+ public function getProtocol()
+ {
+ return $this->isSsl() ? 'https://' : 'http://';
+ }
+
+ /**
+ * Gets the server host
+ * @return string host
+ */
+ public function getHost()
+ {
+ if ($this->host === null) {
+ $host = $this->server->get('HTTP_X_FORWARDED_HOST', $this->server->get('HTTP_HOST'));
+ $pos = strpos($host, ':');
+ if ($pos !== false) {
+ $this->host = substr($host, 0, $pos);
+ $this->port = $this->port === null ? substr($host, $pos + 1) : null;
+ } else {
+ $this->host = $host;
+ }
+ }
+
+ return $this->host;
+ }
+
+ /**
+ * Gets the server port
+ * @return integer port
+ */
+ public static function getPort()
+ {
+ if ($this->port === null) {
+ $this->port = $this->server->get('SERVER_PORT', $this->getStandardPort());
+ }
+
+ return $this->port;
+ }
- /**
- * Gets the standard port number for the current protocol
- * @return integer port (443, 80)
- */
- public static function getStandardPort()
- {
- return $this->isSsl() ? 443 : 80;
- }
-
- /**
- * Gets the port string with colon delimiter if not standard port
- * @return string port
- */
- public function getPortString()
- {
- return (in_array($this->getPort(), array(443, 80))) ? '' : ':' . $this->getPort();
- }
-
- /**
- * Gets the host with the port
- * @return string host with port
- */
- public function getHostWithPort()
- {
- return $this->getHost() . $this->getPortString();
- }
-
- /**
- * Gets the client's remote ip
- * @return string IP
- */
- public function getRemoteIp()
- {
- if ($this->remote_ip === null) {
- $remote_ips = null;
- if ($x_forward = $this->server->get('HTTP_X_FORWARDED_FOR')) {
- $remote_ips = array_map('trim', explode(',', $x_forward));
- }
-
- $client_ip = $this->server->get('HTTP_CLIENT_IP');
- if ($client_ip) {
- if (is_array($remote_ips) && !in_array($client_ip, $remote_ips)) {
- // don't know which came from the proxy, and which from the user
- // sprintf("IP spoofing attack?!\nHTTP_CLIENT_IP=%s\nHTTP_X_FORWARDED_FOR=%s", self::env('HTTP_CLIENT_IP'), self::env('HTTP_X_FORWARDED_FOR')
- throw new \Exception();
- }
-
- $this->remote_ip = $client_ip;
- } elseif (is_array($remote_ips)) {
- $this->remote_ip = $remote_ips[0];
- } else {
- $this->remote_ip = $this->server->get('REMOTE_ADDR');
- }
- }
-
- return $this->remote_ip;
- }
-
- /**
- * Check if the request is an XMLHttpRequest (AJAX)
- * @return boolean is XHR (AJAX) request
- */
- public function isXmlHttpRequest()
- {
- return (bool) preg_match('/XMLHttpRequest/i', $this->server->get('HTTP_X_REQUESTED_WITH'));
- }
-
- /**
- * Gets the full server url with protocol and port
- * @return string server path
- */
- public function getServer()
- {
- return $this->getProtocol() . $this->getHostWithPort();
- }
-
- /**
- * Initialize request headers for HeaderBucket
- * @return array headers
- */
- protected function initializeHeaders()
- {
+ /**
+ * Gets the standard port number for the current protocol
+ * @return integer port (443, 80)
+ */
+ public static function getStandardPort()
+ {
+ return $this->isSsl() ? 443 : 80;
+ }
+
+ /**
+ * Gets the port string with colon delimiter if not standard port
+ * @return string port
+ */
+ public function getPortString()
+ {
+ return (in_array($this->getPort(), array(443, 80))) ? '' : ':' . $this->getPort();
+ }
+
+ /**
+ * Gets the host with the port
+ * @return string host with port
+ */
+ public function getHostWithPort()
+ {
+ return $this->getHost() . $this->getPortString();
+ }
+
+ /**
+ * Gets the client's remote ip
+ * @return string IP
+ */
+ public function getRemoteIp()
+ {
+ // if ($this->remote_ip === null) {
+ // $remote_ips = null;
+ // if ($x_forward = $this->server->get('HTTP_X_FORWARDED_FOR')) {
+ // $remote_ips = array_map('trim', explode(',', $x_forward));
+ // }
+ //
+ // $client_ip = $this->server->get('HTTP_CLIENT_IP');
+ // if ($client_ip) {
+ // if (is_array($remote_ips) && !in_array($client_ip, $remote_ips)) {
+ // // don't know which came from the proxy, and which from the user
+ throw new Exception\IpSpoofingException(sprintf("IP spoofing attack?!\nHTTP_CLIENT_IP=%s\nHTTP_X_FORWARDED_FOR=%s", $this->server->get('HTTP_CLIENT_IP'), $this->server->get('HTTP_X_FORWARDED_FOR')));
+ // }
+ //
+ // $this->remote_ip = $client_ip;
+ // } elseif (is_array($remote_ips)) {
+ // $this->remote_ip = $remote_ips[0];
+ // } else {
+ // $this->remote_ip = $this->server->get('REMOTE_ADDR');
+ // }
+ // }
+ //
+ // return $this->remote_ip;
+ }
+
+ /**
+ * Check if the request is an XMLHttpRequest (AJAX)
+ * @return boolean is XHR (AJAX) request
+ */
+ public function isXmlHttpRequest()
+ {
+ return (bool) preg_match('/XMLHttpRequest/i', $this->server->get('HTTP_X_REQUESTED_WITH'));
+ }
+
+ /**
+ * Gets the full server url with protocol and port
+ * @return string server path
+ */
+ public function getServer()
+ {
+ return $this->getProtocol() . $this->getHostWithPort();
+ }
+
+ /**
+ * Initialize request headers for HeaderBucket
+ * @return array headers
+ */
+ protected function initializeHeaders()
+ {
$headers = array();
foreach ($this->server->all() as $key => $value) {
if (strtolower(substr($key, 0, 5)) === 'http_') {
$headers[substr($key, 5)] = $value;
}
}
return $headers;
- }
+ }
};
|
synewaves/starlight
|
4e1eadc1adb3d9223fe38318bba5409440991a6b
|
Work on request parsing
|
diff --git a/Component/Http/Request.php b/Component/Http/Request.php
deleted file mode 100755
index 210bdbd..0000000
--- a/Component/Http/Request.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/*
- * This file is part of the Starlight framework.
- *
- * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-namespace Starlight\Component\HTTP;
-
-class Request
-{
- public $post;
- public $get;
- public $cookies;
- public $files;
- public $server;
-
-
- public function __construct(array $post = null, array $get = null, array $cookies = null, array $files = null, array $server = null)
- {
- $this->initialize($post, $get, $cookies, $files, $server);
- }
-
- public function initialize(array $post = null, array $get = null, array $cookies = null, array $files = null, array $server = null)
- {
- $this->post = new ParameterContainer($post ?: $_POST);
- $this->get = new ParameterContainer($get ?: $_GET);
- $this->cookies = new ParameterContainer($cookies ?: $_COOKIE);
- $this->files = new ParameterContainer($files ?: $_FILES);
- $this->server = new ParameterContainer($server ?: $_SERVER);
-
- }
-};
diff --git a/Framework/Kernel.php b/Framework/Kernel.php
deleted file mode 100755
index 214d2a5..0000000
--- a/Framework/Kernel.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-/*
- * This file is part of the Starlight framework.
- *
- * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-namespace Starlight\Framework;
-
-
-/**
- *
- */
-class Kernel
-{
- public static function initialize()
- {
- $app_base_path = realpath(dirname(__FILE__) . '/../../../') . DIRECTORY_SEPARATOR;
-
- $autoloader = new \Starlight\Framework\Support\UniversalClassLoader();
- $autoloader->registerNamespaces(array(
- 'Starlight' => $app_base_path . 'vendor',
- ));
- $autoloader->register();
- }
-};
\ No newline at end of file
diff --git a/Framework/bootloader.php b/src/Starlight/Component/Dispatcher/HttpDispatcher.php
old mode 100755
new mode 100644
similarity index 51%
rename from Framework/bootloader.php
rename to src/Starlight/Component/Dispatcher/HttpDispatcher.php
index 66894dd..2e21bb5
--- a/Framework/bootloader.php
+++ b/src/Starlight/Component/Dispatcher/HttpDispatcher.php
@@ -1,15 +1,23 @@
-<?php
-/*
- * This file is part of the Starlight framework.
- *
- * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-require __DIR__ . DIRECTORY_SEPARATOR . 'Kernel.php';
-require __DIR__ . DIRECTORY_SEPARATOR . 'Support' . DIRECTORY_SEPARATOR . 'UniversalClassLoader.php';
-
-
-\Starlight\Framework\Kernel::initialize();
\ No newline at end of file
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\Dispatcher;
+use \Starlight\Component\Http as Http;
+
+
+class HttpDispatcher
+{
+ protected $request;
+
+ public function dispatch(Http\Request $request)
+ {
+ $this->request = $request;
+ }
+};
diff --git a/src/Starlight/Component/Http/HeaderBucket.php b/src/Starlight/Component/Http/HeaderBucket.php
new file mode 100644
index 0000000..9765ace
--- /dev/null
+++ b/src/Starlight/Component/Http/HeaderBucket.php
@@ -0,0 +1,267 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\HTTP;
+
+
+/**
+ * Wrapper class for request/response headers
+ */
+class HeaderBucket
+{
+ /**
+ * Headers
+ * @var array
+ */
+ protected $headers;
+
+ // /**
+ // * Wrapper class for request/response headers
+ // */
+ // protected $cache_control;
+
+ /**
+ * Type (request, response)
+ * @var string
+ */
+ protected $type;
+
+
+ /**
+ * Constructor
+ * @param array $headers An array of HTTP headers
+ * @param string $type The type (null, request, or response)
+ */
+ public function __construct(array $headers = array(), $type = null)
+ {
+ $this->replace($headers);
+
+ if ($type !== null && !in_array($type, array('request', 'response'))) {
+ throw new \InvalidArgumentException(sprintf('The "%s" type is not supported by the HeaderBucket.', $type));
+ }
+ $this->type = $type;
+ }
+
+ /**
+ * Returns the headers
+ * @return array An array of headers
+ */
+ public function all()
+ {
+ return $this->headers;
+ }
+
+ /**
+ * Returns the parameter keys
+ * @return array An array of parameter keys
+ */
+ public function keys()
+ {
+ return array_keys($this->headers);
+ }
+
+ /**
+ * Replaces the current HTTP headers by a new set
+ * @param array $headers An array of HTTP headers
+ */
+ public function replace(array $headers = array())
+ {
+ $this->cache_control = null;
+ $this->headers = array();
+ foreach ($headers as $key => $values) {
+ $this->set($key, $values);
+ }
+ }
+
+ /**
+ * Returns a header value by name
+ * @param string $key The header name
+ * @param Boolean $first Whether to return the first value or all header values
+ * @return string|array The first header value if $first is true, an array of values otherwise
+ */
+ public function get($key, $first = true)
+ {
+ $key = self::normalizeHeaderName($key);
+
+ if (!array_key_exists($key, $this->headers)) {
+ return $first ? null : array();
+ }
+
+ if ($first) {
+ return count($this->headers[$key]) ? $this->headers[$key][0] : '';
+ } else {
+ return $this->headers[$key];
+ }
+ }
+
+ /**
+ * Sets a header by name
+ * @param string $key The key
+ * @param string|array $values The value or an array of values
+ * @param boolean $replace Whether to replace the actual value of not (true by default)
+ */
+ public function set($key, $values, $replace = true)
+ {
+ $key = self::normalizeHeaderName($key);
+
+ if (!is_array($values)) {
+ $values = array($values);
+ }
+
+ if ($replace === true || !isset($this->headers[$key])) {
+ $this->headers[$key] = $values;
+ } else {
+ $this->headers[$key] = array_merge($this->headers[$key], $values);
+ }
+ }
+
+ /**
+ * Returns true if the HTTP header is defined
+ * @param string $key The HTTP header
+ * @return Boolean true if the parameter exists, false otherwise
+ */
+ public function has($key)
+ {
+ return array_key_exists(self::normalizeHeaderName($key), $this->headers);
+ }
+
+ /**
+ * Returns true if the given HTTP header contains the given value
+ * @param string $key The HTTP header name
+ * @param string $value The HTTP value
+ * @return Boolean true if the value is contained in the header, false otherwise
+ */
+ public function contains($key, $value)
+ {
+ return in_array($value, $this->get($key, false));
+ }
+
+ /**
+ * Deletes a header
+ * @param string $key The HTTP header name
+ */
+ public function delete($key)
+ {
+ unset($this->headers[self::normalizeHeaderName($key)]);
+ }
+
+ // /**
+ // * Returns an instance able to manage the Cache-Control header.
+ // *
+ // * @return CacheControl A CacheControl instance
+ // */
+ // public function getCacheControl()
+ // {
+ // if (null === $this->cacheControl) {
+ // $this->cacheControl = new CacheControl($this, $this->get('Cache-Control'), $this->type);
+ // }
+ //
+ // return $this->cacheControl;
+ // }
+ //
+ // /**
+ // * Sets a cookie.
+ // *
+ // * @param string $name The cookie name
+ // * @param string $value The value of the cookie
+ // * @param string $domain The domain that the cookie is available
+ // * @param string $expire The time the cookie expires
+ // * @param string $path The path on the server in which the cookie will be available on
+ // * @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client
+ // * @param bool $httponly When TRUE the cookie will not be made accessible to JavaScript, preventing XSS attacks from stealing cookies
+ // *
+ // * @throws \InvalidArgumentException When the cookie expire parameter is not valid
+ // */
+ // public function setCookie($name, $value, $domain = null, $expires = null, $path = '/', $secure = false, $httponly = true)
+ // {
+ // // from PHP source code
+ // if (preg_match("/[=,; \t\r\n\013\014]/", $name)) {
+ // throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name));
+ // }
+ //
+ // if (preg_match("/[,; \t\r\n\013\014]/", $value)) {
+ // throw new \InvalidArgumentException(sprintf('The cookie value "%s" contains invalid characters.', $name));
+ // }
+ //
+ // if (!$name) {
+ // throw new \InvalidArgumentException('The cookie name cannot be empty');
+ // }
+ //
+ // $cookie = sprintf('%s=%s', $name, urlencode($value));
+ //
+ // if ('request' === $this->type) {
+ // return $this->set('Cookie', $cookie);
+ // }
+ //
+ // if (null !== $expires) {
+ // if (is_numeric($expires)) {
+ // $expires = (int) $expires;
+ // } elseif ($expires instanceof \DateTime) {
+ // $expires = $expires->getTimestamp();
+ // } else {
+ // $expires = strtotime($expires);
+ // if (false === $expires || -1 == $expires) {
+ // throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid.', $expires));
+ // }
+ // }
+ //
+ // $cookie .= '; expires='.substr(\DateTime::createFromFormat('U', $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5);
+ // }
+ //
+ // if ($domain) {
+ // $cookie .= '; domain='.$domain;
+ // }
+ //
+ // if ('/' !== $path) {
+ // $cookie .= '; path='.$path;
+ // }
+ //
+ // if ($secure) {
+ // $cookie .= '; secure';
+ // }
+ //
+ // if ($httponly) {
+ // $cookie .= '; httponly';
+ // }
+ //
+ // $this->set('Set-Cookie', $cookie, false);
+ // }
+ //
+ // /**
+ // * Returns the HTTP header value converted to a date.
+ // *
+ // * @param string $key The parameter key
+ // * @param \DateTime $default The default value
+ // *
+ // * @return \DateTime The filtered value
+ // */
+ // public function getDate($key, \DateTime $default = null)
+ // {
+ // if (null === $value = $this->get($key)) {
+ // return $default;
+ // }
+ //
+ // if (false === $date = \DateTime::createFromFormat(DATE_RFC2822, $value)) {
+ // throw new \RuntimeException(sprintf('The %s HTTP header is not parseable (%s).', $key, $value));
+ // }
+ //
+ // return $date;
+ // }
+
+ /**
+ * Normalizes an HTTP header name
+ * @param string $key The HTTP header name
+ * @return string The normalized HTTP header name
+ */
+ static public function normalizeHeaderName($key)
+ {
+ return strtr(strtolower($key), '_', '-');
+ }
+};
diff --git a/Component/Http/ParameterContainer.php b/src/Starlight/Component/Http/ParameterBucket.php
similarity index 56%
rename from Component/Http/ParameterContainer.php
rename to src/Starlight/Component/Http/ParameterBucket.php
index c04d8a7..5939455 100755
--- a/Component/Http/ParameterContainer.php
+++ b/src/Starlight/Component/Http/ParameterBucket.php
@@ -1,112 +1,110 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Starlight\Component\HTTP;
-class ParameterContainer
+/**
+ * Wrapper class request parameters
+ * @see Request
+ */
+class ParameterBucket
{
+ /**
+ * Parameters
+ * @var array
+ */
protected $parameters;
/**
* Constructor
- *
- * @param array $parameters An array of parameters
+ * @param array $parameters Parameters
*/
public function __construct(array $parameters = array())
{
$this->replace($parameters);
}
/**
- * Returns the parameters.
- *
- * @return array An array of parameters
- */
+ * Returns the parameters
+ * @return array Parameters
+ */
public function all()
{
return $this->parameters;
}
/**
- * Returns the parameter keys.
- *
- * @return array An array of parameter keys
- */
+ * Returns the parameter keys
+ * @return array Parameter keys
+ */
public function keys()
{
return array_keys($this->parameters);
}
/**
- * Replaces the current parameters by a new set.
- *
- * @param array $parameters An array of parameters
- */
+ * Replaces the current parameters by a new set
+ * @param array $parameters parameters
+ */
public function replace(array $parameters = array())
{
$this->parameters = $parameters;
}
/**
- * Adds parameters.
- *
- * @param array $parameters An array of parameters
- */
+ * Adds parameters
+ * @param array $parameters parameters
+ */
public function add(array $parameters = array())
{
$this->parameters = array_replace($this->parameters, $parameters);
}
/**
- * Returns a parameter by name.
- *
- * @param string $key The key
- * @param mixed $default The default value
- */
+ * Returns a parameter by name
+ * @param string $key The key
+ * @param mixed $default default value
+ */
public function get($key, $default = null)
{
return array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default;
}
/**
- * Sets a parameter by name.
- *
- * @param string $key The key
- * @param mixed $value The value
- */
+ * Sets a parameter by name
+ * @param string $key The key
+ * @param mixed $value value
+ */
public function set($key, $value)
{
$this->parameters[$key] = $value;
}
/**
- * Returns true if the parameter is defined.
- *
- * @param string $key The key
- *
- * @return Boolean true if the parameter exists, false otherwise
- */
+ * Returns true if the parameter is defined
+ * @param string $key The key
+ * @return Boolean true if the parameter exists, false otherwise
+ */
public function has($key)
{
return array_key_exists($key, $this->parameters);
}
/**
- * Deletes a parameter.
- *
- * @param string $key The key
- */
+ * Deletes a parameter
+ * @param string $key key
+ */
public function delete($key)
{
unset($this->parameters[$key]);
}
};
diff --git a/src/Starlight/Component/Http/Request.php b/src/Starlight/Component/Http/Request.php
new file mode 100755
index 0000000..38d32cc
--- /dev/null
+++ b/src/Starlight/Component/Http/Request.php
@@ -0,0 +1,277 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\HTTP;
+
+/**
+ * HTTP Request
+ */
+class Request
+{
+ public $post;
+ public $get;
+ public $cookies;
+ public $files;
+ public $server;
+ public $headers;
+
+ protected $host;
+ protected $port;
+ protected $remote_ip;
+
+
+ /**
+ * Constructor
+ * @param array $post POST values
+ * @param array $get GET values
+ * @param array $cookies COOKIE values
+ * @param array $files FILES values
+ * @param array $server SERVER values
+ */
+ public function __construct(array $post = null, array $get = null, array $cookies = null, array $files = null, array $server = null)
+ {
+ $this->post = new ParameterBucket($post ?: $_POST);
+ $this->get = new ParameterBucket($get ?: $_GET);
+ $this->cookies = new ParameterBucket($cookies ?: $_COOKIE);
+ $this->files = new ParameterBucket($files ?: $_FILES);
+ $this->server = new ParameterBucket($server ?: $_SERVER);
+ $this->headers = new HeaderBucket($this->initializeHeaders(), 'request');
+ }
+
+ /**
+ * Clone
+ */
+ public function __clone()
+ {
+ $this->post = clone $this->post;
+ $this->get = clone $this->get;
+ $this->cookies = clone $this->cookies;
+ $this->files = clone $this->files;
+ $this->server = clone $this->server;
+ $this->headers = clone $this->headers;
+ }
+
+ /**
+ * Get a value from the request
+ *
+ * Order or precedence: GET, POST, COOKIE
+ */
+ public function get($key, $default = null)
+ {
+ return $this->get->get($key, $this->post->get($key, $this->cookies->get($key, $default)));
+ }
+
+ /**
+ * Gets request method, lowercased
+ *
+ * Method can come from three places in this order:
+ * <ol>
+ * <li>$_POST[_method]</li>
+ * <li>$_SERVER[X_HTTP_METHOD_OVERRIDE]</li>
+ * <li>$_SERVER[REQUEST_METHOD]</li>
+ * </ol>
+ * @return string request method
+ */
+ public function getMethod()
+ {
+ return strtolower($this->post->get('_method', $this->server->get('X_HTTP_METHOD_OVERRIDE', $this->server->get('REQUEST_METHOD'))));
+ }
+
+ /**
+ * Is this a DELETE request
+ * @return boolean is DELETE request
+ */
+ public function isDelete()
+ {
+ return $this->getMethod() == 'delete';
+ }
+
+ /**
+ * Is this a GET request
+ * @see head()
+ * @return boolean is GET request
+ */
+ public function isGet()
+ {
+ return $this->isHead();
+ }
+
+ /**
+ * Is this a POST request
+ * @return boolean is POST request
+ */
+ public function isPost()
+ {
+ return $this->getMethod() == 'post';
+ }
+
+ /**
+ * Is this a HEAD request
+ *
+ * Functionally equivalent to get()
+ * @return boolean is HEAD request
+ */
+ public function isHead()
+ {
+ return $this->getMethod() == 'head' || $this->getMethod() == 'get';
+ }
+
+ /**
+ * Is this a PUT request
+ * @return boolean is PUT request
+ */
+ public function isPut()
+ {
+ return $this->getMethod() == 'put';
+ }
+
+ /**
+ * Is this an SSL request
+ * @return boolean is SSL request
+ */
+ public function isSsl()
+ {
+ return strtolower($this->server->get('HTTPS')) == 'on';
+ }
+
+ /**
+ * Gets server protocol
+ * @return string protocol
+ */
+ public function getProtocol()
+ {
+ return $this->isSsl() ? 'https://' : 'http://';
+ }
+
+ /**
+ * Gets the server host
+ * @return string host
+ */
+ public function getHost()
+ {
+ if ($this->host === null) {
+ $host = $this->server->get('HTTP_X_FORWARDED_HOST', $this->server->get('HTTP_HOST'));
+ $pos = strpos($host, ':');
+ if ($pos !== false) {
+ $this->host = substr($host, 0, $pos);
+ $this->port = $this->port === null ? substr($host, $pos + 1) : null;
+ } else {
+ $this->host = $host;
+ }
+ }
+
+ return $this->host;
+ }
+
+ /**
+ * Gets the server port
+ * @return integer port
+ */
+ public static function getPort()
+ {
+ if ($this->port === null) {
+ $this->port = $this->server->get('SERVER_PORT', $this->getStandardPort());
+ }
+
+ return $this->port;
+ }
+
+ /**
+ * Gets the standard port number for the current protocol
+ * @return integer port (443, 80)
+ */
+ public static function getStandardPort()
+ {
+ return $this->isSsl() ? 443 : 80;
+ }
+
+ /**
+ * Gets the port string with colon delimiter if not standard port
+ * @return string port
+ */
+ public function getPortString()
+ {
+ return (in_array($this->getPort(), array(443, 80))) ? '' : ':' . $this->getPort();
+ }
+
+ /**
+ * Gets the host with the port
+ * @return string host with port
+ */
+ public function getHostWithPort()
+ {
+ return $this->getHost() . $this->getPortString();
+ }
+
+ /**
+ * Gets the client's remote ip
+ * @return string IP
+ */
+ public function getRemoteIp()
+ {
+ if ($this->remote_ip === null) {
+ $remote_ips = null;
+ if ($x_forward = $this->server->get('HTTP_X_FORWARDED_FOR')) {
+ $remote_ips = array_map('trim', explode(',', $x_forward));
+ }
+
+ $client_ip = $this->server->get('HTTP_CLIENT_IP');
+ if ($client_ip) {
+ if (is_array($remote_ips) && !in_array($client_ip, $remote_ips)) {
+ // don't know which came from the proxy, and which from the user
+ // sprintf("IP spoofing attack?!\nHTTP_CLIENT_IP=%s\nHTTP_X_FORWARDED_FOR=%s", self::env('HTTP_CLIENT_IP'), self::env('HTTP_X_FORWARDED_FOR')
+ throw new \Exception();
+ }
+
+ $this->remote_ip = $client_ip;
+ } elseif (is_array($remote_ips)) {
+ $this->remote_ip = $remote_ips[0];
+ } else {
+ $this->remote_ip = $this->server->get('REMOTE_ADDR');
+ }
+ }
+
+ return $this->remote_ip;
+ }
+
+ /**
+ * Check if the request is an XMLHttpRequest (AJAX)
+ * @return boolean is XHR (AJAX) request
+ */
+ public function isXmlHttpRequest()
+ {
+ return (bool) preg_match('/XMLHttpRequest/i', $this->server->get('HTTP_X_REQUESTED_WITH'));
+ }
+
+ /**
+ * Gets the full server url with protocol and port
+ * @return string server path
+ */
+ public function getServer()
+ {
+ return $this->getProtocol() . $this->getHostWithPort();
+ }
+
+ /**
+ * Initialize request headers for HeaderBucket
+ * @return array headers
+ */
+ protected function initializeHeaders()
+ {
+ $headers = array();
+ foreach ($this->server->all() as $key => $value) {
+ if (strtolower(substr($key, 0, 5)) === 'http_') {
+ $headers[substr($key, 5)] = $value;
+ }
+ }
+
+ return $headers;
+ }
+};
diff --git a/Framework/Support/UniversalClassLoader.php b/src/Starlight/Framework/Support/UniversalClassLoader.php
similarity index 92%
rename from Framework/Support/UniversalClassLoader.php
rename to src/Starlight/Framework/Support/UniversalClassLoader.php
index d277704..12d4c86 100755
--- a/Framework/Support/UniversalClassLoader.php
+++ b/src/Starlight/Framework/Support/UniversalClassLoader.php
@@ -1,150 +1,149 @@
<?php
/*
* This file is part of the Starlight framework.
*
* (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Starlight\Framework\Support;
/**
* UniversalClassLoader implements a "universal" autoloader for PHP 5.3.
*
* It is able to load classes that use either:
*
* * The technical interoperability standards for PHP 5.3 namespaces and
* class names (http://groups.google.com/group/php-standards/web/psr-0-final-proposal);
*
* * The PEAR naming convention for classes (http://pear.php.net/).
*
* Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be
* looked for in a list of locations to ease the vendoring of a sub-set of
* classes for large projects.
*
* Example usage:
*
* $loader = new UniversalClassLoader();
*
* // register classes with namespaces
* $loader->registerNamespaces(array(
* 'Starlight\Support' => __DIR__.'/component',
* 'Starlight' => __DIR__.'/framework',
* ));
*
* // register a library using the PEAR naming convention
* $loader->registerPrefixes(array(
* 'Swift_' => __DIR__.'/Swift',
* ));
*
* // activate the autoloader
* $loader->register();
*
* In this example, if you try to use a class in the Starlight\Support
* namespace or one of its children (Starlight\Support\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*/
class UniversalClassLoader
{
/**
* Current namespaces
* @var array
*/
protected $namespaces = array();
/**
* Current prefixes
* @var array
*/
protected $prefixes = array();
/**
* Get current namespaces
*
* @return array current namespaces
*/
public function getNamespaces()
{
return $this->namespaces;
}
/**
* Get current prefixes
*
* @return array current prefixes
*/
public function getPrefixes()
{
return $this->prefixes;
}
/**
* Registers an array of namespaces
*
* @param array $namespaces An array of namespaces (namespaces as keys and locations as values)
*/
public function registerNamespaces(array $namespaces)
{
$this->namespaces = array_merge($this->namespaces, $namespaces);
}
/**
* Registers a namespace.
*
* @param string $namespace The namespace
* @param string $path The location of the namespace
*/
public function registerNamespace($namespace, $path)
{
$this->namespaces[$namespace] = $path;
}
/**
* Register with the php autoload subsystem
*/
public function register()
{
spl_autoload_register(array($this, 'load'));
}
/**
* Loads the given class/interface
*
* @param string $class fully-qualified class name to load
*/
public function load($class)
{
if (($pos = stripos($class, '\\')) !== false) {
// namespace
$namespace = substr($class, 0, $pos);
foreach ($this->namespaces as $ns => $dir) {
if (strpos($namespace, $ns) === 0) {
- $class = substr($class, $pos + 1);
- $file = $dir . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
+ $file = $dir . DIRECTORY_SEPARATOR . str_replace(array('\\', '_'), DIRECTORY_SEPARATOR, $class) . '.php';
if (file_exists($file)) {
require $file;
}
return;
}
}
} else {
// PEAR style
foreach ($this->prefixes as $prefix => $dir) {
if (strpos($class, $prefix) === 0) {
$file = $dir . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
if (file_exists($file)) {
require $file;
}
return;
}
}
}
}
};
diff --git a/src/Starlight/Framework/bootloader.php b/src/Starlight/Framework/bootloader.php
new file mode 100755
index 0000000..ed05c16
--- /dev/null
+++ b/src/Starlight/Framework/bootloader.php
@@ -0,0 +1,32 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+require __DIR__ . DIRECTORY_SEPARATOR . 'Support' . DIRECTORY_SEPARATOR . 'UniversalClassLoader.php';
+
+$autoloader = new \Starlight\Framework\Support\UniversalClassLoader();
+$autoloader->registerNamespaces(array(
+ 'Starlight' => realpath(dirname(__FILE__) . '/../../'),
+));
+$autoloader->register();
+
+function dump()
+{
+ foreach (func_get_args() as $arg) {
+ echo '<pre>' . print_r($arg, true) . '</pre>';
+ echo '<hr />';
+ }
+}
+
+$dispatcher = new \Starlight\Component\Dispatcher\HttpDispatcher();
+$dispatcher->dispatch(new \Starlight\Component\Http\Request());
+dump($dispatcher);
+
+
+//\Starlight\Framework\Kernel::initialize();
\ No newline at end of file
|
synewaves/starlight
|
dac430fdef7189e3abef602fd13394ea2d76e68e
|
Some basic layout work
|
diff --git a/.gitignore b/.gitignore
old mode 100644
new mode 100755
index e69de29..32a36c2
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+.eprj
\ No newline at end of file
diff --git a/Component/Http/ParameterContainer.php b/Component/Http/ParameterContainer.php
new file mode 100755
index 0000000..c04d8a7
--- /dev/null
+++ b/Component/Http/ParameterContainer.php
@@ -0,0 +1,112 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\HTTP;
+
+
+class ParameterContainer
+{
+ protected $parameters;
+
+
+ /**
+ * Constructor
+ *
+ * @param array $parameters An array of parameters
+ */
+ public function __construct(array $parameters = array())
+ {
+ $this->replace($parameters);
+ }
+
+ /**
+ * Returns the parameters.
+ *
+ * @return array An array of parameters
+ */
+ public function all()
+ {
+ return $this->parameters;
+ }
+
+ /**
+ * Returns the parameter keys.
+ *
+ * @return array An array of parameter keys
+ */
+ public function keys()
+ {
+ return array_keys($this->parameters);
+ }
+
+ /**
+ * Replaces the current parameters by a new set.
+ *
+ * @param array $parameters An array of parameters
+ */
+ public function replace(array $parameters = array())
+ {
+ $this->parameters = $parameters;
+ }
+
+ /**
+ * Adds parameters.
+ *
+ * @param array $parameters An array of parameters
+ */
+ public function add(array $parameters = array())
+ {
+ $this->parameters = array_replace($this->parameters, $parameters);
+ }
+
+ /**
+ * Returns a parameter by name.
+ *
+ * @param string $key The key
+ * @param mixed $default The default value
+ */
+ public function get($key, $default = null)
+ {
+ return array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default;
+ }
+
+ /**
+ * Sets a parameter by name.
+ *
+ * @param string $key The key
+ * @param mixed $value The value
+ */
+ public function set($key, $value)
+ {
+ $this->parameters[$key] = $value;
+ }
+
+ /**
+ * Returns true if the parameter is defined.
+ *
+ * @param string $key The key
+ *
+ * @return Boolean true if the parameter exists, false otherwise
+ */
+ public function has($key)
+ {
+ return array_key_exists($key, $this->parameters);
+ }
+
+ /**
+ * Deletes a parameter.
+ *
+ * @param string $key The key
+ */
+ public function delete($key)
+ {
+ unset($this->parameters[$key]);
+ }
+};
diff --git a/Component/Http/Request.php b/Component/Http/Request.php
new file mode 100755
index 0000000..210bdbd
--- /dev/null
+++ b/Component/Http/Request.php
@@ -0,0 +1,36 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Component\HTTP;
+
+class Request
+{
+ public $post;
+ public $get;
+ public $cookies;
+ public $files;
+ public $server;
+
+
+ public function __construct(array $post = null, array $get = null, array $cookies = null, array $files = null, array $server = null)
+ {
+ $this->initialize($post, $get, $cookies, $files, $server);
+ }
+
+ public function initialize(array $post = null, array $get = null, array $cookies = null, array $files = null, array $server = null)
+ {
+ $this->post = new ParameterContainer($post ?: $_POST);
+ $this->get = new ParameterContainer($get ?: $_GET);
+ $this->cookies = new ParameterContainer($cookies ?: $_COOKIE);
+ $this->files = new ParameterContainer($files ?: $_FILES);
+ $this->server = new ParameterContainer($server ?: $_SERVER);
+
+ }
+};
diff --git a/Framework/Kernel.php b/Framework/Kernel.php
new file mode 100755
index 0000000..214d2a5
--- /dev/null
+++ b/Framework/Kernel.php
@@ -0,0 +1,29 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Framework;
+
+
+/**
+ *
+ */
+class Kernel
+{
+ public static function initialize()
+ {
+ $app_base_path = realpath(dirname(__FILE__) . '/../../../') . DIRECTORY_SEPARATOR;
+
+ $autoloader = new \Starlight\Framework\Support\UniversalClassLoader();
+ $autoloader->registerNamespaces(array(
+ 'Starlight' => $app_base_path . 'vendor',
+ ));
+ $autoloader->register();
+ }
+};
\ No newline at end of file
diff --git a/Framework/Support/UniversalClassLoader.php b/Framework/Support/UniversalClassLoader.php
new file mode 100755
index 0000000..d277704
--- /dev/null
+++ b/Framework/Support/UniversalClassLoader.php
@@ -0,0 +1,150 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Starlight\Framework\Support;
+
+/**
+ * UniversalClassLoader implements a "universal" autoloader for PHP 5.3.
+ *
+ * It is able to load classes that use either:
+ *
+ * * The technical interoperability standards for PHP 5.3 namespaces and
+ * class names (http://groups.google.com/group/php-standards/web/psr-0-final-proposal);
+ *
+ * * The PEAR naming convention for classes (http://pear.php.net/).
+ *
+ * Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be
+ * looked for in a list of locations to ease the vendoring of a sub-set of
+ * classes for large projects.
+ *
+ * Example usage:
+ *
+ * $loader = new UniversalClassLoader();
+ *
+ * // register classes with namespaces
+ * $loader->registerNamespaces(array(
+ * 'Starlight\Support' => __DIR__.'/component',
+ * 'Starlight' => __DIR__.'/framework',
+ * ));
+ *
+ * // register a library using the PEAR naming convention
+ * $loader->registerPrefixes(array(
+ * 'Swift_' => __DIR__.'/Swift',
+ * ));
+ *
+ * // activate the autoloader
+ * $loader->register();
+ *
+ * In this example, if you try to use a class in the Starlight\Support
+ * namespace or one of its children (Starlight\Support\Console for instance),
+ * the autoloader will first look for the class under the component/
+ * directory, and it will then fallback to the framework/ directory if not
+ * found before giving up.
+ */
+class UniversalClassLoader
+{
+ /**
+ * Current namespaces
+ * @var array
+ */
+ protected $namespaces = array();
+
+ /**
+ * Current prefixes
+ * @var array
+ */
+ protected $prefixes = array();
+
+
+ /**
+ * Get current namespaces
+ *
+ * @return array current namespaces
+ */
+ public function getNamespaces()
+ {
+ return $this->namespaces;
+ }
+
+ /**
+ * Get current prefixes
+ *
+ * @return array current prefixes
+ */
+ public function getPrefixes()
+ {
+ return $this->prefixes;
+ }
+
+ /**
+ * Registers an array of namespaces
+ *
+ * @param array $namespaces An array of namespaces (namespaces as keys and locations as values)
+ */
+ public function registerNamespaces(array $namespaces)
+ {
+ $this->namespaces = array_merge($this->namespaces, $namespaces);
+ }
+
+ /**
+ * Registers a namespace.
+ *
+ * @param string $namespace The namespace
+ * @param string $path The location of the namespace
+ */
+ public function registerNamespace($namespace, $path)
+ {
+ $this->namespaces[$namespace] = $path;
+ }
+
+ /**
+ * Register with the php autoload subsystem
+ */
+ public function register()
+ {
+ spl_autoload_register(array($this, 'load'));
+ }
+
+ /**
+ * Loads the given class/interface
+ *
+ * @param string $class fully-qualified class name to load
+ */
+ public function load($class)
+ {
+ if (($pos = stripos($class, '\\')) !== false) {
+ // namespace
+ $namespace = substr($class, 0, $pos);
+ foreach ($this->namespaces as $ns => $dir) {
+ if (strpos($namespace, $ns) === 0) {
+ $class = substr($class, $pos + 1);
+ $file = $dir . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
+ if (file_exists($file)) {
+ require $file;
+ }
+
+ return;
+ }
+ }
+ } else {
+ // PEAR style
+ foreach ($this->prefixes as $prefix => $dir) {
+ if (strpos($class, $prefix) === 0) {
+ $file = $dir . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
+ if (file_exists($file)) {
+ require $file;
+ }
+
+ return;
+ }
+ }
+ }
+ }
+};
diff --git a/Framework/bootloader.php b/Framework/bootloader.php
new file mode 100755
index 0000000..66894dd
--- /dev/null
+++ b/Framework/bootloader.php
@@ -0,0 +1,15 @@
+<?php
+/*
+ * This file is part of the Starlight framework.
+ *
+ * (c) Matthew Vince <matthew.vince@phaseshiftllc.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+require __DIR__ . DIRECTORY_SEPARATOR . 'Kernel.php';
+require __DIR__ . DIRECTORY_SEPARATOR . 'Support' . DIRECTORY_SEPARATOR . 'UniversalClassLoader.php';
+
+
+\Starlight\Framework\Kernel::initialize();
\ No newline at end of file
|
synewaves/starlight
|
91470c660d2bad3cf6cdbb547a9b27d76260bc17
|
Adding base support files
|
diff --git a/README b/.gitignore
similarity index 100%
rename from README
rename to .gitignore
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..42f5cf6
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2010 Matthew Vince
+
+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.
\ No newline at end of file
diff --git a/README.markdown b/README.markdown
new file mode 100644
index 0000000..e69de29
|
ox-it/permissions-ontology
|
c46093b8c6fdb4c4baf6b12a1d41991027bf60dd
|
Flipped subjects and objects in predicates and added ResourceMatch.
|
diff --git a/permissions/index.html b/permissions/index.html
index 762a57f..103c3a7 100644
--- a/permissions/index.html
+++ b/permissions/index.html
@@ -1,225 +1,258 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:wot="http://xmlns.com/wot/0.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:vann="http://purl.org/vocab/vann/" xmlns:cc="http://web.resource.org/cc/" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xml:lang="en" lang="en"><head><title>Ontology for modelling permissions</title><link rel="meta" type="application/rdf+xml" title="Ontology for modelling permissions" href="http://vocab.ox.ac.uk/perm#.rdf"/><style type="text/css">
code.xml .text {
color: #000000;
background: transparent;
}
code.xml .elem {
color: #000080;
background: transparent;
}
code.xml .attr {
color: #008080;
background: transparent;
}
code.xml .attrVal {
color: #666666;
background: transparent;
}
code.xml .highlight {
background: #ffff00;
}
h1, h2, h3, h4, h5, h6 {
font-family: Georgia, "Times New Roman", Times, serif;
font-style:italic;
}
pre {
border: 1px #9999cc dotted;
background-color: #f3f3ff;
color: #000000;
width: 90%;
}
blockquote {
border-style: solid;
border-color: #d0dbe7;
border-width: 0 0 0 .25em;
padding-left: 0.5em;
}
blockquote, q {
font-style: italic;
}
body {
font-family: verdana, geneva, arial, sans-serif;
}
a, p,blockquote, q, dl, dd, dt {
font-family: verdana, geneva, arial, sans-serif;
font-size: 1em;
}
dt {
font-weight: bold;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
:link:active, :visited:active { color: #C00; background: transparent }
:link:hover, :visited:hover { background: #ffa; }
code :link, code :visited { color: inherit; }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #996633; background: transparent; }
h1 { font: 900 170% sans-serif; border-bottom: 1px solid gray; }
h2 { font: 800 140% sans-serif; border-bottom: 1px solid gray; }
h3 { font: 700 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
body { padding: 0 4em 2em 4em; line-height: 1.35; }
pre { margin-left: 2em; /* overflow: auto; */ }
h1 + h2 { margin-top: 0; }
h2 { margin: 3em 0 1em 0; }
h2 + h3 { margin-top: 0; }
h3 { margin: 2em 0 1em 0; }
h4 { margin: 1.5em 0 0.75em 0; }
h5, h6 { margin: 1.5em 0 1em; }
p { margin: 1em 0; }
dl, dd { margin-top: 0; margin-bottom: 0; }
dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
dd dt { margin-top: 0.25em; margin-bottom: 0; }
dd p { margin-top: 0; }
p + * > li, dd li { margin: 1em 0; }
dt, dfn { font-weight: bold; font-style: normal; }
pre, code { font-size: inherit; font-family: monospace; }
pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
pre em { font-weight: bolder; font-style: normal; }
var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
ins { background: green; color: white; /* color: green; border: solid thin lime; padding: 0.3em; line-height: 1.6em; */ text-decoration: none; }
del { background: maroon; color: white; /* color: maroon; border: solid thin red; padding: 0.3em; line-height: 1.6em; */ text-decoration: line-through; }
body ins, body del { display: block; }
body * ins, body * del { display: inline; }
table.properties { width: 90%; }
table.properties th { text-align: right; width: 9em; font-weight: normal;}
table { border-collapse: collapse; border: solid #999999 1px;}
table thead { border-bottom: solid #999999 2px; }
table td, table th { border-left: solid #999999 1px; border-right: solid #999999 1px; border-bottom: solid #999999 1px;; vertical-align: top; padding: 0.2em; }
.historyList {
font-size: 0.9em;
}
- </style></head><body><h1>Ontology for modelling permissions</h1><dl class="doc-info"><dt>This Version</dt><dd><a href="http://vocab.ox.ac.uk/perm#">http://vocab.ox.ac.uk/perm#</a> [<a href="http://vocab.ox.ac.uk/perm/schema.html">HTML</a>] [<a href="http://vocab.ox.ac.uk/perm/schema.rdf">RDF/XML</a>]</dd><dt>Latest Version</dt><dd><a href="http://vocab.ox.ac.uk/perm#">http://vocab.ox.ac.uk/perm#</a></dd><dt>Authors</dt><dd>Alexander Dutton</dd><dt>Contributors</dt></dl><h2 id="toc">Table of Contents</h2><ul class="toc"><li><a href="#sec-introduction">Introduction</a></li><li><a href="#sec-namespace">Namespace</a></li><li><a href="#sec-terms">Summary of Terms</a></li><li><a href="#sec-properties">Vocabulary Properties</a></li><li><a href="#sec-schema">RDF Schema</a></li></ul><h2 id="sec-introduction">Introduction</h2><p class="description">A simple ontology for modelling permissions. Subjects are resources over which permissions may be held (e.g. user accounts, documents, physical objects), and objects are foaf:Agents which may hold those permissions. This ontology defines common permissions (create, read, update, delete, augment) and perm:permittee, the base property for all permissions properties.</p><h2 id="sec-changes">Changes From Previous Version</h2><ul/><h2 id="sec-namespace">Namespace</h2><p>The URI for this vocabulary is </p><pre><code>http://vocab.ox.ac.uk/perm#</code></pre><p>
- When used in XML documents the suggested prefix is <code>perm</code></p><p>Each class or property in the vocabulary has a URI constructed by appending a term name to the vocabulary URI. For example:</p><pre><code>http://vocab.ox.ac.uk/perm#permittee
-</code></pre><p>The term name for a class always starts with an uppercase character. Where the term name is comprised of multiple
+ </style></head><body><h1>Ontology for modelling permissions</h1><dl class="doc-info"><dt>This Version</dt><dd><a href="http://vocab.ox.ac.uk/perm#">http://vocab.ox.ac.uk/perm#</a> [<a href="http://vocab.ox.ac.uk/perm/schema.html">HTML</a>] [<a href="http://vocab.ox.ac.uk/perm/schema.rdf">RDF/XML</a>]</dd><dt>Latest Version</dt><dd><a href="http://vocab.ox.ac.uk/perm#">http://vocab.ox.ac.uk/perm#</a></dd><dt>Authors</dt><dd>Alexander Dutton</dd><dt>Contributors</dt></dl><h2 id="toc">Table of Contents</h2><ul class="toc"><li><a href="#sec-introduction">Introduction</a></li><li><a href="#sec-namespace">Namespace</a></li><li><a href="#sec-terms">Summary of Terms</a></li><li><a href="#sec-classes">Vocabulary Classes</a></li><li><a href="#sec-properties">Vocabulary Properties</a></li><li><a href="#sec-schema">RDF Schema</a></li></ul><h2 id="sec-introduction">Introduction</h2><p class="description">A simple ontology for modelling permissions. Subjects are resources over which permissions may be held (e.g. user accounts, documents, physical objects), and objects are foaf:Agents which may hold those permissions. This ontology defines common permissions (create, read, update, delete, augment) and perm:permittee, the base property for all permissions properties.</p><h2 id="sec-changes">Changes From Previous Version</h2><ul/><h2 id="sec-namespace">Namespace</h2><p>The URI for this vocabulary is </p><pre><code>http://vocab.ox.ac.uk/perm#</code></pre><p>
+ When used in XML documents the suggested prefix is <code>perm</code></p><p>Each class or property in the vocabulary has a URI constructed by appending a term name to the vocabulary URI. For example:</p><pre><code>http://vocab.ox.ac.uk/perm#hasPermissionOver
+http://vocab.ox.ac.uk/perm#ResourceMatch</code></pre><p>The term name for a class always starts with an uppercase character. Where the term name is comprised of multiple
concatenated words, the leading character of each word will be an uppercase character. For example:
- </p><pre><code>
+ </p><pre><code>ResourceMatch
</code></pre><p>The term name for a property always starts with an lowercase character. Where the term name is comprised of multiple
concatenated words, the leading character of the second and each subsequent word will be an uppercase character. For example:
- </p><pre><code>permittee
-editableBy</code></pre><h2 id="sec-terms">Summary of Terms</h2><p>This vocabulary defines
+ </p><pre><code>hasPermissionOver
+mayUpdate</code></pre><h2 id="sec-terms">Summary of Terms</h2><p>This vocabulary defines
- no classes
+ one class
and
- 5 properties
+ 8 properties
.
- </p><table><tr><th>Term Name</th><th>Type</th><th>Definition</th></tr><tr><td><a href="#term-augmentableBy" title="http://vocab.ox.ac.uk/perm#augmentableBy">augmentableBy</a></td><td>property</td><td>The subject may be augmented (e.g. appended to) by the object.</td></tr><tr><td><a href="#term-deletableBy" title="http://vocab.ox.ac.uk/perm#deletableBy">deletableBy</a></td><td>property</td><td>The subject may be deleted by the object.</td></tr><tr><td><a href="#term-editableBy" title="http://vocab.ox.ac.uk/perm#editableBy">editableBy</a></td><td>property</td><td>The subject may be edited by the object.</td></tr><tr><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">permittee</a></td><td>property</td><td>The object has a permission over the subject.</td></tr><tr><td><a href="#term-readableBy" title="http://vocab.ox.ac.uk/perm#readableBy">readableBy</a></td><td>property</td><td>The subject may be read by the object.</td></tr></table><h2 id="sec-properties">Vocabulary Properties</h2><div class="property"><h3 id="term-augmentableBy">Property: augmentableBy</h3><div class="description"><p class="comment">The subject may be augmented (e.g. appended to) by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#augmentableBy</td></tr><tr><th>Label:</th><td>may be augmented by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-deletableBy">Property: deletableBy</h3><div class="description"><p class="comment">The subject may be deleted by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#deletableBy</td></tr><tr><th>Label:</th><td>may be deleted by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-editableBy">Property: editableBy</h3><div class="description"><p class="comment">The subject may be edited by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#editableBy</td></tr><tr><th>Label:</th><td>may be edited by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-permittee">Property: permittee</h3><div class="description"><p class="comment">The object has a permission over the subject.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#permittee</td></tr><tr><th>Label:</th><td>has permittee</td></tr><tr><th>Range</th><td><a href="http://xmlns.com/foaf/0.1/Agent">foaf:Agent</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-readableBy">Property: readableBy</h3><div class="description"><p class="comment">The subject may be read by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#readableBy</td></tr><tr><th>Label:</th><td>may be read by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><h2 id="sec-schema">RDF Schema</h2><p>The schema included here is informational only. The normative schema can be found at <a href="http://vocab.ox.ac.uk/perm#.rdf">http://vocab.ox.ac.uk/perm#.rdf</a></p><pre><code class="xml"><span class="elem"><rdf:RDF</span>
+ </p><table><tr><th>Term Name</th><th>Type</th><th>Definition</th></tr><tr><td><a href="#term-ResourceMatch" title="http://vocab.ox.ac.uk/perm#ResourceMatch">ResourceMatch</a></td><td>class</td><td>An instance is the union of all resource URIs matched by the regular expression in its perm:matchExpression.</td></tr><tr><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">hasPermissionOver</a></td><td>property</td><td>The subject has some permission over the object.</td></tr><tr><td><a href="#term-matchExpression" title="http://vocab.ox.ac.uk/perm#matchExpression">matchExpression</a></td><td>property</td><td/></tr><tr><td><a href="#term-mayAdminister" title="http://vocab.ox.ac.uk/perm#mayAdminister">mayAdminister</a></td><td>property</td><td>The subject holds all permissions over the object.</td></tr><tr><td><a href="#term-mayAugment" title="http://vocab.ox.ac.uk/perm#mayAugment">mayAugment</a></td><td>property</td><td>The subject may augmented (e.g. append to) the object.</td></tr><tr><td><a href="#term-mayCreateChildrenOf" title="http://vocab.ox.ac.uk/perm#mayCreateChildrenOf">mayCreateChildrenOf</a></td><td>property</td><td>The subject can create child resources of the object.</td></tr><tr><td><a href="#term-mayDelete" title="http://vocab.ox.ac.uk/perm#mayDelete">mayDelete</a></td><td>property</td><td>The subject may deletethe object.</td></tr><tr><td><a href="#term-mayRead" title="http://vocab.ox.ac.uk/perm#mayRead">mayRead</a></td><td>property</td><td>The subject may read the object.</td></tr><tr><td><a href="#term-mayUpdate" title="http://vocab.ox.ac.uk/perm#mayUpdate">mayUpdate</a></td><td>property</td><td>The subject may modify the object.</td></tr></table><h2 id="sec-classes">Vocabulary Classes</h2><div class="class"><h3 id="term-ResourceMatch">Class: ResourceMatch</h3><div class="description"><p class="comment">An instance is the union of all resource URIs matched by the regular expression in its perm:matchExpression.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#ResourceMatch</td></tr><tr><th>Label:</th><td>an expression to match resource URIs</td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><h2 id="sec-properties">Vocabulary Properties</h2><div class="property"><h3 id="term-hasPermissionOver">Property: hasPermissionOver</h3><div class="description"><p class="comment">The subject has some permission over the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#hasPermissionOver</td></tr><tr><th>Label:</th><td>has some permission over</td></tr><tr><th>Domain</th><td><a href="http://xmlns.com/foaf/0.1/Agent">foaf:Agent</a></td></tr><tr><th>Paraphrase (experimental)</th><td>
+ Having a <a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a>
+ implies being
+ something that, amongst other things, is a <a href="http://xmlns.com/foaf/0.1/Agent">foaf:Agent</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-matchExpression">Property: matchExpression</h3><div class="description"><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#matchExpression</td></tr><tr><th>Domain</th><td><a href="#term-ResourceMatch" title="http://vocab.ox.ac.uk/perm#ResourceMatch">perm:ResourceMatch</a></td></tr><tr><th>Range</th><td><a href="http://www.w3.org/2000/01/rdf-schema#Literal">rdfs:Literal</a></td></tr><tr><th>Paraphrase (experimental)</th><td>
+ Having a <a href="http://vocab.ox.ac.uk/perm#matchExpression">perm:matchExpression</a>
+ implies being
+ something that, amongst other things, is a <a href="#term-ResourceMatch" title="http://vocab.ox.ac.uk/perm#ResourceMatch">perm:ResourceMatch</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-mayAdminister">Property: mayAdminister</h3><div class="description"><p class="comment">The subject holds all permissions over the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#mayAdminister</td></tr><tr><th>Label:</th><td>may administer</td></tr><tr><th>Subproperty of</th><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-mayAugment">Property: mayAugment</h3><div class="description"><p class="comment">The subject may augmented (e.g. append to) the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#mayAugment</td></tr><tr><th>Label:</th><td>may augment</td></tr><tr><th>Subproperty of</th><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-mayCreateChildrenOf">Property: mayCreateChildrenOf</h3><div class="description"><p class="comment">The subject can create child resources of the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#mayCreateChildrenOf</td></tr><tr><th>Label:</th><td>may create children of</td></tr><tr><th>Subproperty of</th><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-mayDelete">Property: mayDelete</h3><div class="description"><p class="comment">The subject may deletethe object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#mayDelete</td></tr><tr><th>Label:</th><td>may delete</td></tr><tr><th>Subproperty of</th><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-mayRead">Property: mayRead</h3><div class="description"><p class="comment">The subject may read the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#mayRead</td></tr><tr><th>Label:</th><td>may read</td></tr><tr><th>Subproperty of</th><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-mayUpdate">Property: mayUpdate</h3><div class="description"><p class="comment">The subject may modify the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#mayUpdate</td></tr><tr><th>Label:</th><td>may update</td></tr><tr><th>Subproperty of</th><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><h2 id="sec-schema">RDF Schema</h2><p>The schema included here is informational only. The normative schema can be found at <a href="http://vocab.ox.ac.uk/perm#.rdf">http://vocab.ox.ac.uk/perm#.rdf</a></p><pre><code class="xml"><span class="elem"><rdf:RDF</span>
<span class="attr">xmlns:owl</span>="<span class="attrVal">http://www.w3.org/2002/07/owl#</span>"
<span class="attr">xmlns:vann</span>="<span class="attrVal">http://purl.org/vocab/vann/</span>"
<span class="attr">xmlns:dct</span>="<span class="attrVal">http://purl.org/dc/terms/</span>"
<span class="attr">xmlns:dctype</span>="<span class="attrVal">http://purl.org/dc/dcmitype/</span>"
<span class="attr">xmlns:dc</span>="<span class="attrVal">http://purl.org/dc/elements/1.1/</span>"
<span class="attr">xmlns:rdfs</span>="<span class="attrVal">http://www.w3.org/2000/01/rdf-schema#</span>"
<span class="attr">xmlns:rdf</span>="<span class="attrVal">http://www.w3.org/1999/02/22-rdf-syntax-ns#</span>"
<span class="attr">xmlns:admingeo</span>="<span class="attrVal">http://data.ordnancesurvey.co.uk/ontology/admingeo/</span>"
<span class="attr">xmlns:xsd</span>="<span class="attrVal">http://www.w3.org/2001/XMLSchema#</span>"
<span class="attr">xmlns:event</span>="<span class="attrVal">http://purl.org/NET/c4dm/event.owl#</span>"
<span class="attr">xmlns:foaf</span>="<span class="attrVal">http://xmlns.com/foaf/0.1/</span>"
<span class="attr">xmlns:perm</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">></span>
<span class="elem"><owl:Ontology</span> <span class="attr">rdf:about</span>="<span class="attrVal"/>"<span class="elem">></span>
<span class="elem"><dc:title</span><span class="elem">></span><span class="text">Ontology for modelling permissions</span><span class="elem"></dc:title></span>
<span class="elem"><dc:identifier</span><span class="elem">></span><span class="text">http://vocab.ox.ac.uk/perm#</span><span class="elem"></dc:identifier></span>
<span class="elem"><dc:description</span><span class="elem">></span>
<span class="text">A simple ontology for modelling permissions. Subjects are resources over </span>
<span class="text">which permissions may be held (e.g. user accounts, documents, physical </span>
<span class="text">objects), and objects are foaf:Agents which may hold those permissions. </span>
<span class="text">This ontology defines common permissions (create, read, update, delete, </span>
<span class="text">augment) and perm:permittee, the base property for all permissions </span>
<span class="text">properties.</span>
<span class="elem"></dc:description></span>
<span class="elem"><vann:preferredNamespaceUri</span><span class="elem">></span><span class="text">http://vocab.ox.ac.uk/perm#</span><span class="elem"></vann:preferredNamespaceUri></span>
<span class="elem"><vann:preferredNamespacePrefix</span><span class="elem">></span><span class="text">perm</span><span class="elem"></vann:preferredNamespacePrefix></span>
<span class="elem"><dct:isVersionOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
<span class="elem"><dc:creator</span><span class="elem">></span><span class="text">Alexander Dutton</span><span class="elem"></dc:creator></span>
<span class="elem"><dct:hasFormat</span><span class="elem">></span>
<span class="elem"><dctype:Text</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm/schema.html</span>"<span class="elem">></span>
<span class="elem"><dc:format</span><span class="elem">></span>
<span class="elem"><dct:IMT</span><span class="elem">></span>
<span class="elem"><rdf:value</span><span class="elem">></span><span class="text">text/html</span><span class="elem"></rdf:value></span>
<span class="elem"><rdfs:label</span> <span class="attr">xml:lang</span>="<span class="attrVal">en</span>"<span class="elem">></span><span class="text">HTML</span><span class="elem"></rdfs:label></span>
<span class="elem"></dct:IMT></span>
<span class="elem"></dc:format></span>
<span class="elem"></dctype:Text></span>
<span class="elem"></dct:hasFormat></span>
<span class="elem"><dct:hasFormat</span><span class="elem">></span>
<span class="elem"><dctype:Text</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm/schema.rdf</span>"<span class="elem">></span>
<span class="elem"><dc:format</span><span class="elem">></span>
<span class="elem"><dct:IMT</span><span class="elem">></span>
<span class="elem"><rdf:value</span><span class="elem">></span><span class="text">application/rdf+xml</span><span class="elem"></rdf:value></span>
<span class="elem"><rdfs:label</span> <span class="attr">xml:lang</span>="<span class="attrVal">en</span>"<span class="elem">></span><span class="text">RDF/XML</span><span class="elem"></rdfs:label></span>
<span class="elem"></dct:IMT></span>
<span class="elem"></dc:format></span>
<span class="elem"></dctype:Text></span>
<span class="elem"></dct:hasFormat></span>
<span class="elem"></owl:Ontology></span>
<span class="elem"><foaf:Agent</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#public</span>"<span class="elem">></span>
<span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">public</span><span class="elem"></rdfs:label></span>
<span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The union of all agents</span><span class="elem"></rdfs:comment></span>
<span class="elem"></foaf:Agent></span>
- <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">></span>
- <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">has permittee</span><span class="elem"></rdfs:label></span>
- <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The object has a permission over the subject.</span><span class="elem"></rdfs:comment></span>
- <span class="elem"><rdfs:range</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://xmlns.com/foaf/0.1/Agent</span>"<span class="elem">/></span>
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">has some permission over</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject has some permission over the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:domain</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://xmlns.com/foaf/0.1/Agent</span>"<span class="elem">/></span>
<span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
<span class="elem"></rdf:Property></span>
- <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#editableBy</span>"<span class="elem">></span>
- <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be edited by</span><span class="elem"></rdfs:label></span>
- <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may be edited by the object.</span><span class="elem"></rdfs:comment></span>
- <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#mayUpdate</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may update</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may modify the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">/></span>
<span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
<span class="elem"></rdf:Property></span>
- <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#readableBy</span>"<span class="elem">></span>
- <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be read by</span><span class="elem"></rdfs:label></span>
- <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may be read by the object.</span><span class="elem"></rdfs:comment></span>
- <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#mayRead</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may read</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may read the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">/></span>
<span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
<span class="elem"></rdf:Property></span>
- <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#deletableBy</span>"<span class="elem">></span>
- <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be deleted by</span><span class="elem"></rdfs:label></span>
- <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may be deleted by the object.</span><span class="elem"></rdfs:comment></span>
- <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#mayDelete</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may delete</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may deletethe object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">/></span>
<span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
<span class="elem"></rdf:Property></span>
- <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#augmentableBy</span>"<span class="elem">></span>
- <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be augmented by</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#mayAugment</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may augment</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may augmented (e.g. append to) the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#mayAdminister</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may administer</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject holds all permissions over the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#mayCreateChildrenOf</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may create children of</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject can create child resources of the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdfs:Class</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#ResourceMatch</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">an expression to match resource URIs</span><span class="elem"></rdfs:label></span>
<span class="elem"><rdfs:comment</span><span class="elem">></span>
- <span class="text">The subject may be augmented (e.g. appended to) by the object.</span>
+ <span class="text">An instance is the union of all resource URIs matched by the regular </span>
+ <span class="text">expression in its perm:matchExpression.</span>
<span class="elem"></rdfs:comment></span>
- <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdfs:Class></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#matchExpression</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:domain</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#ResourceMatch</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:range</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://www.w3.org/2000/01/rdf-schema#Literal</span>"<span class="elem">/></span>
<span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
<span class="elem"></rdf:Property></span>
<span class="elem"></rdf:RDF></span>
</code></pre><div id="footer">
Documentation generated using the <a href="http://vocab.org/2004/03/toolchain">vocab.org toolchain</a>.
</div></body></html>
diff --git a/permissions/index.rdf b/permissions/index.rdf
index eaed4e8..4e047ec 100644
--- a/permissions/index.rdf
+++ b/permissions/index.rdf
@@ -1,101 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rdf:RDF [
<!ENTITY perm "http://vocab.ox.ac.uk/perm#">
<!ENTITY foaf "http://xmlns.com/foaf/0.1/">
<!ENTITY event "http://purl.org/NET/c4dm/event.owl#">
<!ENTITY dctype "http://purl.org/dc/dcmitype/">
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">
<!ENTITY admingeo "http://data.ordnancesurvey.co.uk/ontology/admingeo/">
+ <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
]>
<rdf:RDF
xmlns:perm="&perm;"
xmlns:foaf="&foaf;"
xmlns:event="&event;"
xmlns:xsd="&xsd;"
xmlns:admingeo="&admingeo;"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+ xmlns:rdfs="&rdfs;"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dctype="&dctype;"
xmlns:dct="http://purl.org/dc/terms/"
xmlns:vann="http://purl.org/vocab/vann/"
xmlns:owl="http://www.w3.org/2002/07/owl#">
<owl:Ontology rdf:about="">
<dc:title>Ontology for modelling permissions</dc:title>
<dc:identifier>http://vocab.ox.ac.uk/perm#</dc:identifier>
<dc:description>A simple ontology for modelling permissions. Subjects are resources over which permissions may be held (e.g. user accounts, documents, physical objects), and objects are foaf:Agents which may hold those permissions. This ontology defines common permissions (create, read, update, delete, augment) and perm:permittee, the base property for all permissions properties.</dc:description>
<vann:preferredNamespaceUri>http://vocab.ox.ac.uk/perm#</vann:preferredNamespaceUri>
<vann:preferredNamespacePrefix>perm</vann:preferredNamespacePrefix>
<dct:isVersionOf rdf:resource="&perm;"/>
<dc:creator>Alexander Dutton</dc:creator>
<dct:hasFormat>
<dctype:Text rdf:about="http://vocab.ox.ac.uk/perm/schema.html">
<dc:format>
<dct:IMT>
<rdf:value>text/html</rdf:value>
<rdfs:label xml:lang="en">HTML</rdfs:label>
</dct:IMT>
</dc:format>
</dctype:Text>
</dct:hasFormat>
<dct:hasFormat>
<dctype:Text rdf:about="http://vocab.ox.ac.uk/perm/schema.rdf">
<dc:format>
<dct:IMT>
<rdf:value>application/rdf+xml</rdf:value>
<rdfs:label xml:lang="en">RDF/XML</rdfs:label>
</dct:IMT>
</dc:format>
</dctype:Text>
</dct:hasFormat>
</owl:Ontology>
<foaf:Agent rdf:about="&perm;public">
<rdfs:label>public</rdfs:label>
<rdfs:comment>The union of all agents</rdfs:comment>
</foaf:Agent>
- <rdf:Property rdf:about="&perm;permittee">
- <rdfs:label>has permittee</rdfs:label>
- <rdfs:comment>The object has a permission over the subject.</rdfs:comment>
- <rdfs:range rdf:resource="&foaf;Agent"/>
+ <rdf:Property rdf:about="&perm;hasPermissionOver">
+ <rdfs:label>has some permission over</rdfs:label>
+ <rdfs:comment>The subject has some permission over the object.</rdfs:comment>
+ <rdfs:domain rdf:resource="&foaf;Agent"/>
<rdfs:isDefinedBy rdf:resource="&perm;"/>
</rdf:Property>
- <rdf:Property rdf:about="&perm;editableBy">
- <rdfs:label>may be edited by</rdfs:label>
- <rdfs:comment>The subject may be edited by the object.</rdfs:comment>
- <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdf:Property rdf:about="&perm;mayUpdate">
+ <rdfs:label>may update</rdfs:label>
+ <rdfs:comment>The subject may modify the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;hasPermissionOver"/>
<rdfs:isDefinedBy rdf:resource="&perm;"/>
</rdf:Property>
- <rdf:Property rdf:about="&perm;readableBy">
- <rdfs:label>may be read by</rdfs:label>
- <rdfs:comment>The subject may be read by the object.</rdfs:comment>
- <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdf:Property rdf:about="&perm;mayRead">
+ <rdfs:label>may read</rdfs:label>
+ <rdfs:comment>The subject may read the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;hasPermissionOver"/>
<rdfs:isDefinedBy rdf:resource="&perm;"/>
</rdf:Property>
- <rdf:Property rdf:about="&perm;deletableBy">
- <rdfs:label>may be deleted by</rdfs:label>
- <rdfs:comment>The subject may be deleted by the object.</rdfs:comment>
- <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdf:Property rdf:about="&perm;mayDelete">
+ <rdfs:label>may delete</rdfs:label>
+ <rdfs:comment>The subject may deletethe object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;hasPermissionOver"/>
<rdfs:isDefinedBy rdf:resource="&perm;"/>
</rdf:Property>
- <rdf:Property rdf:about="&perm;augmentableBy">
- <rdfs:label>may be augmented by</rdfs:label>
- <rdfs:comment>The subject may be augmented (e.g. appended to) by the object.</rdfs:comment>
- <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdf:Property rdf:about="&perm;mayAugment">
+ <rdfs:label>may augment</rdfs:label>
+ <rdfs:comment>The subject may augmented (e.g. append to) the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;hasPermissionOver"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+ <rdf:Property rdf:about="&perm;mayAdminister">
+ <rdfs:label>may administer</rdfs:label>
+ <rdfs:comment>The subject holds all permissions over the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;hasPermissionOver"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+ <rdf:Property rdf:about="&perm;mayCreateChildrenOf">
+ <rdfs:label>may create children of</rdfs:label>
+ <rdfs:comment>The subject can create child resources of the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;hasPermissionOver"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+
+ <rdfs:Class rdf:about="&perm;ResourceMatch">
+ <rdfs:label>an expression to match resource URIs</rdfs:label>
+ <rdfs:comment>An instance is the union of all resource URIs matched by the regular expression in its perm:matchExpression.</rdfs:comment>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdfs:Class>
+
+ <rdf:Property rdf:about="&perm;matchExpression">
+ <rdfs:domain rdf:resource="&perm;ResourceMatch"/>
+ <rdfs:range rdf:resource="&rdfs;Literal"/>
<rdfs:isDefinedBy rdf:resource="&perm;"/>
</rdf:Property>
</rdf:RDF>
diff --git a/permissions/vocab-0.1.html b/permissions/vocab-0.1.html
index 762a57f..103c3a7 100644
--- a/permissions/vocab-0.1.html
+++ b/permissions/vocab-0.1.html
@@ -1,225 +1,258 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:wot="http://xmlns.com/wot/0.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:vann="http://purl.org/vocab/vann/" xmlns:cc="http://web.resource.org/cc/" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xml:lang="en" lang="en"><head><title>Ontology for modelling permissions</title><link rel="meta" type="application/rdf+xml" title="Ontology for modelling permissions" href="http://vocab.ox.ac.uk/perm#.rdf"/><style type="text/css">
code.xml .text {
color: #000000;
background: transparent;
}
code.xml .elem {
color: #000080;
background: transparent;
}
code.xml .attr {
color: #008080;
background: transparent;
}
code.xml .attrVal {
color: #666666;
background: transparent;
}
code.xml .highlight {
background: #ffff00;
}
h1, h2, h3, h4, h5, h6 {
font-family: Georgia, "Times New Roman", Times, serif;
font-style:italic;
}
pre {
border: 1px #9999cc dotted;
background-color: #f3f3ff;
color: #000000;
width: 90%;
}
blockquote {
border-style: solid;
border-color: #d0dbe7;
border-width: 0 0 0 .25em;
padding-left: 0.5em;
}
blockquote, q {
font-style: italic;
}
body {
font-family: verdana, geneva, arial, sans-serif;
}
a, p,blockquote, q, dl, dd, dt {
font-family: verdana, geneva, arial, sans-serif;
font-size: 1em;
}
dt {
font-weight: bold;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
:link:active, :visited:active { color: #C00; background: transparent }
:link:hover, :visited:hover { background: #ffa; }
code :link, code :visited { color: inherit; }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #996633; background: transparent; }
h1 { font: 900 170% sans-serif; border-bottom: 1px solid gray; }
h2 { font: 800 140% sans-serif; border-bottom: 1px solid gray; }
h3 { font: 700 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
body { padding: 0 4em 2em 4em; line-height: 1.35; }
pre { margin-left: 2em; /* overflow: auto; */ }
h1 + h2 { margin-top: 0; }
h2 { margin: 3em 0 1em 0; }
h2 + h3 { margin-top: 0; }
h3 { margin: 2em 0 1em 0; }
h4 { margin: 1.5em 0 0.75em 0; }
h5, h6 { margin: 1.5em 0 1em; }
p { margin: 1em 0; }
dl, dd { margin-top: 0; margin-bottom: 0; }
dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
dd dt { margin-top: 0.25em; margin-bottom: 0; }
dd p { margin-top: 0; }
p + * > li, dd li { margin: 1em 0; }
dt, dfn { font-weight: bold; font-style: normal; }
pre, code { font-size: inherit; font-family: monospace; }
pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
pre em { font-weight: bolder; font-style: normal; }
var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
ins { background: green; color: white; /* color: green; border: solid thin lime; padding: 0.3em; line-height: 1.6em; */ text-decoration: none; }
del { background: maroon; color: white; /* color: maroon; border: solid thin red; padding: 0.3em; line-height: 1.6em; */ text-decoration: line-through; }
body ins, body del { display: block; }
body * ins, body * del { display: inline; }
table.properties { width: 90%; }
table.properties th { text-align: right; width: 9em; font-weight: normal;}
table { border-collapse: collapse; border: solid #999999 1px;}
table thead { border-bottom: solid #999999 2px; }
table td, table th { border-left: solid #999999 1px; border-right: solid #999999 1px; border-bottom: solid #999999 1px;; vertical-align: top; padding: 0.2em; }
.historyList {
font-size: 0.9em;
}
- </style></head><body><h1>Ontology for modelling permissions</h1><dl class="doc-info"><dt>This Version</dt><dd><a href="http://vocab.ox.ac.uk/perm#">http://vocab.ox.ac.uk/perm#</a> [<a href="http://vocab.ox.ac.uk/perm/schema.html">HTML</a>] [<a href="http://vocab.ox.ac.uk/perm/schema.rdf">RDF/XML</a>]</dd><dt>Latest Version</dt><dd><a href="http://vocab.ox.ac.uk/perm#">http://vocab.ox.ac.uk/perm#</a></dd><dt>Authors</dt><dd>Alexander Dutton</dd><dt>Contributors</dt></dl><h2 id="toc">Table of Contents</h2><ul class="toc"><li><a href="#sec-introduction">Introduction</a></li><li><a href="#sec-namespace">Namespace</a></li><li><a href="#sec-terms">Summary of Terms</a></li><li><a href="#sec-properties">Vocabulary Properties</a></li><li><a href="#sec-schema">RDF Schema</a></li></ul><h2 id="sec-introduction">Introduction</h2><p class="description">A simple ontology for modelling permissions. Subjects are resources over which permissions may be held (e.g. user accounts, documents, physical objects), and objects are foaf:Agents which may hold those permissions. This ontology defines common permissions (create, read, update, delete, augment) and perm:permittee, the base property for all permissions properties.</p><h2 id="sec-changes">Changes From Previous Version</h2><ul/><h2 id="sec-namespace">Namespace</h2><p>The URI for this vocabulary is </p><pre><code>http://vocab.ox.ac.uk/perm#</code></pre><p>
- When used in XML documents the suggested prefix is <code>perm</code></p><p>Each class or property in the vocabulary has a URI constructed by appending a term name to the vocabulary URI. For example:</p><pre><code>http://vocab.ox.ac.uk/perm#permittee
-</code></pre><p>The term name for a class always starts with an uppercase character. Where the term name is comprised of multiple
+ </style></head><body><h1>Ontology for modelling permissions</h1><dl class="doc-info"><dt>This Version</dt><dd><a href="http://vocab.ox.ac.uk/perm#">http://vocab.ox.ac.uk/perm#</a> [<a href="http://vocab.ox.ac.uk/perm/schema.html">HTML</a>] [<a href="http://vocab.ox.ac.uk/perm/schema.rdf">RDF/XML</a>]</dd><dt>Latest Version</dt><dd><a href="http://vocab.ox.ac.uk/perm#">http://vocab.ox.ac.uk/perm#</a></dd><dt>Authors</dt><dd>Alexander Dutton</dd><dt>Contributors</dt></dl><h2 id="toc">Table of Contents</h2><ul class="toc"><li><a href="#sec-introduction">Introduction</a></li><li><a href="#sec-namespace">Namespace</a></li><li><a href="#sec-terms">Summary of Terms</a></li><li><a href="#sec-classes">Vocabulary Classes</a></li><li><a href="#sec-properties">Vocabulary Properties</a></li><li><a href="#sec-schema">RDF Schema</a></li></ul><h2 id="sec-introduction">Introduction</h2><p class="description">A simple ontology for modelling permissions. Subjects are resources over which permissions may be held (e.g. user accounts, documents, physical objects), and objects are foaf:Agents which may hold those permissions. This ontology defines common permissions (create, read, update, delete, augment) and perm:permittee, the base property for all permissions properties.</p><h2 id="sec-changes">Changes From Previous Version</h2><ul/><h2 id="sec-namespace">Namespace</h2><p>The URI for this vocabulary is </p><pre><code>http://vocab.ox.ac.uk/perm#</code></pre><p>
+ When used in XML documents the suggested prefix is <code>perm</code></p><p>Each class or property in the vocabulary has a URI constructed by appending a term name to the vocabulary URI. For example:</p><pre><code>http://vocab.ox.ac.uk/perm#hasPermissionOver
+http://vocab.ox.ac.uk/perm#ResourceMatch</code></pre><p>The term name for a class always starts with an uppercase character. Where the term name is comprised of multiple
concatenated words, the leading character of each word will be an uppercase character. For example:
- </p><pre><code>
+ </p><pre><code>ResourceMatch
</code></pre><p>The term name for a property always starts with an lowercase character. Where the term name is comprised of multiple
concatenated words, the leading character of the second and each subsequent word will be an uppercase character. For example:
- </p><pre><code>permittee
-editableBy</code></pre><h2 id="sec-terms">Summary of Terms</h2><p>This vocabulary defines
+ </p><pre><code>hasPermissionOver
+mayUpdate</code></pre><h2 id="sec-terms">Summary of Terms</h2><p>This vocabulary defines
- no classes
+ one class
and
- 5 properties
+ 8 properties
.
- </p><table><tr><th>Term Name</th><th>Type</th><th>Definition</th></tr><tr><td><a href="#term-augmentableBy" title="http://vocab.ox.ac.uk/perm#augmentableBy">augmentableBy</a></td><td>property</td><td>The subject may be augmented (e.g. appended to) by the object.</td></tr><tr><td><a href="#term-deletableBy" title="http://vocab.ox.ac.uk/perm#deletableBy">deletableBy</a></td><td>property</td><td>The subject may be deleted by the object.</td></tr><tr><td><a href="#term-editableBy" title="http://vocab.ox.ac.uk/perm#editableBy">editableBy</a></td><td>property</td><td>The subject may be edited by the object.</td></tr><tr><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">permittee</a></td><td>property</td><td>The object has a permission over the subject.</td></tr><tr><td><a href="#term-readableBy" title="http://vocab.ox.ac.uk/perm#readableBy">readableBy</a></td><td>property</td><td>The subject may be read by the object.</td></tr></table><h2 id="sec-properties">Vocabulary Properties</h2><div class="property"><h3 id="term-augmentableBy">Property: augmentableBy</h3><div class="description"><p class="comment">The subject may be augmented (e.g. appended to) by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#augmentableBy</td></tr><tr><th>Label:</th><td>may be augmented by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-deletableBy">Property: deletableBy</h3><div class="description"><p class="comment">The subject may be deleted by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#deletableBy</td></tr><tr><th>Label:</th><td>may be deleted by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-editableBy">Property: editableBy</h3><div class="description"><p class="comment">The subject may be edited by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#editableBy</td></tr><tr><th>Label:</th><td>may be edited by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-permittee">Property: permittee</h3><div class="description"><p class="comment">The object has a permission over the subject.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#permittee</td></tr><tr><th>Label:</th><td>has permittee</td></tr><tr><th>Range</th><td><a href="http://xmlns.com/foaf/0.1/Agent">foaf:Agent</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-readableBy">Property: readableBy</h3><div class="description"><p class="comment">The subject may be read by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#readableBy</td></tr><tr><th>Label:</th><td>may be read by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><h2 id="sec-schema">RDF Schema</h2><p>The schema included here is informational only. The normative schema can be found at <a href="http://vocab.ox.ac.uk/perm#.rdf">http://vocab.ox.ac.uk/perm#.rdf</a></p><pre><code class="xml"><span class="elem"><rdf:RDF</span>
+ </p><table><tr><th>Term Name</th><th>Type</th><th>Definition</th></tr><tr><td><a href="#term-ResourceMatch" title="http://vocab.ox.ac.uk/perm#ResourceMatch">ResourceMatch</a></td><td>class</td><td>An instance is the union of all resource URIs matched by the regular expression in its perm:matchExpression.</td></tr><tr><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">hasPermissionOver</a></td><td>property</td><td>The subject has some permission over the object.</td></tr><tr><td><a href="#term-matchExpression" title="http://vocab.ox.ac.uk/perm#matchExpression">matchExpression</a></td><td>property</td><td/></tr><tr><td><a href="#term-mayAdminister" title="http://vocab.ox.ac.uk/perm#mayAdminister">mayAdminister</a></td><td>property</td><td>The subject holds all permissions over the object.</td></tr><tr><td><a href="#term-mayAugment" title="http://vocab.ox.ac.uk/perm#mayAugment">mayAugment</a></td><td>property</td><td>The subject may augmented (e.g. append to) the object.</td></tr><tr><td><a href="#term-mayCreateChildrenOf" title="http://vocab.ox.ac.uk/perm#mayCreateChildrenOf">mayCreateChildrenOf</a></td><td>property</td><td>The subject can create child resources of the object.</td></tr><tr><td><a href="#term-mayDelete" title="http://vocab.ox.ac.uk/perm#mayDelete">mayDelete</a></td><td>property</td><td>The subject may deletethe object.</td></tr><tr><td><a href="#term-mayRead" title="http://vocab.ox.ac.uk/perm#mayRead">mayRead</a></td><td>property</td><td>The subject may read the object.</td></tr><tr><td><a href="#term-mayUpdate" title="http://vocab.ox.ac.uk/perm#mayUpdate">mayUpdate</a></td><td>property</td><td>The subject may modify the object.</td></tr></table><h2 id="sec-classes">Vocabulary Classes</h2><div class="class"><h3 id="term-ResourceMatch">Class: ResourceMatch</h3><div class="description"><p class="comment">An instance is the union of all resource URIs matched by the regular expression in its perm:matchExpression.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#ResourceMatch</td></tr><tr><th>Label:</th><td>an expression to match resource URIs</td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><h2 id="sec-properties">Vocabulary Properties</h2><div class="property"><h3 id="term-hasPermissionOver">Property: hasPermissionOver</h3><div class="description"><p class="comment">The subject has some permission over the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#hasPermissionOver</td></tr><tr><th>Label:</th><td>has some permission over</td></tr><tr><th>Domain</th><td><a href="http://xmlns.com/foaf/0.1/Agent">foaf:Agent</a></td></tr><tr><th>Paraphrase (experimental)</th><td>
+ Having a <a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a>
+ implies being
+ something that, amongst other things, is a <a href="http://xmlns.com/foaf/0.1/Agent">foaf:Agent</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-matchExpression">Property: matchExpression</h3><div class="description"><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#matchExpression</td></tr><tr><th>Domain</th><td><a href="#term-ResourceMatch" title="http://vocab.ox.ac.uk/perm#ResourceMatch">perm:ResourceMatch</a></td></tr><tr><th>Range</th><td><a href="http://www.w3.org/2000/01/rdf-schema#Literal">rdfs:Literal</a></td></tr><tr><th>Paraphrase (experimental)</th><td>
+ Having a <a href="http://vocab.ox.ac.uk/perm#matchExpression">perm:matchExpression</a>
+ implies being
+ something that, amongst other things, is a <a href="#term-ResourceMatch" title="http://vocab.ox.ac.uk/perm#ResourceMatch">perm:ResourceMatch</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-mayAdminister">Property: mayAdminister</h3><div class="description"><p class="comment">The subject holds all permissions over the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#mayAdminister</td></tr><tr><th>Label:</th><td>may administer</td></tr><tr><th>Subproperty of</th><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-mayAugment">Property: mayAugment</h3><div class="description"><p class="comment">The subject may augmented (e.g. append to) the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#mayAugment</td></tr><tr><th>Label:</th><td>may augment</td></tr><tr><th>Subproperty of</th><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-mayCreateChildrenOf">Property: mayCreateChildrenOf</h3><div class="description"><p class="comment">The subject can create child resources of the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#mayCreateChildrenOf</td></tr><tr><th>Label:</th><td>may create children of</td></tr><tr><th>Subproperty of</th><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-mayDelete">Property: mayDelete</h3><div class="description"><p class="comment">The subject may deletethe object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#mayDelete</td></tr><tr><th>Label:</th><td>may delete</td></tr><tr><th>Subproperty of</th><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-mayRead">Property: mayRead</h3><div class="description"><p class="comment">The subject may read the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#mayRead</td></tr><tr><th>Label:</th><td>may read</td></tr><tr><th>Subproperty of</th><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-mayUpdate">Property: mayUpdate</h3><div class="description"><p class="comment">The subject may modify the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#mayUpdate</td></tr><tr><th>Label:</th><td>may update</td></tr><tr><th>Subproperty of</th><td><a href="#term-hasPermissionOver" title="http://vocab.ox.ac.uk/perm#hasPermissionOver">perm:hasPermissionOver</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><h2 id="sec-schema">RDF Schema</h2><p>The schema included here is informational only. The normative schema can be found at <a href="http://vocab.ox.ac.uk/perm#.rdf">http://vocab.ox.ac.uk/perm#.rdf</a></p><pre><code class="xml"><span class="elem"><rdf:RDF</span>
<span class="attr">xmlns:owl</span>="<span class="attrVal">http://www.w3.org/2002/07/owl#</span>"
<span class="attr">xmlns:vann</span>="<span class="attrVal">http://purl.org/vocab/vann/</span>"
<span class="attr">xmlns:dct</span>="<span class="attrVal">http://purl.org/dc/terms/</span>"
<span class="attr">xmlns:dctype</span>="<span class="attrVal">http://purl.org/dc/dcmitype/</span>"
<span class="attr">xmlns:dc</span>="<span class="attrVal">http://purl.org/dc/elements/1.1/</span>"
<span class="attr">xmlns:rdfs</span>="<span class="attrVal">http://www.w3.org/2000/01/rdf-schema#</span>"
<span class="attr">xmlns:rdf</span>="<span class="attrVal">http://www.w3.org/1999/02/22-rdf-syntax-ns#</span>"
<span class="attr">xmlns:admingeo</span>="<span class="attrVal">http://data.ordnancesurvey.co.uk/ontology/admingeo/</span>"
<span class="attr">xmlns:xsd</span>="<span class="attrVal">http://www.w3.org/2001/XMLSchema#</span>"
<span class="attr">xmlns:event</span>="<span class="attrVal">http://purl.org/NET/c4dm/event.owl#</span>"
<span class="attr">xmlns:foaf</span>="<span class="attrVal">http://xmlns.com/foaf/0.1/</span>"
<span class="attr">xmlns:perm</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">></span>
<span class="elem"><owl:Ontology</span> <span class="attr">rdf:about</span>="<span class="attrVal"/>"<span class="elem">></span>
<span class="elem"><dc:title</span><span class="elem">></span><span class="text">Ontology for modelling permissions</span><span class="elem"></dc:title></span>
<span class="elem"><dc:identifier</span><span class="elem">></span><span class="text">http://vocab.ox.ac.uk/perm#</span><span class="elem"></dc:identifier></span>
<span class="elem"><dc:description</span><span class="elem">></span>
<span class="text">A simple ontology for modelling permissions. Subjects are resources over </span>
<span class="text">which permissions may be held (e.g. user accounts, documents, physical </span>
<span class="text">objects), and objects are foaf:Agents which may hold those permissions. </span>
<span class="text">This ontology defines common permissions (create, read, update, delete, </span>
<span class="text">augment) and perm:permittee, the base property for all permissions </span>
<span class="text">properties.</span>
<span class="elem"></dc:description></span>
<span class="elem"><vann:preferredNamespaceUri</span><span class="elem">></span><span class="text">http://vocab.ox.ac.uk/perm#</span><span class="elem"></vann:preferredNamespaceUri></span>
<span class="elem"><vann:preferredNamespacePrefix</span><span class="elem">></span><span class="text">perm</span><span class="elem"></vann:preferredNamespacePrefix></span>
<span class="elem"><dct:isVersionOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
<span class="elem"><dc:creator</span><span class="elem">></span><span class="text">Alexander Dutton</span><span class="elem"></dc:creator></span>
<span class="elem"><dct:hasFormat</span><span class="elem">></span>
<span class="elem"><dctype:Text</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm/schema.html</span>"<span class="elem">></span>
<span class="elem"><dc:format</span><span class="elem">></span>
<span class="elem"><dct:IMT</span><span class="elem">></span>
<span class="elem"><rdf:value</span><span class="elem">></span><span class="text">text/html</span><span class="elem"></rdf:value></span>
<span class="elem"><rdfs:label</span> <span class="attr">xml:lang</span>="<span class="attrVal">en</span>"<span class="elem">></span><span class="text">HTML</span><span class="elem"></rdfs:label></span>
<span class="elem"></dct:IMT></span>
<span class="elem"></dc:format></span>
<span class="elem"></dctype:Text></span>
<span class="elem"></dct:hasFormat></span>
<span class="elem"><dct:hasFormat</span><span class="elem">></span>
<span class="elem"><dctype:Text</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm/schema.rdf</span>"<span class="elem">></span>
<span class="elem"><dc:format</span><span class="elem">></span>
<span class="elem"><dct:IMT</span><span class="elem">></span>
<span class="elem"><rdf:value</span><span class="elem">></span><span class="text">application/rdf+xml</span><span class="elem"></rdf:value></span>
<span class="elem"><rdfs:label</span> <span class="attr">xml:lang</span>="<span class="attrVal">en</span>"<span class="elem">></span><span class="text">RDF/XML</span><span class="elem"></rdfs:label></span>
<span class="elem"></dct:IMT></span>
<span class="elem"></dc:format></span>
<span class="elem"></dctype:Text></span>
<span class="elem"></dct:hasFormat></span>
<span class="elem"></owl:Ontology></span>
<span class="elem"><foaf:Agent</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#public</span>"<span class="elem">></span>
<span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">public</span><span class="elem"></rdfs:label></span>
<span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The union of all agents</span><span class="elem"></rdfs:comment></span>
<span class="elem"></foaf:Agent></span>
- <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">></span>
- <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">has permittee</span><span class="elem"></rdfs:label></span>
- <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The object has a permission over the subject.</span><span class="elem"></rdfs:comment></span>
- <span class="elem"><rdfs:range</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://xmlns.com/foaf/0.1/Agent</span>"<span class="elem">/></span>
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">has some permission over</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject has some permission over the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:domain</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://xmlns.com/foaf/0.1/Agent</span>"<span class="elem">/></span>
<span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
<span class="elem"></rdf:Property></span>
- <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#editableBy</span>"<span class="elem">></span>
- <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be edited by</span><span class="elem"></rdfs:label></span>
- <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may be edited by the object.</span><span class="elem"></rdfs:comment></span>
- <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#mayUpdate</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may update</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may modify the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">/></span>
<span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
<span class="elem"></rdf:Property></span>
- <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#readableBy</span>"<span class="elem">></span>
- <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be read by</span><span class="elem"></rdfs:label></span>
- <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may be read by the object.</span><span class="elem"></rdfs:comment></span>
- <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#mayRead</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may read</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may read the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">/></span>
<span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
<span class="elem"></rdf:Property></span>
- <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#deletableBy</span>"<span class="elem">></span>
- <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be deleted by</span><span class="elem"></rdfs:label></span>
- <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may be deleted by the object.</span><span class="elem"></rdfs:comment></span>
- <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#mayDelete</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may delete</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may deletethe object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">/></span>
<span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
<span class="elem"></rdf:Property></span>
- <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#augmentableBy</span>"<span class="elem">></span>
- <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be augmented by</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#mayAugment</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may augment</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may augmented (e.g. append to) the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#mayAdminister</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may administer</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject holds all permissions over the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#mayCreateChildrenOf</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may create children of</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject can create child resources of the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#hasPermissionOver</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdfs:Class</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#ResourceMatch</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">an expression to match resource URIs</span><span class="elem"></rdfs:label></span>
<span class="elem"><rdfs:comment</span><span class="elem">></span>
- <span class="text">The subject may be augmented (e.g. appended to) by the object.</span>
+ <span class="text">An instance is the union of all resource URIs matched by the regular </span>
+ <span class="text">expression in its perm:matchExpression.</span>
<span class="elem"></rdfs:comment></span>
- <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdfs:Class></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#matchExpression</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:domain</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#ResourceMatch</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:range</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://www.w3.org/2000/01/rdf-schema#Literal</span>"<span class="elem">/></span>
<span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
<span class="elem"></rdf:Property></span>
<span class="elem"></rdf:RDF></span>
</code></pre><div id="footer">
Documentation generated using the <a href="http://vocab.org/2004/03/toolchain">vocab.org toolchain</a>.
</div></body></html>
diff --git a/permissions/vocab-0.1.rdf b/permissions/vocab-0.1.rdf
index eaed4e8..4e047ec 100644
--- a/permissions/vocab-0.1.rdf
+++ b/permissions/vocab-0.1.rdf
@@ -1,101 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rdf:RDF [
<!ENTITY perm "http://vocab.ox.ac.uk/perm#">
<!ENTITY foaf "http://xmlns.com/foaf/0.1/">
<!ENTITY event "http://purl.org/NET/c4dm/event.owl#">
<!ENTITY dctype "http://purl.org/dc/dcmitype/">
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">
<!ENTITY admingeo "http://data.ordnancesurvey.co.uk/ontology/admingeo/">
+ <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
]>
<rdf:RDF
xmlns:perm="&perm;"
xmlns:foaf="&foaf;"
xmlns:event="&event;"
xmlns:xsd="&xsd;"
xmlns:admingeo="&admingeo;"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+ xmlns:rdfs="&rdfs;"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dctype="&dctype;"
xmlns:dct="http://purl.org/dc/terms/"
xmlns:vann="http://purl.org/vocab/vann/"
xmlns:owl="http://www.w3.org/2002/07/owl#">
<owl:Ontology rdf:about="">
<dc:title>Ontology for modelling permissions</dc:title>
<dc:identifier>http://vocab.ox.ac.uk/perm#</dc:identifier>
<dc:description>A simple ontology for modelling permissions. Subjects are resources over which permissions may be held (e.g. user accounts, documents, physical objects), and objects are foaf:Agents which may hold those permissions. This ontology defines common permissions (create, read, update, delete, augment) and perm:permittee, the base property for all permissions properties.</dc:description>
<vann:preferredNamespaceUri>http://vocab.ox.ac.uk/perm#</vann:preferredNamespaceUri>
<vann:preferredNamespacePrefix>perm</vann:preferredNamespacePrefix>
<dct:isVersionOf rdf:resource="&perm;"/>
<dc:creator>Alexander Dutton</dc:creator>
<dct:hasFormat>
<dctype:Text rdf:about="http://vocab.ox.ac.uk/perm/schema.html">
<dc:format>
<dct:IMT>
<rdf:value>text/html</rdf:value>
<rdfs:label xml:lang="en">HTML</rdfs:label>
</dct:IMT>
</dc:format>
</dctype:Text>
</dct:hasFormat>
<dct:hasFormat>
<dctype:Text rdf:about="http://vocab.ox.ac.uk/perm/schema.rdf">
<dc:format>
<dct:IMT>
<rdf:value>application/rdf+xml</rdf:value>
<rdfs:label xml:lang="en">RDF/XML</rdfs:label>
</dct:IMT>
</dc:format>
</dctype:Text>
</dct:hasFormat>
</owl:Ontology>
<foaf:Agent rdf:about="&perm;public">
<rdfs:label>public</rdfs:label>
<rdfs:comment>The union of all agents</rdfs:comment>
</foaf:Agent>
- <rdf:Property rdf:about="&perm;permittee">
- <rdfs:label>has permittee</rdfs:label>
- <rdfs:comment>The object has a permission over the subject.</rdfs:comment>
- <rdfs:range rdf:resource="&foaf;Agent"/>
+ <rdf:Property rdf:about="&perm;hasPermissionOver">
+ <rdfs:label>has some permission over</rdfs:label>
+ <rdfs:comment>The subject has some permission over the object.</rdfs:comment>
+ <rdfs:domain rdf:resource="&foaf;Agent"/>
<rdfs:isDefinedBy rdf:resource="&perm;"/>
</rdf:Property>
- <rdf:Property rdf:about="&perm;editableBy">
- <rdfs:label>may be edited by</rdfs:label>
- <rdfs:comment>The subject may be edited by the object.</rdfs:comment>
- <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdf:Property rdf:about="&perm;mayUpdate">
+ <rdfs:label>may update</rdfs:label>
+ <rdfs:comment>The subject may modify the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;hasPermissionOver"/>
<rdfs:isDefinedBy rdf:resource="&perm;"/>
</rdf:Property>
- <rdf:Property rdf:about="&perm;readableBy">
- <rdfs:label>may be read by</rdfs:label>
- <rdfs:comment>The subject may be read by the object.</rdfs:comment>
- <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdf:Property rdf:about="&perm;mayRead">
+ <rdfs:label>may read</rdfs:label>
+ <rdfs:comment>The subject may read the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;hasPermissionOver"/>
<rdfs:isDefinedBy rdf:resource="&perm;"/>
</rdf:Property>
- <rdf:Property rdf:about="&perm;deletableBy">
- <rdfs:label>may be deleted by</rdfs:label>
- <rdfs:comment>The subject may be deleted by the object.</rdfs:comment>
- <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdf:Property rdf:about="&perm;mayDelete">
+ <rdfs:label>may delete</rdfs:label>
+ <rdfs:comment>The subject may deletethe object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;hasPermissionOver"/>
<rdfs:isDefinedBy rdf:resource="&perm;"/>
</rdf:Property>
- <rdf:Property rdf:about="&perm;augmentableBy">
- <rdfs:label>may be augmented by</rdfs:label>
- <rdfs:comment>The subject may be augmented (e.g. appended to) by the object.</rdfs:comment>
- <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdf:Property rdf:about="&perm;mayAugment">
+ <rdfs:label>may augment</rdfs:label>
+ <rdfs:comment>The subject may augmented (e.g. append to) the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;hasPermissionOver"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+ <rdf:Property rdf:about="&perm;mayAdminister">
+ <rdfs:label>may administer</rdfs:label>
+ <rdfs:comment>The subject holds all permissions over the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;hasPermissionOver"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+ <rdf:Property rdf:about="&perm;mayCreateChildrenOf">
+ <rdfs:label>may create children of</rdfs:label>
+ <rdfs:comment>The subject can create child resources of the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;hasPermissionOver"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+
+ <rdfs:Class rdf:about="&perm;ResourceMatch">
+ <rdfs:label>an expression to match resource URIs</rdfs:label>
+ <rdfs:comment>An instance is the union of all resource URIs matched by the regular expression in its perm:matchExpression.</rdfs:comment>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdfs:Class>
+
+ <rdf:Property rdf:about="&perm;matchExpression">
+ <rdfs:domain rdf:resource="&perm;ResourceMatch"/>
+ <rdfs:range rdf:resource="&rdfs;Literal"/>
<rdfs:isDefinedBy rdf:resource="&perm;"/>
</rdf:Property>
</rdf:RDF>
|
ox-it/permissions-ontology
|
c607c202823613094f52878b5a85eadd4f648811
|
Beginnings of a permissions ontology.
|
diff --git a/2004/03/toolchain/cc-schema.rdfs b/2004/03/toolchain/cc-schema.rdfs
new file mode 100644
index 0000000..e06e248
--- /dev/null
+++ b/2004/03/toolchain/cc-schema.rdfs
@@ -0,0 +1,103 @@
+<rdf:RDF xmlns="http://web.resource.org/cc/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
+
+ <rdfs:Class rdf:about="http://web.resource.org/cc/Work">
+ <dc:title>work</dc:title>
+ <dc:description>a potentially copyrightable work</dc:description>
+ <rdfs:seeAlso rdf:resource="http://www.w3.org/2000/10/swap/pim/doc#Work"/>
+ </rdfs:Class>
+ <rdfs:Class rdf:about="http://web.resource.org/cc/Agent">
+ <dc:title>agent</dc:title>
+ <dc:description>something (e.g. a person, corporation or computer) capable of creating things</dc:description>
+ </rdfs:Class>
+ <rdfs:Class rdf:about="http://web.resource.org/cc/License">
+ <dc:title>license</dc:title>
+ <dc:description>a set of requests/permissions to users of a Work, e.g. a copyright license, the public domain, information for distributors</dc:description>
+ </rdfs:Class>
+ <rdfs:Class rdf:about="http://web.resource.org/cc/Permission">
+ <dc:title>permission</dc:title>
+ <dc:description>an action that may or may not be allowed or desired</dc:description>
+ </rdfs:Class>
+ <rdfs:Class rdf:about="http://web.resource.org/cc/Requirement">
+ <dc:title>requirement</dc:title>
+ <dc:description>an action that may or may not be requested of you</dc:description>
+ </rdfs:Class>
+ <rdfs:Class rdf:about="http://web.resource.org/cc/Prohibition">
+ <dc:title>prohibition</dc:title>
+ <dc:description>something you may be asked not to do</dc:description>
+ </rdfs:Class>
+
+ <License rdf:about="http://web.resource.org/cc/PublicDomain">
+ <dc:title>public domain</dc:title>
+ <dc:description>no copyright; everything is permitted without restriction</dc:description>
+ </License>
+
+ <Permission rdf:about="http://web.resource.org/cc/Reproduction">
+ <dc:title>reproduction</dc:title>
+ <dc:description>making multiple copies</dc:description>
+ </Permission>
+ <Permission rdf:about="http://web.resource.org/cc/Distribution">
+ <dc:title>distribution</dc:title>
+ <dc:description>distribution, public display, and publicly performance</dc:description>
+ </Permission>
+ <Permission rdf:about="http://web.resource.org/cc/DerivativeWorks">
+ <dc:title>derivative works</dc:title>
+ <dc:description>creation and distribution of derivative works</dc:description>
+ </Permission>
+
+ <Requirement rdf:about="http://web.resource.org/cc/Notice">
+ <dc:title>copyright notices</dc:title>
+ <dc:description>copyright and license notices be kept intact</dc:description>
+ </Requirement>
+ <Requirement rdf:about="http://web.resource.org/cc/Attribution">
+ <dc:title>attribution</dc:title>
+ <dc:description>credit be given to copyright holder and/or author</dc:description>
+ </Requirement>
+ <Requirement rdf:about="http://web.resource.org/cc/ShareAlike">
+ <dc:title>share alike</dc:title>
+ <dc:description>derivative works be licensed under the same terms as the original work</dc:description>
+ </Requirement>
+ <Requirement rdf:about="http://web.resource.org/cc/SourceCode">
+ <dc:title>source code</dc:title>
+ <dc:description>source code (the preferred form for making modifications) must be provided for all derivative works</dc:description>
+ </Requirement>
+
+ <Prohibition rdf:about="http://web.resource.org/cc/CommercialUse">
+ <dc:title>commercial use</dc:title>
+ <dc:description>exercising rights for commercial purposes</dc:description>
+ </Prohibition>
+
+ <rdf:Property rdf:about="http://web.resource.org/cc/license">
+ <dc:title>has license</dc:title>
+ <rdfs:domain rdf:resource="http://web.resource.org/cc/Work"/>
+ <rdfs:range rdf:resource="http://web.resource.org/cc/License"/>
+ <rdfs:seeAlso rdf:resource="http://www.w3.org/2000/10/swap/pim/doc#ipr"/>
+ <rdfs:subPropertyOf rdf:resource="http://purl.org/dc/elements/1.1/rights"/>
+ </rdf:Property>
+ <rdf:Property rdf:about="http://web.resource.org/cc/permits">
+ <dc:title>permits</dc:title>
+ <rdfs:domain rdf:resource="http://web.resource.org/cc/License"/>
+ <rdfs:range rdf:resource="http://web.resource.org/cc/Permission"/>
+ </rdf:Property>
+ <rdf:Property rdf:about="http://web.resource.org/cc/requires">
+ <dc:title>requires</dc:title>
+ <rdfs:domain rdf:resource="http://web.resource.org/cc/License"/>
+ <rdfs:range rdf:resource="http://web.resource.org/cc/Requirement"/>
+ </rdf:Property>
+ <rdf:Property rdf:about="http://web.resource.org/cc/prohibits">
+ <dc:title>prohibits</dc:title>
+ <rdfs:domain rdf:resource="http://web.resource.org/cc/License"/>
+ <rdfs:range rdf:resource="http://web.resource.org/cc/Prohibition"/>
+ </rdf:Property>
+
+ <!-- Utility Terms -->
+
+ <rdf:Property rdf:about="http://web.resource.org/cc/derivativeWork">
+ <dc:title>has a derivative work</dc:title>
+ <rdfs:domain rdf:resource="http://web.resource.org/cc/Work" />
+ <rdfs:range rdf:resource="http://web.resource.org/cc/Work" />
+ <rdfs:seeAlso rdf:resource="http://purl.org/dc/elements/1.1/source" />
+ </rdf:Property>
+</rdf:RDF>
diff --git a/2004/03/toolchain/pretty-xml.xsl b/2004/03/toolchain/pretty-xml.xsl
new file mode 100644
index 0000000..70086e7
--- /dev/null
+++ b/2004/03/toolchain/pretty-xml.xsl
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns="http://www.w3.org/1999/xhtml"
+
+>
+ <xsl:output method="xml" version="1.0" encoding="utf-8" omit-xml-declaration="no" standalone="no" indent="no"/>
+ <xsl:template match="*" mode="html">
+ <xsl:variable name="indent" select="2 * count(ancestor::*)"/>
+ <xsl:call-template name="indent">
+ <xsl:with-param name="depth" select="$indent"/>
+ </xsl:call-template>
+
+ <xsl:if test="$indent = 2">
+ <xsl:text>
</xsl:text>
+ <xsl:call-template name="indent">
+ <xsl:with-param name="depth" select="$indent"/>
+ </xsl:call-template>
+ </xsl:if>
+
+ <xsl:variable name="elementNameLength" select="string-length(name())"/>
+
+ <span class="elem"><<xsl:value-of select="name()"/></span>
+
+ <xsl:if test="count(parent::*) = 0">
+ <xsl:for-each select="namespace::*[name() != 'xml']">
+<!--
+ <xsl:if test="count(parent::*/namespace::*) > 1">
+-->
+ <xsl:text>
</xsl:text>
+ <xsl:call-template name="indent">
+ <xsl:with-param name="depth" select="$indent+ 2"/>
+ </xsl:call-template>
+<!--
+ </xsl:if>
+-->
+ <xsl:text> </xsl:text>
+ <span class="attr">
+ <xsl:text>xmlns:</xsl:text>
+ <xsl:value-of select="name()"/>
+ </span>
+ <xsl:text>="</xsl:text>
+ <span class="attrVal">
+ <xsl:value-of select="."/>
+ </span>
+ <xsl:text>"</xsl:text>
+ </xsl:for-each>
+ </xsl:if>
+
+ <xsl:for-each select="@*">
+ <xsl:if test="count(parent::*/@*) > 1">
+ <xsl:text>
</xsl:text>
+ <xsl:call-template name="indent">
+ <xsl:with-param name="depth" select="$indent+ 2"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:text> </xsl:text>
+ <span class="attr">
+ <xsl:value-of select="name()"/>
+ </span>
+ <xsl:text>="</xsl:text>
+ <span class="attrVal">
+ <xsl:value-of select="."/>
+ </span>
+ <xsl:text>"</xsl:text>
+ </xsl:for-each>
+ <span class="elem">
+ <xsl:if test="count(child::*|child::text()) = 0">
+ <xsl:text>/</xsl:text>
+ </xsl:if>
+ <xsl:text>></xsl:text>
+ </span>
+ <xsl:choose>
+ <xsl:when test="count(text()) = 0 or string-length(normalize-space(text())) > 60 or count(@*[name() != 'xml:lang']) > 0 or count(descendant::*|descendant::text()) != count(child::*|child::text())">
+ <xsl:text>
</xsl:text>
+ <xsl:apply-templates select="child::*|child::text()" mode="html" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="child::*|child::text()" mode="html"/>
+ </xsl:otherwise>
+
+ </xsl:choose>
+ <xsl:if test="count(child::*) > 0">
+ <xsl:call-template name="indent">
+ <xsl:with-param name="depth" select="$indent"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="count(child::*|child::text()) > 0">
+ <span class="elem"></<xsl:value-of select="name()"/>></span>
+ <xsl:text>
</xsl:text>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="text()" mode="html">
+ <xsl:variable name="indent" select="2 * count(ancestor::*)"/>
+ <xsl:if test="normalize-space(.)">
+ <xsl:choose>
+ <xsl:when test="string-length(.) > 60">
+ <xsl:call-template name="indent">
+ <xsl:with-param name="depth" select="$indent"/>
+ </xsl:call-template>
+ <xsl:call-template name="breakText">
+ <xsl:with-param name="text">
+ <xsl:value-of select="normalize-space(.)"/>
+ </xsl:with-param>
+ <xsl:with-param name="columns" select="80"/>
+ <xsl:with-param name="indent" select="$indent"/>
+ </xsl:call-template>
+ <xsl:text>
</xsl:text>
+ <xsl:call-template name="indent">
+ <xsl:with-param name="depth" select="$indent - 2"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <span class="text">
+ <xsl:value-of select="normalize-space(.)"/>
+ </span>
+ </xsl:otherwise>
+
+ </xsl:choose>
+
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="breakText">
+ <xsl:param name="text" select="''"/>
+ <xsl:param name="columns" select="60"/>
+ <xsl:param name="indent" select="0"/>
+
+ <xsl:variable name="line">
+ <xsl:choose>
+ <xsl:when test="string-length($text) > ($columns - $indent) and contains($text, ' ')">
+ <xsl:call-template name="truncateToLastSpace">
+ <xsl:with-param name="text" select="substring($text, 0, $columns - $indent)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <span class="text">
+ <xsl:value-of select="$line"/>
+ </span>
+ <xsl:if test="string-length($text) > string-length($line)">
+ <xsl:text>
</xsl:text>
+ <xsl:call-template name="indent">
+ <xsl:with-param name="depth" select="$indent"/>
+ </xsl:call-template>
+ <xsl:call-template name="breakText">
+ <xsl:with-param name="text" select="substring-after($text, $line)"/>
+ <xsl:with-param name="columns" select="$columns"/>
+ <xsl:with-param name="indent" select="$indent"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="truncateToLastSpace">
+ <xsl:param name="text" select="''"/>
+ <xsl:if test="contains($text, ' ')">
+ <xsl:value-of select="substring-before($text, ' ')"/>
+
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="truncateToLastSpace">
+ <xsl:with-param name="text" select="substring-after($text, ' ')"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+
+
+</xsl:stylesheet>
diff --git a/2004/03/toolchain/vocab-extract-term-rdf.xsl b/2004/03/toolchain/vocab-extract-term-rdf.xsl
new file mode 100644
index 0000000..f912b51
--- /dev/null
+++ b/2004/03/toolchain/vocab-extract-term-rdf.xsl
@@ -0,0 +1,81 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+ xmlns:owl="http://www.w3.org/2002/07/owl#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterm="http://purl.org/dc/terms/" xmlns:vann="http://purl.org/vocab/vann/"
+xmlns:cc="http://web.resource.org/cc/"
+>
+<xsl:output method="xml" version="1.0" encoding="utf-8" omit-xml-declaration="no" standalone="no" indent="yes"/>
+
+ <xsl:param name="term"/>
+ <xsl:param name="identifier"/>
+
+
+ <xsl:template match="/">
+ <xsl:apply-templates select="rdf:RDF"/>
+ </xsl:template>
+
+ <xsl:template match="rdf:RDF">
+
+ <rdf:RDF>
+ <rdf:Description rdf:about="">
+ <xsl:copy-of select="*[@rdf:about='']/dc:contributor"/>
+ <xsl:copy-of select="*[@rdf:about='']/dc:rights"/>
+ <xsl:copy-of select="*[@rdf:about='']/vann:preferredNamespaceUri"/>
+ <xsl:copy-of select="*[@rdf:about='']/vann:preferredNamespacePrefix"/>
+ <dcterm:isPartOf rdf:resource="{*[@rdf:about='']/dc:identifier}" dc:title="{*[@rdf:about='']/dc:title|*[@rdf:about='']/@dc:title}"/>
+ <rdfs:seeAlso rdf:resource="{*[@rdf:about='']/dc:identifier}" dc:title="{*[@rdf:about='']/dc:title|*[@rdf:about='']/@dc:title}"/>
+ <dc:title>
+ <xsl:value-of select="*[@rdf:about=$term]/rdfs:label | *[@rdf:about=$term]/@rdfs:label"/>
+ </dc:title>
+
+ <dc:description>
+ <xsl:value-of select="*[@rdf:about=$term]/rdfs:label|*[@rdf:about=$term]/@rdfs:label"/>
+ <xsl:text>, a term in </xsl:text>
+ <xsl:value-of select="*[@rdf:about='']/dc:title|*[@rdf:about='']/@dc:title"/>
+ </dc:description>
+
+ <dc:identifier>
+ <xsl:value-of select="$identifier"/>
+ </dc:identifier>
+
+ <dcterm:isVersionOf rdf:resource="{$term}"/>
+
+ <dcterm:hasFormat>
+ <rdf:Description rdf:about="{$identifier}.html">
+ <dc:format>
+ <dcterm:IMT>
+ <rdf:value>text/html</rdf:value>
+ <rdfs:label xml:lang="en">HTML</rdfs:label>
+ </dcterm:IMT>
+ </dc:format>
+ </rdf:Description>
+ </dcterm:hasFormat>
+ <dcterm:hasFormat>
+ <rdf:Description rdf:about="{$identifier}.rdf">
+ <dc:format>
+ <dcterm:IMT>
+ <rdf:value>application/rdf+xml</rdf:value>
+ <rdfs:label xml:lang="en">RDF</rdfs:label>
+ </dcterm:IMT>
+ </dc:format>
+ </rdf:Description>
+ </dcterm:hasFormat>
+
+
+ </rdf:Description>
+
+ <xsl:copy-of select="*[@rdf:about=$term]"/>
+ <xsl:copy-of select="cc:Work[@rdf:about='']"/>
+ <xsl:copy-of select="cc:License"/>
+ </rdf:RDF>
+ </xsl:template>
+
+ <xsl:template match="*|@*|text()" />
+
+
+
+
+</xsl:stylesheet>
diff --git a/2004/03/toolchain/vocab-generate-makefile.xsl b/2004/03/toolchain/vocab-generate-makefile.xsl
new file mode 100644
index 0000000..83180d2
--- /dev/null
+++ b/2004/03/toolchain/vocab-generate-makefile.xsl
@@ -0,0 +1,343 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:owl="http://www.w3.org/2002/07/owl#"
+>
+
+ <xsl:output method="text" encoding="ascii"/>
+ <xsl:param name="schema"/>
+ <xsl:param name="canonicalFilename" select="'index'"/>
+ <xsl:param name="date"/>
+ <xsl:param name="pathPrefix"/>
+ <xsl:param name="toolchain-dir" select="'../2004/03/toolchain/'"/>
+
+ <xsl:template match="/">
+ <xsl:choose>
+ <xsl:when test="string-length($schema)=0">
+ <xsl:message>Schema parameter not supplied</xsl:message>
+ </xsl:when>
+ <xsl:when test="string-length($date)=0">
+ <xsl:message>Date parameter not supplied</xsl:message>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>XSLT=xsltproc --catalogs
</xsl:text>
+ <xsl:text>
</xsl:text>
+ <xsl:apply-templates />
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <xsl:template match="rdf:RDF">
+ <xsl:variable name="vocab-version-identifier" select="*[@rdf:about='']/dc:identifier|*[@rdf:about='']/@dc:identifier" />
+ <xsl:variable name="vocab-version-rdf-filename">
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="concat($vocab-version-identifier, '.rdf')"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="vocab-version-html-filename">
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="concat($vocab-version-identifier, '.html')"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="vocab-version-htaccess-filename">
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="concat($vocab-version-identifier, '.htaccess')"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="canonical-rdf-filename">
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="concat($canonicalFilename, '.rdf')"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="canonical-html-filename">
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="concat($canonicalFilename, '.html')"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+
+ <xsl:call-template name="rule-all">
+ <xsl:with-param name="vocab-version-identifier" select="$vocab-version-identifier" />
+ <xsl:with-param name="vocab-version-rdf-filename" select="$vocab-version-rdf-filename" />
+ <xsl:with-param name="vocab-version-html-filename" select="$vocab-version-html-filename" />
+ <xsl:with-param name="vocab-version-htaccess-filename" select="$vocab-version-htaccess-filename"/>
+ <xsl:with-param name="canonical-rdf-filename" select="$canonical-rdf-filename" />
+ <xsl:with-param name="canonical-html-filename" select="$canonical-html-filename" />
+ </xsl:call-template>
+
+ <xsl:call-template name="rule-rdf-to-html">
+ <xsl:with-param name="document-rdf-filename" select="$vocab-version-rdf-filename"/>
+ <xsl:with-param name="document-html-filename" select="$vocab-version-html-filename"/>
+ <xsl:with-param name="document-identifier" select="$vocab-version-identifier" />
+ </xsl:call-template>
+
+
+ <xsl:call-template name="rule-htaccess">
+ <xsl:with-param name="document-rdf-filename" select="$vocab-version-rdf-filename"/>
+ <xsl:with-param name="document-htaccess-filename" select="$vocab-version-htaccess-filename"/>
+ <xsl:with-param name="document-identifier" select="$vocab-version-identifier" />
+ </xsl:call-template>
+
+ <xsl:call-template name="rule-clean">
+ <xsl:with-param name="vocab-version-identifier" select="$vocab-version-identifier" />
+ <xsl:with-param name="vocab-version-rdf-filename" select="$vocab-version-rdf-filename" />
+ <xsl:with-param name="vocab-version-html-filename" select="$vocab-version-html-filename" />
+ </xsl:call-template>
+
+ </xsl:template>
+
+ <xsl:template match="*|@*|text()" />
+
+ <xsl:template name="rule-all">
+ <xsl:param name="vocab-version-identifier"/>
+ <xsl:param name="vocab-version-rdf-filename" />
+ <xsl:param name="vocab-version-html-filename" />
+ <xsl:param name="vocab-version-htaccess-filename" />
+ <xsl:param name="canonical-rdf-filename" />
+ <xsl:param name="canonical-html-filename" />
+
+ <xsl:text>all: </xsl:text>
+ <xsl:value-of select="$vocab-version-html-filename"/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="$vocab-version-htaccess-filename"/>
+
+ <xsl:text>
</xsl:text>
+
+ <xsl:call-template name="do-copy">
+ <xsl:with-param name="from" select="$vocab-version-html-filename"/>
+ <xsl:with-param name="to" select="$canonical-html-filename"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="do-copy">
+ <xsl:with-param name="from" select="$vocab-version-rdf-filename"/>
+ <xsl:with-param name="to" select="$canonical-rdf-filename"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="do-copy">
+ <xsl:with-param name="from" select="$vocab-version-htaccess-filename"/>
+ <xsl:with-param name="to" select="'.htaccess'"/>
+ </xsl:call-template>
+
+
+
+ <xsl:text>
</xsl:text>
+ </xsl:template>
+
+
+ <xsl:template name="rule-clean">
+ <xsl:param name="vocab-version-identifier"/>
+ <xsl:param name="vocab-version-rdf-filename" />
+ <xsl:param name="vocab-version-html-filename" />
+
+ <xsl:text>clean: </xsl:text>
+ <xsl:text>
</xsl:text>
+
+
+ <xsl:call-template name="do-delete">
+ <xsl:with-param name="filename" select="$vocab-version-html-filename"/>
+ </xsl:call-template>
+
+ <xsl:text>
</xsl:text>
+
+ </xsl:template>
+
+
+ <xsl:template name="rule-rdf-to-html">
+ <xsl:param name="document-rdf-filename"/>
+ <xsl:param name="document-html-filename"/>
+ <xsl:param name="document-identifier"/>
+ <xsl:param name="term-uri"/>
+
+ <xsl:value-of select="$document-html-filename"/>
+ <xsl:text>: </xsl:text>
+ <xsl:value-of select="$document-rdf-filename"/>
+ <xsl:text>
</xsl:text>
+
+ <xsl:call-template name="do-xslt">
+ <xsl:with-param name="stylesheet" select="concat($toolchain-dir, 'vocab-html-docs.xsl')"/>
+ <xsl:with-param name="input" select="$document-rdf-filename"/>
+ <xsl:with-param name="output" select="$document-html-filename"/>
+ <xsl:with-param name="term" select="$term-uri"/>
+ <xsl:with-param name="identifier" select="$document-identifier"/>
+ </xsl:call-template>
+
+ <xsl:text>
</xsl:text>
+ </xsl:template>
+
+ <xsl:template name="rule-htaccess">
+ <xsl:param name="document-rdf-filename"/>
+ <xsl:param name="document-htaccess-filename"/>
+ <xsl:param name="document-identifier"/>
+
+ <xsl:value-of select="$document-htaccess-filename"/>
+ <xsl:text>: </xsl:text>
+ <xsl:value-of select="$document-rdf-filename"/>
+ <xsl:text>
</xsl:text>
+
+ <xsl:call-template name="do-xslt">
+ <xsl:with-param name="stylesheet" select="concat($toolchain-dir, 'vocab-htaccess.xsl')"/>
+ <xsl:with-param name="input" select="$document-rdf-filename"/>
+ <xsl:with-param name="output" select="$document-htaccess-filename"/>
+ <xsl:with-param name="identifier" select="$document-identifier"/>
+ <xsl:with-param name="pathPrefix" select="$pathPrefix"/>
+ </xsl:call-template>
+ <xsl:text></xsl:text>
+ <xsl:text>
</xsl:text>
+ </xsl:template>
+
+
+ <xsl:template name="rule-extract-term">
+ <xsl:param name="vocab-version-rdf-filename" />
+ <xsl:param name="term-version-rdf-filename"/>
+ <xsl:param name="term-version-identifier" />
+ <xsl:param name="term-uri"/>
+
+ <xsl:value-of select="$term-version-rdf-filename"/>
+ <xsl:text>: </xsl:text>
+ <xsl:value-of select="$vocab-version-rdf-filename"/>
+ <xsl:text>
</xsl:text>
+
+ <xsl:call-template name="do-xslt">
+ <xsl:with-param name="stylesheet" select="concat($toolchain-dir, 'vocab-html-docs.xsl')"/>
+ <xsl:with-param name="input" select="$vocab-version-rdf-filename"/>
+ <xsl:with-param name="output" select="$term-version-rdf-filename"/>
+ <xsl:with-param name="term" select="$term-uri"/>
+ <xsl:with-param name="identifier" select="$term-version-identifier"/>
+ </xsl:call-template>
+
+ <xsl:text>
</xsl:text>
+ </xsl:template>
+
+
+
+
+ <xsl:template name="do-copy-term">
+ <xsl:param name="term-version-html-filename"/>
+ <xsl:param name="term-version-rdf-filename"/>
+ <xsl:param name="term-name"/>
+
+ <xsl:call-template name="do-copy">
+ <xsl:with-param name="from" select="$term-version-html-filename"/>
+ <xsl:with-param name="to">
+ <xsl:value-of select="$term-name"/>
+ <xsl:text>.html</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
+
+ <xsl:call-template name="do-copy">
+ <xsl:with-param name="from" select="$term-version-rdf-filename"/>
+ <xsl:with-param name="to">
+ <xsl:value-of select="$term-name"/>
+ <xsl:text>.rdf</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
+
+ </xsl:template>
+
+ <xsl:template name="do-copy">
+ <xsl:param name="from"/>
+ <xsl:param name="to"/>
+ <xsl:text>	cp -f </xsl:text>
+ <xsl:value-of select="$from"/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="$to"/>
+ <xsl:text>
</xsl:text>
+
+ </xsl:template>
+
+ <xsl:template name="do-delete">
+ <xsl:param name="filename"/>
+ <xsl:text>	rm -f </xsl:text>
+ <xsl:value-of select="$filename"/>
+ <xsl:text>
</xsl:text>
+ </xsl:template>
+
+
+ <xsl:template name="do-xslt">
+ <xsl:param name="stylesheet"/>
+ <xsl:param name="input"/>
+ <xsl:param name="output"/>
+ <xsl:param name="term"/>
+ <xsl:param name="identifier"/>
+ <xsl:param name="pathPrefix"/>
+
+ <xsl:text>	$(XSLT) $(XSLTOPT) </xsl:text>
+
+ <xsl:if test="$term">
+ <xsl:text> --param term "'</xsl:text>
+ <xsl:value-of select="$term"/>
+ <xsl:text>'" </xsl:text>
+ </xsl:if>
+
+ <xsl:if test="$term">
+ <xsl:text> --param identifier "'</xsl:text>
+ <xsl:value-of select="$identifier "/>
+ <xsl:text>'" </xsl:text>
+ </xsl:if>
+
+ <xsl:if test="$pathPrefix">
+ <xsl:text> --param pathPrefix "'</xsl:text>
+ <xsl:value-of select="$pathPrefix"/>
+ <xsl:text>'" </xsl:text>
+ </xsl:if>
+
+
+ <xsl:text> -o </xsl:text>
+ <xsl:value-of select="$output"/>
+ <xsl:text> </xsl:text>
+
+ <xsl:value-of select="$stylesheet"/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="$input"/>
+ <xsl:text>
</xsl:text>
+ </xsl:template>
+
+
+ <xsl:template name="filename">
+ <xsl:param name="fullPath"/>
+ <xsl:choose>
+ <xsl:when test="contains($fullPath,'/')">
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="substring-after($fullPath,'/')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$fullPath"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template name="rdfToHtmlExtension">
+ <xsl:param name="uri"/>
+ <xsl:choose>
+ <xsl:when test="contains($uri, '.rdf')">
+ <xsl:value-of select="substring-before($uri, '.rdf')"/>
+ <xsl:text>.html</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$uri"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <xsl:template name="filename-from-identifier">
+ <xsl:param name="identifier"/>
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath">
+ <xsl:value-of select="$identifier"/>
+ </xsl:with-param>
+ </xsl:call-template>
+
+ </xsl:template>
+
+
+</xsl:stylesheet>
diff --git a/2004/03/toolchain/vocab-html-docs.xsl b/2004/03/toolchain/vocab-html-docs.xsl
new file mode 100644
index 0000000..4525040
--- /dev/null
+++ b/2004/03/toolchain/vocab-html-docs.xsl
@@ -0,0 +1,1459 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+ xmlns:foaf="http://xmlns.com/foaf/0.1/"
+ xmlns:wot="http://xmlns.com/wot/0.1/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:dct="http://purl.org/dc/terms/"
+ xmlns:owl="http://www.w3.org/2002/07/owl#"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:vann="http://purl.org/vocab/vann/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:skos="http://www.w3.org/2004/02/skos/core#"
+>
+<!--
+This stylesheet was authored by Ian Davis (http://purl.org/NET/iand) and is in the public domain
+
+Brief notes on the kind of RDF/XML this schema requires:
+
+ * Add an owl:Ontology element as child of rdf:RDF with rdf:about=""
+ * To owl:Ontology element
+ o Add a dc:date attribute with date of schema version in YYYY-MM-DD format
+ o Add dc:title element containing title of schema
+ o Add as many rdfs:comment elements as necessary - these become the introductory text for the schema
+ o Add a dc:identifier element containing the URI of the schema version
+ o Add a dct:isVersionOf with an rdf:resource attribute containing the URI of the namespace for the vocabulary
+ o Add a dc:creator element for each author
+ o Add a dc:rights element containing a copyright statement
+ o If schema is a revision of another then add dct:replaces element with rdf:resource attribute pointing to URI of previous version (without file type)
+ o Add vann:preferredNamespaceUri containing literal value of the schema URI
+ o Add vann:preferredNamespacePrefix containing a short namespace prefix (e.g. bio)
+ o Add links to formats:
+
+
+
+ <dct:hasFormat>
+ <dctype:Text rdf:about="&vocabid;.html">
+ <dc:format>
+ <dct:IMT>
+ <rdf:value>text/html</rdf:value>
+ <rdfs:label xml:lang="en">HTML</rdfs:label>
+ </dct:IMT>
+ </dc:format>
+ </dctype:Text>
+ </dct:hasFormat>
+
+ <dct:hasFormat>
+ <dctype:Text rdf:about="&vocabid;.rdf">
+ <dc:format>
+ <dct:IMT>
+ <rdf:value>application/rdf+xml</rdf:value>
+ <rdfs:label xml:lang="en">RDF</rdfs:label>
+ </dct:IMT>
+ </dc:format>
+ </dctype:Text>
+ </dct:hasFormat>
+
+ * Add dct:issued with the date the schema was first issued
+
+ * For each property and class definition:
+ o Important: add an rdfs:isDefinedBy element with rdf:resource attribute with value of schema namespace URI (whatever appeared in isVersionOf)
+ o Add an rdfs:label element containing the short label for the term
+ o Add a skos:defnition element containing the definition of the term. (Note when deciding on phrasing for the definition, property definitions will be prefixed with the phrase 'The value of this property is')
+ o Add as many rdfs:comment elements as necessary to document the term
+ o Add a dct:issued element containing the date the term was first issued in YYYY-MM-DD format
+ o For each editorial change to previous version add a skos:changeNote elements with an rdf:value attribute describing the change, a dc:date attribute containing the date of the change in YYYY-MM-DD format and a dc:creator attribute containing the name of the change author
+ o For each semantric change to previous version add a skos:historyNote elements with an rdf:value attribute describing the change, a dc:date attribute containing the date of the change in YYYY-MM-DD format and a dc:creator attribute containing the name of the change author
+
+-->
+
+ <xsl:output method="xml" version="1.0" encoding="utf-8" omit-xml-declaration="no" standalone="no" indent="no"/>
+ <xsl:param name="term" select="''"/>
+ <xsl:include href="pretty-xml.xsl"/>
+
+ <xsl:variable name="vocabUri">
+ <xsl:value-of select="/*/*[@rdf:about='']/dct:isVersionOf/@rdf:resource"/>
+ </xsl:variable>
+
+
+ <xsl:variable name="classes" select="/*/rdfs:Class[rdfs:isDefinedBy/@rdf:resource=$vocabUri]|/*/owl:Class[rdfs:isDefinedBy/@rdf:resource=$vocabUri]"/>
+ <xsl:variable name="properties" select="/*/rdf:Property[rdfs:isDefinedBy/@rdf:resource=$vocabUri] | /*/owl:TransitiveProperty[rdfs:isDefinedBy/@rdf:resource=$vocabUri] | /*/owl:SymmetricProperty[rdfs:isDefinedBy/@rdf:resource=$vocabUri] | /*/owl:AnnotationProperty[rdfs:isDefinedBy/@rdf:resource=$vocabUri] | /*/owl:DatatypeProperty[rdfs:isDefinedBy/@rdf:resource=$vocabUri] | /*/owl:FunctionalProperty[rdfs:isDefinedBy/@rdf:resource=$vocabUri] | /*/owl:InverseFunctionalProperty[rdfs:isDefinedBy/@rdf:resource=$vocabUri] | /*/owl:ObjectProperty[rdfs:isDefinedBy/@rdf:resource=$vocabUri] | /*/owl:OntologyProperty[rdfs:isDefinedBy/@rdf:resource=$vocabUri]"/>
+
+
+ <xsl:template match="rdf:RDF">
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <title>
+ <xsl:value-of select="*[@rdf:about='']/dc:title|*[@rdf:about='']/@dc:title"/>
+ </title>
+ <link rel="meta" type="application/rdf+xml">
+ <xsl:attribute name="title">
+ <xsl:value-of select="*[@rdf:about='']/dc:title|*[@rdf:about='']/@dc:title"/>
+ </xsl:attribute>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(*[@rdf:about='']/dc:identifier, '.rdf')"/>
+ </xsl:attribute>
+ </link>
+ <xsl:call-template name="output-style"/>
+ </head>
+
+ <body>
+
+ <h1>
+ <xsl:value-of select="*[@rdf:about='']/dc:title|*[@rdf:about='']/@dc:title"/>
+ </h1>
+ <dl class="doc-info">
+ <dt>This Version</dt>
+ <dd>
+ <a href="{*[@rdf:about='']/dc:identifier}">
+ <xsl:value-of select="*[@rdf:about='']/dc:identifier"/>
+ </a>
+ <xsl:for-each select="*[@rdf:about='']/dct:hasFormat">
+ <xsl:text> [</xsl:text>
+ <a href="{*/@rdf:about}">
+ <xsl:value-of select="*/dc:format/dct:IMT/rdfs:label"/>
+ </a>
+ <xsl:text>]</xsl:text>
+ </xsl:for-each>
+ </dd>
+
+ <dt>Latest Version</dt>
+ <dd>
+ <a href="{*[@rdf:about='']/dct:isVersionOf/@rdf:resource}">
+ <xsl:value-of select="*[@rdf:about='']/dct:isVersionOf/@rdf:resource"/>
+ </a>
+ </dd>
+
+ <xsl:if test="*[@rdf:about='']/dct:replaces/@rdf:resource">
+ <dt>Previous Version</dt>
+ <dd>
+ <a>
+ <xsl:attribute name="href"><xsl:call-template name="removeExtension"><xsl:with-param name="uri" select="*[@rdf:about='']/dct:replaces/@rdf:resource"/></xsl:call-template> </xsl:attribute>
+ <xsl:call-template name="removeExtension">
+ <xsl:with-param name="uri" select="*[@rdf:about='']/dct:replaces/@rdf:resource"/>
+ </xsl:call-template>
+ </a>
+ </dd>
+ </xsl:if>
+
+ <xsl:if test="*[@rdf:about='']/dct:isPartOf/@rdf:resource">
+ <dt>Part Of</dt>
+ <xsl:for-each select="*[@rdf:about='']/dct:isPartOf">
+ <dd>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:call-template name="removeExtension">
+ <xsl:with-param name="uri" select="@rdf:resource"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:choose>
+ <xsl:when test="@dc:title">
+ <xsl:value-of select="@dc:title"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@rdf:resource"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </a>
+ </dd>
+ </xsl:for-each>
+ </xsl:if>
+
+ <dt>Authors</dt>
+ <xsl:for-each select="*[@rdf:about='']/dc:creator">
+ <dd>
+ <xsl:value-of select="."/>
+ </dd>
+ </xsl:for-each>
+ <dt>Contributors</dt>
+ <xsl:for-each select="*[@rdf:about='']/dc:contributor">
+ <dd>
+ <xsl:value-of select="."/>
+ </dd>
+ </xsl:for-each>
+ </dl>
+
+ <xsl:if test="*[@rdf:about='']/dc:rights">
+ <p class="rights">
+ <xsl:value-of select="*[@rdf:about='']/dc:rights"/>
+ </p>
+ </xsl:if>
+
+ <xsl:if test="*[@rdf:about='']/cc:license">
+ <xsl:for-each select="*[@rdf:about='']/cc:license">
+ <xsl:variable name="licenseUri">
+ <xsl:value-of select="@rdf:resource"/>
+ </xsl:variable>
+ <p class="license">
+ <xsl:text>This work is licensed under a </xsl:text>
+ <a href="{$licenseUri}">Creative Commons License</a>
+ <xsl:text>.</xsl:text>
+ </p>
+ </xsl:for-each>
+ </xsl:if>
+
+
+ <xsl:choose>
+ <xsl:when test="$term">
+ <xsl:apply-templates select="*[@rdf:about=$term]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="generate-html"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </body>
+ </html>
+ </xsl:template>
+
+
+ <xsl:template name="generate-html">
+
+ <h2 id="toc">Table of Contents</h2>
+ <ul class="toc">
+ <li>
+ <a href="#sec-introduction">Introduction</a>
+ </li>
+
+ <xsl:if test="*[@rdf:about='']/vann:changes ">
+ <li>
+ <a href="#sec-changes">Changes From Previous Version</a>
+ </li>
+ </xsl:if>
+
+ <xsl:if test="*[@rdf:about='']/vann:preferredNamespaceUri">
+ <li>
+ <a href="#sec-namespace">Namespace</a>
+ </li>
+ </xsl:if>
+
+ <li>
+ <a href="#sec-terms">Summary of Terms</a>
+ </li>
+
+ <xsl:if test="count($classes) > 0">
+ <li>
+ <a href="#sec-classes">Vocabulary Classes</a>
+ </li>
+ </xsl:if>
+
+ <xsl:if test="count($properties) > 0">
+ <li>
+ <a href="#sec-properties">Vocabulary Properties</a>
+ </li>
+ </xsl:if>
+
+ <xsl:if test="count(*[@rdf:about='']/vann:example|*[@rdf:about='']/skos:example) > 0">
+ <li>
+ <a href="#sec-examples">Examples</a>
+ </li>
+ </xsl:if>
+ <li>
+ <a href="#sec-schema">RDF Schema</a>
+ </li>
+ <xsl:if test="*[@rdf:about='']/cc:license">
+ <li>
+ <a href="#sec-license">License</a>
+ </li>
+ </xsl:if>
+ </ul>
+
+
+
+ <h2 id="sec-introduction">Introduction</h2>
+ <xsl:apply-templates select="*[@rdf:about='']/dc:description|*[@rdf:about='']/rdfs:comment"/>
+
+
+ <h2 id="sec-changes">Changes From Previous Version</h2>
+ <ul>
+ <xsl:if test="dct:issued|@dct:issued">
+ <li><span class="date"><xsl:value-of select="*[@rdf:about='']/dct:issued|*[@rdf:about='']/@dct:issued"/></span> - first issued</li>
+ </xsl:if>
+ <xsl:apply-templates select="*[@rdf:about='']/skos:changeNote|*[@rdf:about='']/skos:historyNote" />
+ </ul>
+
+ <xsl:apply-templates select="*[@rdf:about='']/vann:changes"/>
+
+ <xsl:if test="*[@rdf:about='']/vann:preferredNamespaceUri">
+ <h2 id="sec-namespace">Namespace</h2>
+ <p>The URI for this vocabulary is </p>
+ <pre><code><xsl:value-of select="*[@rdf:about='']/vann:preferredNamespaceUri"/></code></pre>
+
+ <xsl:if test="*[@rdf:about='']/vann:preferredNamespacePrefix">
+ <p>
+ When used in XML documents the suggested prefix is <code><xsl:value-of select="*[@rdf:about='']/vann:preferredNamespacePrefix"/></code>
+ </p>
+ </xsl:if>
+ <p>Each class or property in the vocabulary has a URI constructed by appending a term name to the vocabulary URI. For example:</p>
+ <pre><code><xsl:value-of select="$properties[1]/@rdf:about"/><xsl:text>
+</xsl:text><xsl:value-of select="$classes[1]/@rdf:about"/></code></pre>
+
+ <p>The term name for a class always starts with an uppercase character. Where the term name is comprised of multiple
+ concatenated words, the leading character of each word will be an uppercase character. For example:
+ </p>
+ <pre><code>
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="$classes[1]/@rdf:about"/>
+ </xsl:call-template><xsl:text>
+</xsl:text>
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="$classes[2]/@rdf:about"/>
+ </xsl:call-template></code></pre>
+
+ <p>The term name for a property always starts with an lowercase character. Where the term name is comprised of multiple
+ concatenated words, the leading character of the second and each subsequent word will be an uppercase character. For example:
+ </p>
+ <pre><code>
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="$properties[1]/@rdf:about"/>
+ </xsl:call-template><xsl:text>
+</xsl:text>
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="$properties[2]/@rdf:about"/>
+ </xsl:call-template></code></pre>
+
+
+ </xsl:if>
+
+ <h2 id="sec-terms">Summary of Terms</h2>
+ <p>This vocabulary defines
+
+ <xsl:choose>
+ <xsl:when test="count($classes) = 0">
+ no classes
+ </xsl:when>
+ <xsl:when test="count($classes) = 1">
+ one class
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="count($classes)"/> classes
+ </xsl:otherwise>
+ </xsl:choose>
+ and
+ <xsl:choose>
+ <xsl:when test="count($properties) = 0">
+ no properties
+ </xsl:when>
+ <xsl:when test="count($properties) = 1">
+ one property
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="count($properties)"/> properties
+ </xsl:otherwise>
+ </xsl:choose>
+ .
+ </p>
+ <table>
+ <tr>
+ <th>Term Name</th>
+ <th>Type</th>
+ <th>Definition</th>
+ </tr>
+
+ <xsl:for-each select="$classes">
+ <xsl:sort select="@rdf:about"/>
+
+ <xsl:variable name="termName">
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="@rdf:about"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <tr>
+ <td>
+ <a>
+ <xsl:attribute name="href"><xsl:text>#term-</xsl:text><xsl:value-of select="$termName"/></xsl:attribute>
+ <xsl:attribute name="title"><xsl:value-of select="@rdf:about"/></xsl:attribute>
+ <xsl:value-of select="$termName"/>
+ </a>
+ </td>
+ <td>class</td>
+ <td>
+ <xsl:choose>
+ <xsl:when test="skos:definition">
+ <xsl:value-of select="skos:definition[1]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="rdfs:comment[1]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ </tr>
+ </xsl:for-each>
+
+ <xsl:for-each select="$properties">
+ <xsl:sort select="@rdf:about"/>
+
+ <xsl:variable name="termName">
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="@rdf:about"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <tr>
+ <td>
+ <a>
+ <xsl:attribute name="href"><xsl:text>#term-</xsl:text><xsl:value-of select="$termName"/></xsl:attribute>
+ <xsl:attribute name="title"><xsl:value-of select="@rdf:about"/></xsl:attribute>
+ <xsl:value-of select="$termName"/>
+ </a>
+ </td>
+ <td>property</td>
+ <td>
+ <xsl:choose>
+ <xsl:when test="skos:definition">
+ <xsl:value-of select="skos:definition[1]"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="rdfs:comment[1]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </td>
+ </tr>
+ </xsl:for-each>
+
+ </table>
+
+ <xsl:if test="count($classes) > 0">
+ <h2 id="sec-classes">Vocabulary Classes</h2>
+ <xsl:apply-templates select="$classes">
+ <xsl:sort select="@rdf:about"/>
+ </xsl:apply-templates>
+ </xsl:if>
+
+ <xsl:if test="count($properties) > 0">
+ <h2 id="sec-properties">Vocabulary Properties</h2>
+ <xsl:apply-templates select="$properties">
+ <xsl:sort select="@rdf:about"/>
+ </xsl:apply-templates>
+ </xsl:if>
+
+ <xsl:if test="count(*[@rdf:about='']/vann:example|*[@rdf:about='']/skos:example) > 0">
+ <h2 id="sec-examples">Examples</h2>
+ <xsl:apply-templates select="*[@rdf:about='']/vann:example|*[@rdf:about='']/skos:example"/>
+ </xsl:if>
+
+ <h2 id="sec-schema">RDF Schema</h2>
+ <p>
+ <xsl:text>The schema included here is informational only. The normative schema can be found at </xsl:text>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat(*[@rdf:about='']/dc:identifier, '.rdf')"/>
+ </xsl:attribute>
+ <xsl:value-of select="concat(*[@rdf:about='']/dc:identifier, '.rdf')"/>
+ </a>
+ </p>
+ <pre>
+ <code class="xml">
+ <xsl:apply-templates select="/" mode="html"/>
+ </code>
+ </pre>
+
+
+ <xsl:if test="*[@rdf:about='']/cc:license">
+ <h2 id="sec-license">License</h2>
+ <xsl:for-each select="*[@rdf:about='']/cc:license">
+ <xsl:variable name="licenseUri">
+ <xsl:value-of select="@rdf:resource"/>
+ </xsl:variable>
+ <p class="license">
+ <xsl:text>This work is licensed under a </xsl:text>
+ <a href="{$licenseUri}">Creative Commons License</a>
+ <xsl:text>.</xsl:text>
+ <xsl:apply-templates select="/rdf:RDF/cc:License[@rdf:about=$licenseUri]"/>
+ </p>
+ </xsl:for-each>
+ </xsl:if>
+
+ <div id="footer">
+ Documentation generated using the <a href="http://vocab.org/2004/03/toolchain">vocab.org toolchain</a>.
+ </div>
+
+</xsl:template>
+
+
+ <xsl:template match="rdf:Property|owl:TransitiveProperty|owl:SymmetricProperty|owl:AnnotationProperty|owl:DatatypeProperty|owl:FunctionalProperty|owl:InverseFunctionalProperty|owl:ObjectProperty|owl:OntologyProperty">
+ <xsl:variable name="uri" select="@rdf:about"/>
+
+ <div class="property">
+
+ <h3>
+ <xsl:attribute name="id"><xsl:text>term-</xsl:text><xsl:call-template name="filename"><xsl:with-param name="fullPath" select="@rdf:about"/></xsl:call-template></xsl:attribute>
+ <xsl:text>Property: </xsl:text>
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="@rdf:about"/>
+ </xsl:call-template>
+
+ </h3>
+ <div class="description">
+ <xsl:apply-templates select="skos:definition">
+ <xsl:with-param name="prelude" select="'[The value of this property is] '"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="rdfs:comment|@rdfs:comment" />
+
+ <table class="properties">
+ <tbody>
+ <tr>
+ <th>URI:</th>
+ <td>
+ <xsl:value-of select="$uri"/>
+ </td>
+ </tr>
+ <xsl:for-each select="rdfs:label|@rdfs:label">
+ <tr>
+ <th>Label:</th>
+ <td>
+ <xsl:value-of select="."/>
+ </td>
+ </tr>
+ </xsl:for-each>
+
+
+ <xsl:call-template name="resourceList">
+ <xsl:with-param name="properties" select="rdfs:domain"/>
+ <xsl:with-param name="label" select="'Domain'"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="resourceList">
+ <xsl:with-param name="properties" select="rdfs:range"/>
+ <xsl:with-param name="label" select="'Range'"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="resourceList">
+ <xsl:with-param name="properties" select="rdfs:subPropertyOf"/>
+ <xsl:with-param name="label" select="'Subproperty of'"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="resourceList">
+ <xsl:with-param name="properties" select="owl:inverseOf"/>
+ <xsl:with-param name="label" select="'Inverse of'"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="resourceList">
+ <xsl:with-param name="properties" select="owl:sameAs"/>
+ <xsl:with-param name="label" select="'Same as'"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="resourceList">
+ <xsl:with-param name="properties" select="rdfs:seeAlso"/>
+ <xsl:with-param name="label" select="'See also'"/>
+ </xsl:call-template>
+
+ <xsl:if test="count(rdfs:domain) > 0">
+ <tr>
+ <th>Paraphrase (experimental)</th>
+ <td>
+ Having a <xsl:call-template name="makeTermReference"><xsl:with-param name="uri" select="@rdf:about"/></xsl:call-template>
+ implies being
+ <xsl:apply-templates select="rdfs:domain" mode="paraphrase" />
+ </td>
+ </tr>
+ </xsl:if>
+ </tbody>
+ </table>
+
+ <h4>History</h4>
+ <ul class="historyList">
+ <xsl:if test="dct:issued|@dct:issued">
+ <li><span class="date"><xsl:value-of select="dct:issued|@dct:issued"/></span> - first issued</li>
+ </xsl:if>
+ <xsl:apply-templates select="skos:changeNote|skos:historyNote" />
+ </ul>
+
+ </div>
+
+
+ </div>
+ </xsl:template>
+
+
+
+ <xsl:template match="rdfs:Class|owl:Class">
+ <div class="class">
+ <h3>
+ <xsl:attribute name="id"><xsl:text>term-</xsl:text><xsl:call-template name="filename"><xsl:with-param name="fullPath" select="@rdf:about"/></xsl:call-template></xsl:attribute>
+ <xsl:text>Class: </xsl:text>
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="@rdf:about"/>
+ </xsl:call-template>
+ </h3>
+ <div class="description">
+ <xsl:apply-templates select="skos:definition" />
+ <xsl:apply-templates select="rdfs:comment|@rdfs:comment" />
+
+ <table class="properties">
+ <tbody>
+ <tr>
+ <th>URI:</th>
+ <td>
+ <xsl:value-of select="@rdf:about"/>
+ </td>
+ </tr>
+ <xsl:for-each select="rdfs:label|@rdfs:label">
+ <tr>
+ <th>Label:</th>
+ <td>
+ <xsl:value-of select="."/>
+ </td>
+ </tr>
+ </xsl:for-each>
+
+ <xsl:call-template name="resourceList">
+ <xsl:with-param name="properties" select="rdfs:subClassOf"/>
+ <xsl:with-param name="label" select="'Subclass of'"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="resourceList">
+ <xsl:with-param name="properties" select="owl:disjointWith"/>
+ <xsl:with-param name="label" select="'Disjoint with'"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="resourceList">
+ <xsl:with-param name="properties" select="owl:equivalentClass"/>
+ <xsl:with-param name="label" select="'Equivalent to'"/>
+ </xsl:call-template>
+
+ <xsl:call-template name="resourceList">
+ <xsl:with-param name="properties" select="owl:sameAs"/>
+ <xsl:with-param name="label" select="'Same as'"/>
+ </xsl:call-template>
+
+ <xsl:if test="count(owl:disjointWith|rdfs:subClassOf|owl:equivalentClass) > 0">
+ <tr>
+ <th>Paraphrase (experimental)</th>
+ <td>
+
+ A <xsl:call-template name="makeTermReference"><xsl:with-param name="uri" select="@rdf:about"/></xsl:call-template>
+ is something that, amongst other things,
+ <xsl:apply-templates select="rdfs:subClassOf" mode="paraphrase" />
+ <xsl:if test="count(owl:disjointWith) > 0 and count(rdfs:subClassOf) > 0">
+ <xsl:text> but </xsl:text>
+ </xsl:if>
+ <xsl:apply-templates select="owl:disjointWith" mode="paraphrase" />
+ <xsl:if test="count(owl:disjointWith|rdfs:subClassOf) > 0 and count(owl:equivalentClass) > 0">
+ <xsl:text> and must be </xsl:text>
+ </xsl:if>
+ <xsl:apply-templates select="owl:equivalentClass" mode="paraphrase" />
+ </td>
+ </tr>
+ </xsl:if>
+
+ </tbody>
+ </table>
+
+ <h4>History</h4>
+ <ul class="historyList">
+ <xsl:if test="dct:issued|@dct:issued">
+ <li><span class="date"><xsl:value-of select="dct:issued|@dct:issued"/></span> - first issued</li>
+ </xsl:if>
+ <xsl:apply-templates select="skos:changeNote|skos:historyNote" />
+ </ul>
+
+ </div>
+
+
+ </div>
+ </xsl:template>
+
+ <!-- ======================================================================== -->
+ <!-- PROPERTIES -->
+ <!-- ======================================================================== -->
+
+
+ <xsl:template name="resourceList">
+ <xsl:param name="properties"/>
+ <xsl:param name="label"/>
+ <xsl:if test="count($properties) > 0">
+ <tr>
+ <th><xsl:value-of select="$label"/></th>
+ <td>
+ <xsl:apply-templates select="$properties" mode="property"/>
+ </td>
+ </tr>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="*[@rdf:resource]" mode="property">
+ <xsl:variable name="name" select="name(.)"/>
+ <xsl:if test="count(preceding-sibling::*[name() = $name]) > 0">
+ <xsl:choose>
+ <xsl:when test="count(following-sibling::*[name() = $name]) = 0">
+ <xsl:text> and </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>, </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="@rdf:resource"/>
+ <xsl:with-param name="label" select="@rdfs:label"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="*[owl:Class]" mode="property">
+ <xsl:variable name="name" select="name(.)"/>
+ <xsl:if test="count(preceding-sibling::*[name() = $name]) > 0">
+ <xsl:choose>
+ <xsl:when test="count(following-sibling::*[name() = $name]) = 0">
+ <xsl:text> and </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>, </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:apply-templates select="owl:Class" mode="reference"/>
+ </xsl:template>
+
+ <xsl:template match="*" mode="property">
+ <xsl:if test="count(preceding-sibling::*) > 0">
+ <xsl:choose>
+ <xsl:when test="count(following-sibling::*) = 0">
+ <xsl:text> and </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>, </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:text>(a composite term, see schema)</xsl:text>
+ </xsl:template>
+
+
+ <xsl:template match="owl:Class" mode="reference">
+ <!-- Describes a reference to an owl:Class -->
+ <xsl:choose>
+ <xsl:when test="owl:unionOf[@rdf:parseType='Collection']/owl:Class">
+ <xsl:text>Union of </xsl:text>
+ <xsl:apply-templates mode="reference"/>
+ </xsl:when>
+ <xsl:when test="owl:intersectionOf[@rdf:parseType='Collection']/owl:Class">
+ <xsl:text>Intersection of </xsl:text>
+ <xsl:apply-templates mode="reference"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>(composite term, see schema)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="owl:unionOf/owl:Class" mode="reference">
+ <!-- Describes a reference to an owl:Class that is part of a union with other classes -->
+ <xsl:if test="count(preceding-sibling::*) > 0">
+ <xsl:choose>
+ <xsl:when test="count(following-sibling::*) = 0">
+ <xsl:text> or a </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>, </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="@rdf:about"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="owl:intersectionOf/owl:Class" mode="reference">
+ <!-- Describes a reference to an owl:Class that is part of an intersection with other classes -->
+ <xsl:if test="count(preceding-sibling::*) > 0">
+ <xsl:choose>
+ <xsl:when test="count(following-sibling::*) = 0">
+ <xsl:text> and </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>, </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:choose>
+ <xsl:when test="owl:complementOf/@rdf:resource">
+ <xsl:text>everything that is not a </xsl:text>
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="owl:complementOf/@rdf:resource"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="@rdf:about"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="owl:intersectionOf/owl:Restriction" mode="reference">
+ <xsl:if test="count(preceding-sibling::*) > 0">
+ <xsl:choose>
+ <xsl:when test="count(following-sibling::*) = 0">
+ <xsl:text> and </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>, </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:text> things that have </xsl:text>
+ <xsl:choose>
+ <xsl:when test="owl:minCardinality">
+ <xsl:text> at least </xsl:text>
+ <xsl:value-of select="owl:minCardinality"/>
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="owl:onProperty/@rdf:resource"/>
+ </xsl:call-template>
+ <xsl:text> property</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ (a complex restriction, see schema)
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- ======================================================================== -->
+ <!-- PARAPHRASE -->
+ <!-- ======================================================================== -->
+
+ <xsl:template match="owl:disjointWith" mode="paraphrase">
+ <xsl:if test="count(preceding-sibling::owl:disjointWith) > 0">
+ <xsl:text > and </xsl:text>
+ </xsl:if>
+ <xsl:choose>
+ <xsl:when test="@rdf:resource">
+ is not a
+ <xsl:call-template name="makeTermReference"><xsl:with-param name="uri" select="@rdf:resource"/></xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="paraphrase" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template match="rdfs:subClassOf" mode="paraphrase">
+ <xsl:if test="count(preceding-sibling::rdfs:subClassOf) > 0">
+ <xsl:text > and </xsl:text>
+ </xsl:if>
+ <xsl:choose>
+ <xsl:when test="@rdf:resource">
+ is a
+ <xsl:call-template name="makeTermReference"><xsl:with-param name="uri" select="@rdf:resource"/></xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="paraphrase" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="rdfs:domain" mode="paraphrase">
+ <xsl:if test="count(preceding-sibling::rdfs:domain) > 0">
+ <xsl:text > and a </xsl:text>
+ </xsl:if>
+ <xsl:choose>
+ <xsl:when test="@rdf:resource">
+ <xsl:text> something that, amongst other things, is a </xsl:text>
+ <xsl:call-template name="makeTermReference"><xsl:with-param name="uri" select="@rdf:resource"/></xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="paraphrase" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="owl:Class" mode="paraphrase">
+ <xsl:choose>
+ <xsl:when test="@rdf:about">
+ <xsl:if test="count(preceding-sibling::*) > 0">
+ <xsl:text >, </xsl:text>
+ </xsl:if>
+ <xsl:call-template name="makeTermReference"><xsl:with-param name="uri" select="@rdf:about"/></xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ something that, amongst other things, is a
+ <xsl:apply-templates mode="paraphrase" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <xsl:template match="*|text()" mode="paraphrase">
+ <xsl:apply-templates mode="paraphrase" />
+ </xsl:template>
+
+ <xsl:template match="text()" mode="head"/>
+ <xsl:template match="text()" mode="body"/>
+ <xsl:template match="rdf:Description[@rdf:about='']/dc:title" mode="head">
+ <title>
+ <xsl:value-of select="."/>
+ </title>
+ </xsl:template>
+ <xsl:template match="rdf:Description[@rdf:about='']/dc:contributor" mode="body">
+ <h1>
+ <xsl:value-of select="."/>
+ </h1>
+ </xsl:template>
+
+ <xsl:template match="owl:unionOf/owl:Class" mode="paraphrase">
+ <!-- Describes a reference to an owl:Class that is part of a union with other classes -->
+ <xsl:if test="count(preceding-sibling::*) > 0">
+ <xsl:choose>
+ <xsl:when test="count(following-sibling::*) = 0">
+ <xsl:text> or a </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>, </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="@rdf:about"/>
+ </xsl:call-template>
+ </xsl:template>
+
+
+ <xsl:template match="owl:intersectionOf/owl:Class" mode="paraphrase">
+ <!-- Describes a reference to an owl:Class that is part of an intersection with other classes -->
+ <xsl:if test="count(preceding-sibling::*) > 0">
+ <xsl:choose>
+ <xsl:when test="count(following-sibling::*) = 0">
+ <xsl:text> and </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>, </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:choose>
+ <xsl:when test="owl:complementOf/@rdf:resource">
+ <xsl:text>everything that is not a </xsl:text>
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="owl:complementOf/@rdf:resource"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="@rdf:about"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="owl:intersectionOf/owl:Restriction|rdfs:subClassOf/owl:Restriction" mode="paraphrase">
+ <xsl:if test="count(preceding-sibling::*) > 0">
+ <xsl:choose>
+ <xsl:when test="count(following-sibling::*) = 0">
+ <xsl:text> and </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>, </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:text> has </xsl:text>
+ <xsl:choose>
+ <xsl:when test="owl:minCardinality">
+ <xsl:text> at least </xsl:text>
+ <xsl:value-of select="owl:minCardinality"/>
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="owl:onProperty/@rdf:resource"/>
+ </xsl:call-template>
+ <xsl:text> property</xsl:text>
+ </xsl:when>
+ <xsl:when test="owl:cardinality">
+ <xsl:text> exactly </xsl:text>
+ <xsl:value-of select="owl:cardinality"/>
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="owl:onProperty/@rdf:resource"/>
+ </xsl:call-template>
+ <xsl:text> property</xsl:text>
+ </xsl:when>
+ <xsl:when test="owl:maxCardinality">
+ <xsl:text> no more than </xsl:text>
+ <xsl:value-of select="owl:maxCardinality"/>
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="owl:onProperty/@rdf:resource"/>
+ </xsl:call-template>
+ <xsl:text> property</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ (a complex restriction, see schema)
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+
+
+ <!-- -->
+
+ <xsl:template match="skos:definition|@skos:definition">
+ <xsl:param name="prelude"/>
+ <p class="definition">
+ <strong>Definition: </strong>
+ <xsl:value-of select="$prelude"/>
+ <xsl:value-of select="."/>
+ </p>
+ </xsl:template>
+
+ <xsl:template match="skos:scopeNote|@skos:scopeNote">
+ <p class="scopeNote">
+ <xsl:value-of select="."/>
+ </p>
+ </xsl:template>
+
+ <xsl:template match="rdfs:comment|@rdfs:comment">
+ <p class="comment">
+ <xsl:value-of select="."/>
+ </p>
+ </xsl:template>
+
+ <xsl:template match="skos:changeNote">
+ <li class="changeNote">
+ <xsl:value-of select="@dc:date|dc:date"/> - editorial change by <xsl:value-of select="@dc:creator|dc:creator"/>:
+ "<xsl:value-of select="@rdf:value|rdf:value"/>"
+ </li>
+ </xsl:template>
+
+ <xsl:template match="skos:historyNote">
+ <li class="historyNote">
+ <xsl:value-of select="@dc:date|dc:date"/> - semantic change by <xsl:value-of select="@dc:creator|dc:creator"/>:
+ "<xsl:value-of select="@rdf:value|rdf:value"/>"
+ </li>
+ </xsl:template>
+
+
+ <xsl:template match="dc:description">
+ <p class="description">
+ <xsl:value-of select="."/>
+ </p>
+ </xsl:template>
+
+ <xsl:template match="vann:example|skos:example">
+ <div class="example">
+ <h3>
+ <xsl:choose>
+ <xsl:when test="dc:title|@dc:title">
+ <xsl:value-of select="dc:title|@dc:title"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="document(@rdf:resource)/*[local-name() = 'html'][1]/*[local-name() = 'head'][1]/*[local-name() = 'title'][1]"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </h3>
+ <xsl:copy-of select="document(@rdf:resource)/*[local-name() = 'html'][1]/*[local-name() = 'body'][1]"/>
+ </div>
+ </xsl:template>
+
+
+
+ <xsl:template match="vann:usageNote" >
+ <div class="usage-note">
+ <xsl:variable name="filename">
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="@rdf:resource" />
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:copy-of select="document(@rdf:resource)/*[local-name() = 'html'][1]/*[local-name() = 'body'][1]"/>
+ </div>
+ </xsl:template>
+
+
+ <xsl:template match="vann:changes">
+ <div class="changes">
+ <xsl:variable name="filename">
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="@rdf:resource" />
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:copy-of select="document(@rdf:resource)/*[local-name() = 'html'][1]/*[local-name() = 'body'][1]"/>
+ </div>
+ </xsl:template>
+
+ <xsl:template match="cc:License">
+ <p>The following section is informational only, please refer to the
+ <a href="{@rdf:about}">Original License</a> for complete license terms.
+ </p>
+ <xsl:if test="count(cc:permits) > 0">
+ <p>This license grants the following rights:</p>
+ <ul>
+ <xsl:for-each select="cc:permits">
+ <xsl:variable name="uri" select="@rdf:resource" />
+ <li>
+ <xsl:value-of select="document('cc-schema.rdfs')//*[@rdf:about = $uri]/dc:description"/>
+ (<a href="{$uri}"><xsl:value-of select="$uri"/></a>)
+ </li>
+ </xsl:for-each>
+ </ul>
+ </xsl:if>
+ <xsl:if test="count(cc:requires) > 0">
+ <p>This license imposes the following restrictions:</p>
+ <ul>
+ <xsl:for-each select="cc:requires">
+ <xsl:variable name="uri" select="@rdf:resource" />
+ <li>
+ <xsl:value-of select="document('cc-schema.rdfs')//*[@rdf:about = $uri]/dc:description"/>
+ (<a href="{$uri}"><xsl:value-of select="$uri"/></a>)
+ </li>
+ </xsl:for-each>
+ </ul>
+ </xsl:if>
+ <xsl:if test="count(cc:prohibits) > 0">
+ <p>This license prohibits the following:</p>
+ <ul>
+ <xsl:for-each select="cc:prohibits">
+ <xsl:variable name="uri" select="@rdf:resource" />
+ <li>
+ <xsl:value-of select="document('cc-schema.rdfs')//*[@rdf:about = $uri]/dc:description"/>
+ (<a href="{$uri}"><xsl:value-of select="$uri"/></a>)
+ </li>
+ </xsl:for-each>
+ </ul>
+ </xsl:if>
+ </xsl:template>
+
+
+ <xsl:template name="output-style">
+ <style type="text/css">
+ code.xml .text {
+ color: #000000;
+ background: transparent;
+ }
+ code.xml .elem {
+ color: #000080;
+ background: transparent;
+ }
+ code.xml .attr {
+ color: #008080;
+ background: transparent;
+ }
+ code.xml .attrVal {
+ color: #666666;
+ background: transparent;
+ }
+ code.xml .highlight {
+ background: #ffff00;
+ }
+
+ h1, h2, h3, h4, h5, h6 {
+ font-family: Georgia, "Times New Roman", Times, serif;
+ font-style:italic;
+ }
+
+ pre {
+ border: 1px #9999cc dotted;
+ background-color: #f3f3ff;
+ color: #000000;
+ width: 90%;
+ }
+
+ blockquote {
+ border-style: solid;
+ border-color: #d0dbe7;
+ border-width: 0 0 0 .25em;
+ padding-left: 0.5em;
+ }
+
+ blockquote, q {
+ font-style: italic;
+ }
+
+ body {
+ font-family: verdana, geneva, arial, sans-serif;
+ }
+
+ a, p,blockquote, q, dl, dd, dt {
+ font-family: verdana, geneva, arial, sans-serif;
+ font-size: 1em;
+ }
+
+
+ dt {
+ font-weight: bold;
+ }
+
+
+:link { color: #00C; background: transparent }
+:visited { color: #609; background: transparent }
+:link:active, :visited:active { color: #C00; background: transparent }
+:link:hover, :visited:hover { background: #ffa; }
+code :link, code :visited { color: inherit; }
+
+h1, h2, h3, h4, h5, h6 { text-align: left }
+h1, h2, h3 { color: #996633; background: transparent; }
+h1 { font: 900 170% sans-serif; border-bottom: 1px solid gray; }
+h2 { font: 800 140% sans-serif; border-bottom: 1px solid gray; }
+h3 { font: 700 120% sans-serif }
+h4 { font: bold 100% sans-serif }
+h5 { font: italic 100% sans-serif }
+h6 { font: small-caps 100% sans-serif }
+
+body { padding: 0 4em 2em 4em; line-height: 1.35; }
+
+pre { margin-left: 2em; /* overflow: auto; */ }
+h1 + h2 { margin-top: 0; }
+h2 { margin: 3em 0 1em 0; }
+h2 + h3 { margin-top: 0; }
+h3 { margin: 2em 0 1em 0; }
+h4 { margin: 1.5em 0 0.75em 0; }
+h5, h6 { margin: 1.5em 0 1em; }
+p { margin: 1em 0; }
+dl, dd { margin-top: 0; margin-bottom: 0; }
+dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
+dd dt { margin-top: 0.25em; margin-bottom: 0; }
+dd p { margin-top: 0; }
+p + * > li, dd li { margin: 1em 0; }
+dt, dfn { font-weight: bold; font-style: normal; }
+pre, code { font-size: inherit; font-family: monospace; }
+pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
+pre em { font-weight: bolder; font-style: normal; }
+var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
+blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
+ins { background: green; color: white; /* color: green; border: solid thin lime; padding: 0.3em; line-height: 1.6em; */ text-decoration: none; }
+del { background: maroon; color: white; /* color: maroon; border: solid thin red; padding: 0.3em; line-height: 1.6em; */ text-decoration: line-through; }
+body ins, body del { display: block; }
+body * ins, body * del { display: inline; }
+
+table.properties { width: 90%; }
+table.properties th { text-align: right; width: 9em; font-weight: normal;}
+
+table { border-collapse: collapse; border: solid #999999 1px;}
+table thead { border-bottom: solid #999999 2px; }
+table td, table th { border-left: solid #999999 1px; border-right: solid #999999 1px; border-bottom: solid #999999 1px;; vertical-align: top; padding: 0.2em; }
+
+.historyList {
+ font-size: 0.9em;
+}
+
+ </style>
+ </xsl:template>
+
+
+ <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+ <!-- U T I L I T Y T E M P L A T E S -->
+ <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+ <xsl:template name="filename">
+ <xsl:param name="fullPath"/>
+ <xsl:choose>
+ <xsl:when test="contains($fullPath,'#')">
+ <xsl:value-of select="substring-after($fullPath,'#')"/>
+ </xsl:when>
+ <xsl:when test="contains($fullPath,'/')">
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="substring-after($fullPath,'/')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$fullPath"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+ <!-- ............................................................................ -->
+ <xsl:template name="replaceString">
+ <xsl:param name="input"/>
+ <xsl:param name="searchFor"/>
+ <xsl:param name="replaceWith"/>
+ <xsl:choose>
+ <xsl:when test="contains($input, $searchFor)">
+ <xsl:value-of select="substring-before($input, $searchFor)"/>
+ <xsl:value-of select="$replaceWith"/>
+ <xsl:value-of select="substring-after($input, $searchFor)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$input"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+ <xsl:template name="rdfToHtmlExtension">
+ <xsl:param name="uri"/>
+ <xsl:choose>
+ <xsl:when test="contains($uri, '.rdf')">
+ <xsl:value-of select="substring-before($uri, '.rdf')"/>
+ <xsl:text>.html</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$uri"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <xsl:template name="removeExtension">
+ <xsl:param name="uri"/>
+ <xsl:choose>
+ <xsl:when test="contains($uri, '.rdf')">
+ <xsl:value-of select="substring-before($uri, '.rdf')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$uri"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <xsl:template name="removeLeadingAnd">
+ <xsl:param name="text"/>
+ <xsl:choose>
+ <xsl:when test="starts-with($text, ' and ')">
+ <xsl:value-of select="substring-after($text, ' and ')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <xsl:template name="indent">
+ <xsl:param name="depth" select="0"/>
+ <xsl:if test="$depth > 0">
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="indent">
+ <xsl:with-param name="depth" select="$depth - 1"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+
+
+
+ <xsl:template name="termList">
+ <xsl:param name="termUris"/>
+ <xsl:param name="listConjunction"/>
+
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="$termUris[1]"/>
+ </xsl:call-template>
+
+ <xsl:if test="count($termUris) > 1">
+ <xsl:if test="count($termUris) > 2">
+ <xsl:for-each select="$termUris[position() > 1 and position() < count($termUris)]">
+ <xsl:text>, </xsl:text>
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="."/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:if>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="$listConjunction"/>
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="makeTermReference">
+ <xsl:with-param name="uri" select="$termUris[position() = last()]"/>
+ </xsl:call-template>
+ </xsl:if>
+
+ </xsl:template>
+
+ <xsl:template name="makeTermReference">
+ <xsl:param name="uri" />
+
+ <xsl:choose>
+ <xsl:when test="$uri">
+
+ <xsl:variable name="termQName">
+ <xsl:choose>
+ <xsl:when test="starts-with($uri, $vocabUri) and count ( //*[@rdf:about='']/vann:preferredNamespacePrefix )">
+ <xsl:value-of select="//*[@rdf:about='']/vann:preferredNamespacePrefix"/>
+ <xsl:text>:</xsl:text>
+ <xsl:value-of select="substring-after($uri, $vocabUri)"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#')">
+ <xsl:text>rdf:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#')"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://www.w3.org/2000/01/rdf-schema#')">
+ <xsl:text>rdfs:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://www.w3.org/2000/01/rdf-schema#')"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://www.w3.org/2002/07/owl#')">
+ <xsl:text>owl:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://www.w3.org/2002/07/owl#')"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://purl.org/vocab/frbr/core#')">
+ <xsl:text>frbr:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://purl.org/vocab/frbr/core#')"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://xmlns.com/foaf/0.1/')">
+ <xsl:text>foaf:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://xmlns.com/foaf/0.1/')"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://xmlns.com/wordnet/1.6/')">
+ <xsl:text>wordnet:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://xmlns.com/wordnet/1.6/')"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://purl.org/dc/elements/1.1/')">
+ <xsl:text>dc:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://purl.org/dc/elements/1.1/')"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://www.w3.org/2003/01/geo/wgs84_pos#')">
+ <xsl:text>geo:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://www.w3.org/2003/01/geo/wgs84_pos#')"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://www.w3.org/2004/02/skos/core#')">
+ <xsl:text>skos:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://www.w3.org/2004/02/skos/core#')"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://www.w3.org/2001/XMLSchema#')">
+ <xsl:text>xsd:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://www.w3.org/2001/XMLSchema#')"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://www.isi.edu/~pan/damltime/time-entry.owl#')">
+ <xsl:text>owltime:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://www.isi.edu/~pan/damltime/time-entry.owl#')"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://purl.org/vocab/frbr/extended#')">
+ <xsl:text>frbre:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://purl.org/vocab/frbr/extended#')"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://purl.org/vocab/relationship/')">
+ <xsl:text>rel:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://purl.org/vocab/relationship/')"/>
+ </xsl:when>
+ <xsl:when test="starts-with($uri, 'http://purl.org/vocab/bio/0.1/')">
+ <xsl:text>bio:</xsl:text>
+ <xsl:value-of select="substring-after($uri, 'http://purl.org/vocab/bio/0.1/')"/>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:value-of select="$uri" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="//*[@rdf:about=$uri]/rdfs:label">
+ <xsl:variable name="termName">
+ <xsl:call-template name="filename">
+ <xsl:with-param name="fullPath" select="$uri"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <a>
+ <xsl:attribute name="href"><xsl:text>#term-</xsl:text><xsl:value-of select="$termName"/></xsl:attribute>
+ <xsl:attribute name="title"><xsl:value-of select="$uri"/></xsl:attribute>
+ <xsl:value-of select="$termQName"/>
+ </a>
+ </xsl:when>
+ <xsl:otherwise>
+ <a>
+ <xsl:attribute name="href"><xsl:value-of select="$uri"/></xsl:attribute>
+ <xsl:value-of select="$termQName"/>
+ </a>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+
+ <xsl:otherwise>
+ <xsl:text>(composite term ref, see schema)</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..77ea54c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,7 @@
+The toolchain is courtesy of Ian Davis and may be acquired from
+<http://vocab.org/2004/03/toolchain/>.
+
+The permissions schema is copyright the authors and contributors, and is
+licensed under a CC-BY license:
+
+ <http://creativecommons.org/licenses/by/2.0/uk/>
diff --git a/permissions/Makefile-permisions-20100704 b/permissions/Makefile-permisions-20100704
new file mode 100644
index 0000000..d033f93
--- /dev/null
+++ b/permissions/Makefile-permisions-20100704
@@ -0,0 +1,15 @@
+XSLT=xsltproc --catalogs
+
+all: vocab-0.1.html
+ cp -f vocab-0.1.html index.html
+ cp -f vocab-0.1.rdf index.rdf
+
+vocab-0.1.html: vocab-0.1.rdf
+ $(XSLT) $(XSLTOPT) -o vocab-0.1.html ../2004/03/toolchain/vocab-html-docs.xsl vocab-0.1.rdf
+
+vocab-0.1.htaccess: vocab-0.1.rdf
+ $(XSLT) $(XSLTOPT) -o vocab-0.1.htaccess ../2004/03/toolchain/vocab-htaccess.xsl vocab-0.1.rdf
+
+clean:
+ rm -f vocab-0.1.html
+
diff --git a/permissions/index.html b/permissions/index.html
new file mode 100644
index 0000000..762a57f
--- /dev/null
+++ b/permissions/index.html
@@ -0,0 +1,225 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:wot="http://xmlns.com/wot/0.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:vann="http://purl.org/vocab/vann/" xmlns:cc="http://web.resource.org/cc/" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xml:lang="en" lang="en"><head><title>Ontology for modelling permissions</title><link rel="meta" type="application/rdf+xml" title="Ontology for modelling permissions" href="http://vocab.ox.ac.uk/perm#.rdf"/><style type="text/css">
+ code.xml .text {
+ color: #000000;
+ background: transparent;
+ }
+ code.xml .elem {
+ color: #000080;
+ background: transparent;
+ }
+ code.xml .attr {
+ color: #008080;
+ background: transparent;
+ }
+ code.xml .attrVal {
+ color: #666666;
+ background: transparent;
+ }
+ code.xml .highlight {
+ background: #ffff00;
+ }
+
+ h1, h2, h3, h4, h5, h6 {
+ font-family: Georgia, "Times New Roman", Times, serif;
+ font-style:italic;
+ }
+
+ pre {
+ border: 1px #9999cc dotted;
+ background-color: #f3f3ff;
+ color: #000000;
+ width: 90%;
+ }
+
+ blockquote {
+ border-style: solid;
+ border-color: #d0dbe7;
+ border-width: 0 0 0 .25em;
+ padding-left: 0.5em;
+ }
+
+ blockquote, q {
+ font-style: italic;
+ }
+
+ body {
+ font-family: verdana, geneva, arial, sans-serif;
+ }
+
+ a, p,blockquote, q, dl, dd, dt {
+ font-family: verdana, geneva, arial, sans-serif;
+ font-size: 1em;
+ }
+
+
+ dt {
+ font-weight: bold;
+ }
+
+
+:link { color: #00C; background: transparent }
+:visited { color: #609; background: transparent }
+:link:active, :visited:active { color: #C00; background: transparent }
+:link:hover, :visited:hover { background: #ffa; }
+code :link, code :visited { color: inherit; }
+
+h1, h2, h3, h4, h5, h6 { text-align: left }
+h1, h2, h3 { color: #996633; background: transparent; }
+h1 { font: 900 170% sans-serif; border-bottom: 1px solid gray; }
+h2 { font: 800 140% sans-serif; border-bottom: 1px solid gray; }
+h3 { font: 700 120% sans-serif }
+h4 { font: bold 100% sans-serif }
+h5 { font: italic 100% sans-serif }
+h6 { font: small-caps 100% sans-serif }
+
+body { padding: 0 4em 2em 4em; line-height: 1.35; }
+
+pre { margin-left: 2em; /* overflow: auto; */ }
+h1 + h2 { margin-top: 0; }
+h2 { margin: 3em 0 1em 0; }
+h2 + h3 { margin-top: 0; }
+h3 { margin: 2em 0 1em 0; }
+h4 { margin: 1.5em 0 0.75em 0; }
+h5, h6 { margin: 1.5em 0 1em; }
+p { margin: 1em 0; }
+dl, dd { margin-top: 0; margin-bottom: 0; }
+dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
+dd dt { margin-top: 0.25em; margin-bottom: 0; }
+dd p { margin-top: 0; }
+p + * > li, dd li { margin: 1em 0; }
+dt, dfn { font-weight: bold; font-style: normal; }
+pre, code { font-size: inherit; font-family: monospace; }
+pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
+pre em { font-weight: bolder; font-style: normal; }
+var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
+blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
+ins { background: green; color: white; /* color: green; border: solid thin lime; padding: 0.3em; line-height: 1.6em; */ text-decoration: none; }
+del { background: maroon; color: white; /* color: maroon; border: solid thin red; padding: 0.3em; line-height: 1.6em; */ text-decoration: line-through; }
+body ins, body del { display: block; }
+body * ins, body * del { display: inline; }
+
+table.properties { width: 90%; }
+table.properties th { text-align: right; width: 9em; font-weight: normal;}
+
+table { border-collapse: collapse; border: solid #999999 1px;}
+table thead { border-bottom: solid #999999 2px; }
+table td, table th { border-left: solid #999999 1px; border-right: solid #999999 1px; border-bottom: solid #999999 1px;; vertical-align: top; padding: 0.2em; }
+
+.historyList {
+ font-size: 0.9em;
+}
+
+ </style></head><body><h1>Ontology for modelling permissions</h1><dl class="doc-info"><dt>This Version</dt><dd><a href="http://vocab.ox.ac.uk/perm#">http://vocab.ox.ac.uk/perm#</a> [<a href="http://vocab.ox.ac.uk/perm/schema.html">HTML</a>] [<a href="http://vocab.ox.ac.uk/perm/schema.rdf">RDF/XML</a>]</dd><dt>Latest Version</dt><dd><a href="http://vocab.ox.ac.uk/perm#">http://vocab.ox.ac.uk/perm#</a></dd><dt>Authors</dt><dd>Alexander Dutton</dd><dt>Contributors</dt></dl><h2 id="toc">Table of Contents</h2><ul class="toc"><li><a href="#sec-introduction">Introduction</a></li><li><a href="#sec-namespace">Namespace</a></li><li><a href="#sec-terms">Summary of Terms</a></li><li><a href="#sec-properties">Vocabulary Properties</a></li><li><a href="#sec-schema">RDF Schema</a></li></ul><h2 id="sec-introduction">Introduction</h2><p class="description">A simple ontology for modelling permissions. Subjects are resources over which permissions may be held (e.g. user accounts, documents, physical objects), and objects are foaf:Agents which may hold those permissions. This ontology defines common permissions (create, read, update, delete, augment) and perm:permittee, the base property for all permissions properties.</p><h2 id="sec-changes">Changes From Previous Version</h2><ul/><h2 id="sec-namespace">Namespace</h2><p>The URI for this vocabulary is </p><pre><code>http://vocab.ox.ac.uk/perm#</code></pre><p>
+ When used in XML documents the suggested prefix is <code>perm</code></p><p>Each class or property in the vocabulary has a URI constructed by appending a term name to the vocabulary URI. For example:</p><pre><code>http://vocab.ox.ac.uk/perm#permittee
+</code></pre><p>The term name for a class always starts with an uppercase character. Where the term name is comprised of multiple
+ concatenated words, the leading character of each word will be an uppercase character. For example:
+ </p><pre><code>
+</code></pre><p>The term name for a property always starts with an lowercase character. Where the term name is comprised of multiple
+ concatenated words, the leading character of the second and each subsequent word will be an uppercase character. For example:
+ </p><pre><code>permittee
+editableBy</code></pre><h2 id="sec-terms">Summary of Terms</h2><p>This vocabulary defines
+
+
+ no classes
+
+ and
+ 5 properties
+
+ .
+ </p><table><tr><th>Term Name</th><th>Type</th><th>Definition</th></tr><tr><td><a href="#term-augmentableBy" title="http://vocab.ox.ac.uk/perm#augmentableBy">augmentableBy</a></td><td>property</td><td>The subject may be augmented (e.g. appended to) by the object.</td></tr><tr><td><a href="#term-deletableBy" title="http://vocab.ox.ac.uk/perm#deletableBy">deletableBy</a></td><td>property</td><td>The subject may be deleted by the object.</td></tr><tr><td><a href="#term-editableBy" title="http://vocab.ox.ac.uk/perm#editableBy">editableBy</a></td><td>property</td><td>The subject may be edited by the object.</td></tr><tr><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">permittee</a></td><td>property</td><td>The object has a permission over the subject.</td></tr><tr><td><a href="#term-readableBy" title="http://vocab.ox.ac.uk/perm#readableBy">readableBy</a></td><td>property</td><td>The subject may be read by the object.</td></tr></table><h2 id="sec-properties">Vocabulary Properties</h2><div class="property"><h3 id="term-augmentableBy">Property: augmentableBy</h3><div class="description"><p class="comment">The subject may be augmented (e.g. appended to) by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#augmentableBy</td></tr><tr><th>Label:</th><td>may be augmented by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-deletableBy">Property: deletableBy</h3><div class="description"><p class="comment">The subject may be deleted by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#deletableBy</td></tr><tr><th>Label:</th><td>may be deleted by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-editableBy">Property: editableBy</h3><div class="description"><p class="comment">The subject may be edited by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#editableBy</td></tr><tr><th>Label:</th><td>may be edited by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-permittee">Property: permittee</h3><div class="description"><p class="comment">The object has a permission over the subject.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#permittee</td></tr><tr><th>Label:</th><td>has permittee</td></tr><tr><th>Range</th><td><a href="http://xmlns.com/foaf/0.1/Agent">foaf:Agent</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-readableBy">Property: readableBy</h3><div class="description"><p class="comment">The subject may be read by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#readableBy</td></tr><tr><th>Label:</th><td>may be read by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><h2 id="sec-schema">RDF Schema</h2><p>The schema included here is informational only. The normative schema can be found at <a href="http://vocab.ox.ac.uk/perm#.rdf">http://vocab.ox.ac.uk/perm#.rdf</a></p><pre><code class="xml"><span class="elem"><rdf:RDF</span>
+ <span class="attr">xmlns:owl</span>="<span class="attrVal">http://www.w3.org/2002/07/owl#</span>"
+ <span class="attr">xmlns:vann</span>="<span class="attrVal">http://purl.org/vocab/vann/</span>"
+ <span class="attr">xmlns:dct</span>="<span class="attrVal">http://purl.org/dc/terms/</span>"
+ <span class="attr">xmlns:dctype</span>="<span class="attrVal">http://purl.org/dc/dcmitype/</span>"
+ <span class="attr">xmlns:dc</span>="<span class="attrVal">http://purl.org/dc/elements/1.1/</span>"
+ <span class="attr">xmlns:rdfs</span>="<span class="attrVal">http://www.w3.org/2000/01/rdf-schema#</span>"
+ <span class="attr">xmlns:rdf</span>="<span class="attrVal">http://www.w3.org/1999/02/22-rdf-syntax-ns#</span>"
+ <span class="attr">xmlns:admingeo</span>="<span class="attrVal">http://data.ordnancesurvey.co.uk/ontology/admingeo/</span>"
+ <span class="attr">xmlns:xsd</span>="<span class="attrVal">http://www.w3.org/2001/XMLSchema#</span>"
+ <span class="attr">xmlns:event</span>="<span class="attrVal">http://purl.org/NET/c4dm/event.owl#</span>"
+ <span class="attr">xmlns:foaf</span>="<span class="attrVal">http://xmlns.com/foaf/0.1/</span>"
+ <span class="attr">xmlns:perm</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">></span>
+
+ <span class="elem"><owl:Ontology</span> <span class="attr">rdf:about</span>="<span class="attrVal"/>"<span class="elem">></span>
+ <span class="elem"><dc:title</span><span class="elem">></span><span class="text">Ontology for modelling permissions</span><span class="elem"></dc:title></span>
+ <span class="elem"><dc:identifier</span><span class="elem">></span><span class="text">http://vocab.ox.ac.uk/perm#</span><span class="elem"></dc:identifier></span>
+ <span class="elem"><dc:description</span><span class="elem">></span>
+ <span class="text">A simple ontology for modelling permissions. Subjects are resources over </span>
+ <span class="text">which permissions may be held (e.g. user accounts, documents, physical </span>
+ <span class="text">objects), and objects are foaf:Agents which may hold those permissions. </span>
+ <span class="text">This ontology defines common permissions (create, read, update, delete, </span>
+ <span class="text">augment) and perm:permittee, the base property for all permissions </span>
+ <span class="text">properties.</span>
+ <span class="elem"></dc:description></span>
+ <span class="elem"><vann:preferredNamespaceUri</span><span class="elem">></span><span class="text">http://vocab.ox.ac.uk/perm#</span><span class="elem"></vann:preferredNamespaceUri></span>
+ <span class="elem"><vann:preferredNamespacePrefix</span><span class="elem">></span><span class="text">perm</span><span class="elem"></vann:preferredNamespacePrefix></span>
+ <span class="elem"><dct:isVersionOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"><dc:creator</span><span class="elem">></span><span class="text">Alexander Dutton</span><span class="elem"></dc:creator></span>
+ <span class="elem"><dct:hasFormat</span><span class="elem">></span>
+ <span class="elem"><dctype:Text</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm/schema.html</span>"<span class="elem">></span>
+ <span class="elem"><dc:format</span><span class="elem">></span>
+ <span class="elem"><dct:IMT</span><span class="elem">></span>
+ <span class="elem"><rdf:value</span><span class="elem">></span><span class="text">text/html</span><span class="elem"></rdf:value></span>
+ <span class="elem"><rdfs:label</span> <span class="attr">xml:lang</span>="<span class="attrVal">en</span>"<span class="elem">></span><span class="text">HTML</span><span class="elem"></rdfs:label></span>
+ <span class="elem"></dct:IMT></span>
+ <span class="elem"></dc:format></span>
+ <span class="elem"></dctype:Text></span>
+ <span class="elem"></dct:hasFormat></span>
+ <span class="elem"><dct:hasFormat</span><span class="elem">></span>
+ <span class="elem"><dctype:Text</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm/schema.rdf</span>"<span class="elem">></span>
+ <span class="elem"><dc:format</span><span class="elem">></span>
+ <span class="elem"><dct:IMT</span><span class="elem">></span>
+ <span class="elem"><rdf:value</span><span class="elem">></span><span class="text">application/rdf+xml</span><span class="elem"></rdf:value></span>
+ <span class="elem"><rdfs:label</span> <span class="attr">xml:lang</span>="<span class="attrVal">en</span>"<span class="elem">></span><span class="text">RDF/XML</span><span class="elem"></rdfs:label></span>
+ <span class="elem"></dct:IMT></span>
+ <span class="elem"></dc:format></span>
+ <span class="elem"></dctype:Text></span>
+ <span class="elem"></dct:hasFormat></span>
+ <span class="elem"></owl:Ontology></span>
+
+ <span class="elem"><foaf:Agent</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#public</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">public</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The union of all agents</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"></foaf:Agent></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">has permittee</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The object has a permission over the subject.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:range</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://xmlns.com/foaf/0.1/Agent</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#editableBy</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be edited by</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may be edited by the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#readableBy</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be read by</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may be read by the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#deletableBy</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be deleted by</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may be deleted by the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#augmentableBy</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be augmented by</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span>
+ <span class="text">The subject may be augmented (e.g. appended to) by the object.</span>
+ <span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+<span class="elem"></rdf:RDF></span>
+</code></pre><div id="footer">
+ Documentation generated using the <a href="http://vocab.org/2004/03/toolchain">vocab.org toolchain</a>.
+ </div></body></html>
diff --git a/permissions/index.rdf b/permissions/index.rdf
new file mode 100644
index 0000000..eaed4e8
--- /dev/null
+++ b/permissions/index.rdf
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE rdf:RDF [
+ <!ENTITY perm "http://vocab.ox.ac.uk/perm#">
+ <!ENTITY foaf "http://xmlns.com/foaf/0.1/">
+ <!ENTITY event "http://purl.org/NET/c4dm/event.owl#">
+ <!ENTITY dctype "http://purl.org/dc/dcmitype/">
+ <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">
+ <!ENTITY admingeo "http://data.ordnancesurvey.co.uk/ontology/admingeo/">
+]>
+
+<rdf:RDF
+ xmlns:perm="&perm;"
+ xmlns:foaf="&foaf;"
+ xmlns:event="&event;"
+ xmlns:xsd="&xsd;"
+ xmlns:admingeo="&admingeo;"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:dctype="&dctype;"
+ xmlns:dct="http://purl.org/dc/terms/"
+ xmlns:vann="http://purl.org/vocab/vann/"
+ xmlns:owl="http://www.w3.org/2002/07/owl#">
+
+ <owl:Ontology rdf:about="">
+ <dc:title>Ontology for modelling permissions</dc:title>
+ <dc:identifier>http://vocab.ox.ac.uk/perm#</dc:identifier>
+ <dc:description>A simple ontology for modelling permissions. Subjects are resources over which permissions may be held (e.g. user accounts, documents, physical objects), and objects are foaf:Agents which may hold those permissions. This ontology defines common permissions (create, read, update, delete, augment) and perm:permittee, the base property for all permissions properties.</dc:description>
+ <vann:preferredNamespaceUri>http://vocab.ox.ac.uk/perm#</vann:preferredNamespaceUri>
+ <vann:preferredNamespacePrefix>perm</vann:preferredNamespacePrefix>
+
+ <dct:isVersionOf rdf:resource="&perm;"/>
+
+ <dc:creator>Alexander Dutton</dc:creator>
+
+ <dct:hasFormat>
+ <dctype:Text rdf:about="http://vocab.ox.ac.uk/perm/schema.html">
+ <dc:format>
+ <dct:IMT>
+ <rdf:value>text/html</rdf:value>
+ <rdfs:label xml:lang="en">HTML</rdfs:label>
+ </dct:IMT>
+ </dc:format>
+ </dctype:Text>
+ </dct:hasFormat>
+
+ <dct:hasFormat>
+ <dctype:Text rdf:about="http://vocab.ox.ac.uk/perm/schema.rdf">
+ <dc:format>
+ <dct:IMT>
+ <rdf:value>application/rdf+xml</rdf:value>
+ <rdfs:label xml:lang="en">RDF/XML</rdfs:label>
+ </dct:IMT>
+ </dc:format>
+ </dctype:Text>
+ </dct:hasFormat>
+
+ </owl:Ontology>
+
+ <foaf:Agent rdf:about="&perm;public">
+ <rdfs:label>public</rdfs:label>
+ <rdfs:comment>The union of all agents</rdfs:comment>
+ </foaf:Agent>
+
+ <rdf:Property rdf:about="&perm;permittee">
+ <rdfs:label>has permittee</rdfs:label>
+ <rdfs:comment>The object has a permission over the subject.</rdfs:comment>
+ <rdfs:range rdf:resource="&foaf;Agent"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+ <rdf:Property rdf:about="&perm;editableBy">
+ <rdfs:label>may be edited by</rdfs:label>
+ <rdfs:comment>The subject may be edited by the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+ <rdf:Property rdf:about="&perm;readableBy">
+ <rdfs:label>may be read by</rdfs:label>
+ <rdfs:comment>The subject may be read by the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+ <rdf:Property rdf:about="&perm;deletableBy">
+ <rdfs:label>may be deleted by</rdfs:label>
+ <rdfs:comment>The subject may be deleted by the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+ <rdf:Property rdf:about="&perm;augmentableBy">
+ <rdfs:label>may be augmented by</rdfs:label>
+ <rdfs:comment>The subject may be augmented (e.g. appended to) by the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+</rdf:RDF>
diff --git a/permissions/vocab-0.1.html b/permissions/vocab-0.1.html
new file mode 100644
index 0000000..762a57f
--- /dev/null
+++ b/permissions/vocab-0.1.html
@@ -0,0 +1,225 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:wot="http://xmlns.com/wot/0.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:vann="http://purl.org/vocab/vann/" xmlns:cc="http://web.resource.org/cc/" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xml:lang="en" lang="en"><head><title>Ontology for modelling permissions</title><link rel="meta" type="application/rdf+xml" title="Ontology for modelling permissions" href="http://vocab.ox.ac.uk/perm#.rdf"/><style type="text/css">
+ code.xml .text {
+ color: #000000;
+ background: transparent;
+ }
+ code.xml .elem {
+ color: #000080;
+ background: transparent;
+ }
+ code.xml .attr {
+ color: #008080;
+ background: transparent;
+ }
+ code.xml .attrVal {
+ color: #666666;
+ background: transparent;
+ }
+ code.xml .highlight {
+ background: #ffff00;
+ }
+
+ h1, h2, h3, h4, h5, h6 {
+ font-family: Georgia, "Times New Roman", Times, serif;
+ font-style:italic;
+ }
+
+ pre {
+ border: 1px #9999cc dotted;
+ background-color: #f3f3ff;
+ color: #000000;
+ width: 90%;
+ }
+
+ blockquote {
+ border-style: solid;
+ border-color: #d0dbe7;
+ border-width: 0 0 0 .25em;
+ padding-left: 0.5em;
+ }
+
+ blockquote, q {
+ font-style: italic;
+ }
+
+ body {
+ font-family: verdana, geneva, arial, sans-serif;
+ }
+
+ a, p,blockquote, q, dl, dd, dt {
+ font-family: verdana, geneva, arial, sans-serif;
+ font-size: 1em;
+ }
+
+
+ dt {
+ font-weight: bold;
+ }
+
+
+:link { color: #00C; background: transparent }
+:visited { color: #609; background: transparent }
+:link:active, :visited:active { color: #C00; background: transparent }
+:link:hover, :visited:hover { background: #ffa; }
+code :link, code :visited { color: inherit; }
+
+h1, h2, h3, h4, h5, h6 { text-align: left }
+h1, h2, h3 { color: #996633; background: transparent; }
+h1 { font: 900 170% sans-serif; border-bottom: 1px solid gray; }
+h2 { font: 800 140% sans-serif; border-bottom: 1px solid gray; }
+h3 { font: 700 120% sans-serif }
+h4 { font: bold 100% sans-serif }
+h5 { font: italic 100% sans-serif }
+h6 { font: small-caps 100% sans-serif }
+
+body { padding: 0 4em 2em 4em; line-height: 1.35; }
+
+pre { margin-left: 2em; /* overflow: auto; */ }
+h1 + h2 { margin-top: 0; }
+h2 { margin: 3em 0 1em 0; }
+h2 + h3 { margin-top: 0; }
+h3 { margin: 2em 0 1em 0; }
+h4 { margin: 1.5em 0 0.75em 0; }
+h5, h6 { margin: 1.5em 0 1em; }
+p { margin: 1em 0; }
+dl, dd { margin-top: 0; margin-bottom: 0; }
+dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
+dd dt { margin-top: 0.25em; margin-bottom: 0; }
+dd p { margin-top: 0; }
+p + * > li, dd li { margin: 1em 0; }
+dt, dfn { font-weight: bold; font-style: normal; }
+pre, code { font-size: inherit; font-family: monospace; }
+pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
+pre em { font-weight: bolder; font-style: normal; }
+var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
+blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
+ins { background: green; color: white; /* color: green; border: solid thin lime; padding: 0.3em; line-height: 1.6em; */ text-decoration: none; }
+del { background: maroon; color: white; /* color: maroon; border: solid thin red; padding: 0.3em; line-height: 1.6em; */ text-decoration: line-through; }
+body ins, body del { display: block; }
+body * ins, body * del { display: inline; }
+
+table.properties { width: 90%; }
+table.properties th { text-align: right; width: 9em; font-weight: normal;}
+
+table { border-collapse: collapse; border: solid #999999 1px;}
+table thead { border-bottom: solid #999999 2px; }
+table td, table th { border-left: solid #999999 1px; border-right: solid #999999 1px; border-bottom: solid #999999 1px;; vertical-align: top; padding: 0.2em; }
+
+.historyList {
+ font-size: 0.9em;
+}
+
+ </style></head><body><h1>Ontology for modelling permissions</h1><dl class="doc-info"><dt>This Version</dt><dd><a href="http://vocab.ox.ac.uk/perm#">http://vocab.ox.ac.uk/perm#</a> [<a href="http://vocab.ox.ac.uk/perm/schema.html">HTML</a>] [<a href="http://vocab.ox.ac.uk/perm/schema.rdf">RDF/XML</a>]</dd><dt>Latest Version</dt><dd><a href="http://vocab.ox.ac.uk/perm#">http://vocab.ox.ac.uk/perm#</a></dd><dt>Authors</dt><dd>Alexander Dutton</dd><dt>Contributors</dt></dl><h2 id="toc">Table of Contents</h2><ul class="toc"><li><a href="#sec-introduction">Introduction</a></li><li><a href="#sec-namespace">Namespace</a></li><li><a href="#sec-terms">Summary of Terms</a></li><li><a href="#sec-properties">Vocabulary Properties</a></li><li><a href="#sec-schema">RDF Schema</a></li></ul><h2 id="sec-introduction">Introduction</h2><p class="description">A simple ontology for modelling permissions. Subjects are resources over which permissions may be held (e.g. user accounts, documents, physical objects), and objects are foaf:Agents which may hold those permissions. This ontology defines common permissions (create, read, update, delete, augment) and perm:permittee, the base property for all permissions properties.</p><h2 id="sec-changes">Changes From Previous Version</h2><ul/><h2 id="sec-namespace">Namespace</h2><p>The URI for this vocabulary is </p><pre><code>http://vocab.ox.ac.uk/perm#</code></pre><p>
+ When used in XML documents the suggested prefix is <code>perm</code></p><p>Each class or property in the vocabulary has a URI constructed by appending a term name to the vocabulary URI. For example:</p><pre><code>http://vocab.ox.ac.uk/perm#permittee
+</code></pre><p>The term name for a class always starts with an uppercase character. Where the term name is comprised of multiple
+ concatenated words, the leading character of each word will be an uppercase character. For example:
+ </p><pre><code>
+</code></pre><p>The term name for a property always starts with an lowercase character. Where the term name is comprised of multiple
+ concatenated words, the leading character of the second and each subsequent word will be an uppercase character. For example:
+ </p><pre><code>permittee
+editableBy</code></pre><h2 id="sec-terms">Summary of Terms</h2><p>This vocabulary defines
+
+
+ no classes
+
+ and
+ 5 properties
+
+ .
+ </p><table><tr><th>Term Name</th><th>Type</th><th>Definition</th></tr><tr><td><a href="#term-augmentableBy" title="http://vocab.ox.ac.uk/perm#augmentableBy">augmentableBy</a></td><td>property</td><td>The subject may be augmented (e.g. appended to) by the object.</td></tr><tr><td><a href="#term-deletableBy" title="http://vocab.ox.ac.uk/perm#deletableBy">deletableBy</a></td><td>property</td><td>The subject may be deleted by the object.</td></tr><tr><td><a href="#term-editableBy" title="http://vocab.ox.ac.uk/perm#editableBy">editableBy</a></td><td>property</td><td>The subject may be edited by the object.</td></tr><tr><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">permittee</a></td><td>property</td><td>The object has a permission over the subject.</td></tr><tr><td><a href="#term-readableBy" title="http://vocab.ox.ac.uk/perm#readableBy">readableBy</a></td><td>property</td><td>The subject may be read by the object.</td></tr></table><h2 id="sec-properties">Vocabulary Properties</h2><div class="property"><h3 id="term-augmentableBy">Property: augmentableBy</h3><div class="description"><p class="comment">The subject may be augmented (e.g. appended to) by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#augmentableBy</td></tr><tr><th>Label:</th><td>may be augmented by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-deletableBy">Property: deletableBy</h3><div class="description"><p class="comment">The subject may be deleted by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#deletableBy</td></tr><tr><th>Label:</th><td>may be deleted by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-editableBy">Property: editableBy</h3><div class="description"><p class="comment">The subject may be edited by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#editableBy</td></tr><tr><th>Label:</th><td>may be edited by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-permittee">Property: permittee</h3><div class="description"><p class="comment">The object has a permission over the subject.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#permittee</td></tr><tr><th>Label:</th><td>has permittee</td></tr><tr><th>Range</th><td><a href="http://xmlns.com/foaf/0.1/Agent">foaf:Agent</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><div class="property"><h3 id="term-readableBy">Property: readableBy</h3><div class="description"><p class="comment">The subject may be read by the object.</p><table class="properties"><tbody><tr><th>URI:</th><td>http://vocab.ox.ac.uk/perm#readableBy</td></tr><tr><th>Label:</th><td>may be read by</td></tr><tr><th>Subproperty of</th><td><a href="#term-permittee" title="http://vocab.ox.ac.uk/perm#permittee">perm:permittee</a></td></tr></tbody></table><h4>History</h4><ul class="historyList"/></div></div><h2 id="sec-schema">RDF Schema</h2><p>The schema included here is informational only. The normative schema can be found at <a href="http://vocab.ox.ac.uk/perm#.rdf">http://vocab.ox.ac.uk/perm#.rdf</a></p><pre><code class="xml"><span class="elem"><rdf:RDF</span>
+ <span class="attr">xmlns:owl</span>="<span class="attrVal">http://www.w3.org/2002/07/owl#</span>"
+ <span class="attr">xmlns:vann</span>="<span class="attrVal">http://purl.org/vocab/vann/</span>"
+ <span class="attr">xmlns:dct</span>="<span class="attrVal">http://purl.org/dc/terms/</span>"
+ <span class="attr">xmlns:dctype</span>="<span class="attrVal">http://purl.org/dc/dcmitype/</span>"
+ <span class="attr">xmlns:dc</span>="<span class="attrVal">http://purl.org/dc/elements/1.1/</span>"
+ <span class="attr">xmlns:rdfs</span>="<span class="attrVal">http://www.w3.org/2000/01/rdf-schema#</span>"
+ <span class="attr">xmlns:rdf</span>="<span class="attrVal">http://www.w3.org/1999/02/22-rdf-syntax-ns#</span>"
+ <span class="attr">xmlns:admingeo</span>="<span class="attrVal">http://data.ordnancesurvey.co.uk/ontology/admingeo/</span>"
+ <span class="attr">xmlns:xsd</span>="<span class="attrVal">http://www.w3.org/2001/XMLSchema#</span>"
+ <span class="attr">xmlns:event</span>="<span class="attrVal">http://purl.org/NET/c4dm/event.owl#</span>"
+ <span class="attr">xmlns:foaf</span>="<span class="attrVal">http://xmlns.com/foaf/0.1/</span>"
+ <span class="attr">xmlns:perm</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">></span>
+
+ <span class="elem"><owl:Ontology</span> <span class="attr">rdf:about</span>="<span class="attrVal"/>"<span class="elem">></span>
+ <span class="elem"><dc:title</span><span class="elem">></span><span class="text">Ontology for modelling permissions</span><span class="elem"></dc:title></span>
+ <span class="elem"><dc:identifier</span><span class="elem">></span><span class="text">http://vocab.ox.ac.uk/perm#</span><span class="elem"></dc:identifier></span>
+ <span class="elem"><dc:description</span><span class="elem">></span>
+ <span class="text">A simple ontology for modelling permissions. Subjects are resources over </span>
+ <span class="text">which permissions may be held (e.g. user accounts, documents, physical </span>
+ <span class="text">objects), and objects are foaf:Agents which may hold those permissions. </span>
+ <span class="text">This ontology defines common permissions (create, read, update, delete, </span>
+ <span class="text">augment) and perm:permittee, the base property for all permissions </span>
+ <span class="text">properties.</span>
+ <span class="elem"></dc:description></span>
+ <span class="elem"><vann:preferredNamespaceUri</span><span class="elem">></span><span class="text">http://vocab.ox.ac.uk/perm#</span><span class="elem"></vann:preferredNamespaceUri></span>
+ <span class="elem"><vann:preferredNamespacePrefix</span><span class="elem">></span><span class="text">perm</span><span class="elem"></vann:preferredNamespacePrefix></span>
+ <span class="elem"><dct:isVersionOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"><dc:creator</span><span class="elem">></span><span class="text">Alexander Dutton</span><span class="elem"></dc:creator></span>
+ <span class="elem"><dct:hasFormat</span><span class="elem">></span>
+ <span class="elem"><dctype:Text</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm/schema.html</span>"<span class="elem">></span>
+ <span class="elem"><dc:format</span><span class="elem">></span>
+ <span class="elem"><dct:IMT</span><span class="elem">></span>
+ <span class="elem"><rdf:value</span><span class="elem">></span><span class="text">text/html</span><span class="elem"></rdf:value></span>
+ <span class="elem"><rdfs:label</span> <span class="attr">xml:lang</span>="<span class="attrVal">en</span>"<span class="elem">></span><span class="text">HTML</span><span class="elem"></rdfs:label></span>
+ <span class="elem"></dct:IMT></span>
+ <span class="elem"></dc:format></span>
+ <span class="elem"></dctype:Text></span>
+ <span class="elem"></dct:hasFormat></span>
+ <span class="elem"><dct:hasFormat</span><span class="elem">></span>
+ <span class="elem"><dctype:Text</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm/schema.rdf</span>"<span class="elem">></span>
+ <span class="elem"><dc:format</span><span class="elem">></span>
+ <span class="elem"><dct:IMT</span><span class="elem">></span>
+ <span class="elem"><rdf:value</span><span class="elem">></span><span class="text">application/rdf+xml</span><span class="elem"></rdf:value></span>
+ <span class="elem"><rdfs:label</span> <span class="attr">xml:lang</span>="<span class="attrVal">en</span>"<span class="elem">></span><span class="text">RDF/XML</span><span class="elem"></rdfs:label></span>
+ <span class="elem"></dct:IMT></span>
+ <span class="elem"></dc:format></span>
+ <span class="elem"></dctype:Text></span>
+ <span class="elem"></dct:hasFormat></span>
+ <span class="elem"></owl:Ontology></span>
+
+ <span class="elem"><foaf:Agent</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#public</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">public</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The union of all agents</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"></foaf:Agent></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">has permittee</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The object has a permission over the subject.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:range</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://xmlns.com/foaf/0.1/Agent</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#editableBy</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be edited by</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may be edited by the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#readableBy</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be read by</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may be read by the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#deletableBy</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be deleted by</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span><span class="text">The subject may be deleted by the object.</span><span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+
+ <span class="elem"><rdf:Property</span> <span class="attr">rdf:about</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#augmentableBy</span>"<span class="elem">></span>
+ <span class="elem"><rdfs:label</span><span class="elem">></span><span class="text">may be augmented by</span><span class="elem"></rdfs:label></span>
+ <span class="elem"><rdfs:comment</span><span class="elem">></span>
+ <span class="text">The subject may be augmented (e.g. appended to) by the object.</span>
+ <span class="elem"></rdfs:comment></span>
+ <span class="elem"><rdfs:subPropertyOf</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#permittee</span>"<span class="elem">/></span>
+ <span class="elem"><rdfs:isDefinedBy</span> <span class="attr">rdf:resource</span>="<span class="attrVal">http://vocab.ox.ac.uk/perm#</span>"<span class="elem">/></span>
+ <span class="elem"></rdf:Property></span>
+<span class="elem"></rdf:RDF></span>
+</code></pre><div id="footer">
+ Documentation generated using the <a href="http://vocab.org/2004/03/toolchain">vocab.org toolchain</a>.
+ </div></body></html>
diff --git a/permissions/vocab-0.1.rdf b/permissions/vocab-0.1.rdf
new file mode 100644
index 0000000..eaed4e8
--- /dev/null
+++ b/permissions/vocab-0.1.rdf
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE rdf:RDF [
+ <!ENTITY perm "http://vocab.ox.ac.uk/perm#">
+ <!ENTITY foaf "http://xmlns.com/foaf/0.1/">
+ <!ENTITY event "http://purl.org/NET/c4dm/event.owl#">
+ <!ENTITY dctype "http://purl.org/dc/dcmitype/">
+ <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">
+ <!ENTITY admingeo "http://data.ordnancesurvey.co.uk/ontology/admingeo/">
+]>
+
+<rdf:RDF
+ xmlns:perm="&perm;"
+ xmlns:foaf="&foaf;"
+ xmlns:event="&event;"
+ xmlns:xsd="&xsd;"
+ xmlns:admingeo="&admingeo;"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:dctype="&dctype;"
+ xmlns:dct="http://purl.org/dc/terms/"
+ xmlns:vann="http://purl.org/vocab/vann/"
+ xmlns:owl="http://www.w3.org/2002/07/owl#">
+
+ <owl:Ontology rdf:about="">
+ <dc:title>Ontology for modelling permissions</dc:title>
+ <dc:identifier>http://vocab.ox.ac.uk/perm#</dc:identifier>
+ <dc:description>A simple ontology for modelling permissions. Subjects are resources over which permissions may be held (e.g. user accounts, documents, physical objects), and objects are foaf:Agents which may hold those permissions. This ontology defines common permissions (create, read, update, delete, augment) and perm:permittee, the base property for all permissions properties.</dc:description>
+ <vann:preferredNamespaceUri>http://vocab.ox.ac.uk/perm#</vann:preferredNamespaceUri>
+ <vann:preferredNamespacePrefix>perm</vann:preferredNamespacePrefix>
+
+ <dct:isVersionOf rdf:resource="&perm;"/>
+
+ <dc:creator>Alexander Dutton</dc:creator>
+
+ <dct:hasFormat>
+ <dctype:Text rdf:about="http://vocab.ox.ac.uk/perm/schema.html">
+ <dc:format>
+ <dct:IMT>
+ <rdf:value>text/html</rdf:value>
+ <rdfs:label xml:lang="en">HTML</rdfs:label>
+ </dct:IMT>
+ </dc:format>
+ </dctype:Text>
+ </dct:hasFormat>
+
+ <dct:hasFormat>
+ <dctype:Text rdf:about="http://vocab.ox.ac.uk/perm/schema.rdf">
+ <dc:format>
+ <dct:IMT>
+ <rdf:value>application/rdf+xml</rdf:value>
+ <rdfs:label xml:lang="en">RDF/XML</rdfs:label>
+ </dct:IMT>
+ </dc:format>
+ </dctype:Text>
+ </dct:hasFormat>
+
+ </owl:Ontology>
+
+ <foaf:Agent rdf:about="&perm;public">
+ <rdfs:label>public</rdfs:label>
+ <rdfs:comment>The union of all agents</rdfs:comment>
+ </foaf:Agent>
+
+ <rdf:Property rdf:about="&perm;permittee">
+ <rdfs:label>has permittee</rdfs:label>
+ <rdfs:comment>The object has a permission over the subject.</rdfs:comment>
+ <rdfs:range rdf:resource="&foaf;Agent"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+ <rdf:Property rdf:about="&perm;editableBy">
+ <rdfs:label>may be edited by</rdfs:label>
+ <rdfs:comment>The subject may be edited by the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+ <rdf:Property rdf:about="&perm;readableBy">
+ <rdfs:label>may be read by</rdfs:label>
+ <rdfs:comment>The subject may be read by the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+ <rdf:Property rdf:about="&perm;deletableBy">
+ <rdfs:label>may be deleted by</rdfs:label>
+ <rdfs:comment>The subject may be deleted by the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+ <rdf:Property rdf:about="&perm;augmentableBy">
+ <rdfs:label>may be augmented by</rdfs:label>
+ <rdfs:comment>The subject may be augmented (e.g. appended to) by the object.</rdfs:comment>
+ <rdfs:subPropertyOf rdf:resource="&perm;permittee"/>
+ <rdfs:isDefinedBy rdf:resource="&perm;"/>
+ </rdf:Property>
+
+</rdf:RDF>
|
ox-it/permissions-ontology
|
733c738c141cacd4ca38680ec444618cfab026f2
|
Added initial README.
|
diff --git a/README b/README
new file mode 100644
index 0000000..d312368
--- /dev/null
+++ b/README
@@ -0,0 +1,4 @@
+A permissions ontology
+======================
+
+
|
timcharper/railswhere
|
d563de2fffb7b4496461bc3d978ddd9cb72aee84
|
convert dos format to unix
|
diff --git a/init.rb b/init.rb
index bd4169a..f968453 100644
--- a/init.rb
+++ b/init.rb
@@ -1,3 +1,3 @@
-require 'where.rb'
-require 'search_builder.rb'
-
+require 'where.rb'
+require 'search_builder.rb'
+
diff --git a/lib/where.rb b/lib/where.rb
index ab9af9b..abb1df7 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,207 +1,207 @@
-# = Where clause generator
-# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
-#
-# <b>Usage example</b>
-# === Returning SQL
-#
-# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
-# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
-#
-# === Building a complicated where clause made easy
-#
-# def get_search_query_string
-#
-# where = Where.new
-# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
-# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
-#
-# status_where = Where.new
-# for status in params[search_statuses].split(',')
-# status_where.or 'status=?', status
-# end
-# where.and status_where unless status_where.blank?
-#
-# where.to_s
-# end
-#
-# User.find(:all, :conditions => get_search_query_string)
-#
-# === Inline
-#
-# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
-# # Sweet chaining action!
-
-
-class Where
- attr_accessor :default_params
- attr_reader :clauses, :target
- # Constructs a new where clause
- #
- # optionally, you can provide a criteria, like the following:
- #
- # Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
- def initialize(criteria_or_options=nil, *params, &block)
- @clauses=Array.new
- @target = self
- if criteria_or_options.is_a?(Hash)
- criteria = nil
- options = criteria_or_options
- else
- criteria = criteria_or_options
- options = {}
- end
- self.and(criteria, *params) unless criteria.nil?
- self.default_params = options[:default_params] || {}
-
- yield(self) if block_given?
- end
-
- def initialize_copy(from)
- @clauses = from.instance_variable_get("@clauses").clone
- end
-
- # Appends an <b>and</b> expression to your where clause
- #
- # Example:
- #
- # where = Where.new
- # where.and("name = ?", "Tim O'brien")
- # where.to_s
- #
- # # => "(name = 'Tim O''brien')
- def and(*params, &block)
- @target.append_clause(params, "AND", &block)
- end
-
- alias << and
-
- # Appends an <b>or</b> expression to your where clause
- #
- # Example:
- #
- # where = Where.new
- # where.or("name = ?", "Tim O'brien")
- # where.or("name = ?", "Tim O'neal")
- # where.to_s
- #
- # # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
- def or(*params, &block)
- @target.append_clause(params, "OR", &block)
- end
-
- # Same as or, but negates the whole expression
- def or_not(*params, &block)
- @target.append_clause(params, "OR NOT", &block)
- end
-
- # Same as and, but negates the whole expression
- def and_not(*params, &block)
- @target.append_clause(params, "AND NOT", &block)
- end
-
- def &(params)
- self.and(*params)
- end
-
- def |(params)
- self.or(*params)
- end
-
- def self.&(params)
- Where.new(*params)
- end
-
- def self.|(params)
- Where.new.or(*params)
- end
-
- # Converts the where clause to a SQL string.
- def to_s(format=nil)
- output=""
-
- @clauses.each_index{|index|
- omit_conjuction = (index==0)
- output << @clauses[index].to_s(omit_conjuction) # Omit the clause if index=0
- }
- case format
- when :where
- output.empty? ? "" : " WHERE #{output}"
- else
- output.empty? ? "(true)" : output
- end
- end
-
- alias :to_sql :to_s
-
- # Determines if any clauses have been added.
- #
- # where = Where.new
- # where.blank?
- # # => true
- #
- # where.and(nil)
- # where.blank?
- # # => true
- #
- # where.and(Where.new(nil))
- # where.blank?
- # # => true
- #
- # where.and("name=1")
- # where.blank?
- # # => false
- def blank?
- @clauses.empty?
- end
-
- alias :empty? :blank?
-
-protected
- def append_clause(params, conjuction = "AND", &block) # :nodoc:
- if block_given?
- previous_target = @target
- @target = Where.new(:default_params => default_params)
- yield
- previous_target.clauses << Clause.new(@target, conjuction)
- @target = previous_target
- else
- params = params + [default_params] if params.length == 1 && params.first.is_a?(String)
- @target.clauses << Clause.new(params, conjuction) unless params.first.blank?
- end
- self
- end
-
- # Used internally to +Where+. You shouldn't have any reason to interact with this class.
- class Clause
-
- def initialize(criteria, conjuction = "AND") # :nodoc:
- @conjuction=conjuction.upcase
- criteria = criteria.first if criteria.class==Array && criteria.length==1
-
+# = Where clause generator
+# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
+#
+# <b>Usage example</b>
+# === Returning SQL
+#
+# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
+# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
+#
+# === Building a complicated where clause made easy
+#
+# def get_search_query_string
+#
+# where = Where.new
+# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
+# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
+#
+# status_where = Where.new
+# for status in params[search_statuses].split(',')
+# status_where.or 'status=?', status
+# end
+# where.and status_where unless status_where.blank?
+#
+# where.to_s
+# end
+#
+# User.find(:all, :conditions => get_search_query_string)
+#
+# === Inline
+#
+# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
+# # Sweet chaining action!
+
+
+class Where
+ attr_accessor :default_params
+ attr_reader :clauses, :target
+ # Constructs a new where clause
+ #
+ # optionally, you can provide a criteria, like the following:
+ #
+ # Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
+ def initialize(criteria_or_options=nil, *params, &block)
+ @clauses=Array.new
+ @target = self
+ if criteria_or_options.is_a?(Hash)
+ criteria = nil
+ options = criteria_or_options
+ else
+ criteria = criteria_or_options
+ options = {}
+ end
+ self.and(criteria, *params) unless criteria.nil?
+ self.default_params = options[:default_params] || {}
+
+ yield(self) if block_given?
+ end
+
+ def initialize_copy(from)
+ @clauses = from.instance_variable_get("@clauses").clone
+ end
+
+ # Appends an <b>and</b> expression to your where clause
+ #
+ # Example:
+ #
+ # where = Where.new
+ # where.and("name = ?", "Tim O'brien")
+ # where.to_s
+ #
+ # # => "(name = 'Tim O''brien')
+ def and(*params, &block)
+ @target.append_clause(params, "AND", &block)
+ end
+
+ alias << and
+
+ # Appends an <b>or</b> expression to your where clause
+ #
+ # Example:
+ #
+ # where = Where.new
+ # where.or("name = ?", "Tim O'brien")
+ # where.or("name = ?", "Tim O'neal")
+ # where.to_s
+ #
+ # # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
+ def or(*params, &block)
+ @target.append_clause(params, "OR", &block)
+ end
+
+ # Same as or, but negates the whole expression
+ def or_not(*params, &block)
+ @target.append_clause(params, "OR NOT", &block)
+ end
+
+ # Same as and, but negates the whole expression
+ def and_not(*params, &block)
+ @target.append_clause(params, "AND NOT", &block)
+ end
+
+ def &(params)
+ self.and(*params)
+ end
+
+ def |(params)
+ self.or(*params)
+ end
+
+ def self.&(params)
+ Where.new(*params)
+ end
+
+ def self.|(params)
+ Where.new.or(*params)
+ end
+
+ # Converts the where clause to a SQL string.
+ def to_s(format=nil)
+ output=""
+
+ @clauses.each_index{|index|
+ omit_conjuction = (index==0)
+ output << @clauses[index].to_s(omit_conjuction) # Omit the clause if index=0
+ }
+ case format
+ when :where
+ output.empty? ? "" : " WHERE #{output}"
+ else
+ output.empty? ? "(true)" : output
+ end
+ end
+
+ alias :to_sql :to_s
+
+ # Determines if any clauses have been added.
+ #
+ # where = Where.new
+ # where.blank?
+ # # => true
+ #
+ # where.and(nil)
+ # where.blank?
+ # # => true
+ #
+ # where.and(Where.new(nil))
+ # where.blank?
+ # # => true
+ #
+ # where.and("name=1")
+ # where.blank?
+ # # => false
+ def blank?
+ @clauses.empty?
+ end
+
+ alias :empty? :blank?
+
+protected
+ def append_clause(params, conjuction = "AND", &block) # :nodoc:
+ if block_given?
+ previous_target = @target
+ @target = Where.new(:default_params => default_params)
+ yield
+ previous_target.clauses << Clause.new(@target, conjuction)
+ @target = previous_target
+ else
+ params = params + [default_params] if params.length == 1 && params.first.is_a?(String)
+ @target.clauses << Clause.new(params, conjuction) unless params.first.blank?
+ end
+ self
+ end
+
+ # Used internally to +Where+. You shouldn't have any reason to interact with this class.
+ class Clause
+
+ def initialize(criteria, conjuction = "AND") # :nodoc:
+ @conjuction=conjuction.upcase
+ criteria = criteria.first if criteria.class==Array && criteria.length==1
+
case criteria
when Array # if it's an array, sanitize it
- @criteria = ActiveRecord::Base.send(:sanitize_sql_array, criteria)
+ @criteria = ActiveRecord::Base.send(:sanitize_sql_array, criteria)
when Hash
return nil if criteria.empty?
@criteria = criteria.keys.sort_by { |v| v.to_s }.map do |field|
ActiveRecord::Base.send(:sanitize_sql_array, ["#{field} = ?", criteria[field]])
end.join(' AND ')
- else
- @criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
- end
- end
-
- def to_s(omit_conjuction=false) # :nodoc:
- if omit_conjuction
- output = @conjuction.include?("NOT") ? "NOT " : ""
- output << "(#{@criteria})"
- else
- " #{@conjuction} (#{@criteria})"
- end
- end
- end
-end
-
-def Where(*params, &block)
- Where.new(*params, &block)
+ else
+ @criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
+ end
+ end
+
+ def to_s(omit_conjuction=false) # :nodoc:
+ if omit_conjuction
+ output = @conjuction.include?("NOT") ? "NOT " : ""
+ output << "(#{@criteria})"
+ else
+ " #{@conjuction} (#{@criteria})"
+ end
+ end
+ end
+end
+
+def Where(*params, &block)
+ Where.new(*params, &block)
end
diff --git a/spec/lib/where_spec.rb b/spec/lib/where_spec.rb
index 11cff02..a497b27 100644
--- a/spec/lib/where_spec.rb
+++ b/spec/lib/where_spec.rb
@@ -1,136 +1,143 @@
require File.join(File.dirname(__FILE__), '../spec_helper.rb')
describe Where do
describe "#new" do
it "yields the instance to the optional block, much like tap" do
Where.new { |w| w.and("hi = ?", "1") }.to_s.should == "(hi = '1')"
end
it "sets default_params, which are used when params not provided" do
where = Where.new(:default_params => {:x => 1})
where.default_params.should == {:x => 1}
where.and("x = :x")
where.to_s.should == "(x = 1)"
end
end
describe "#or" do
it "appends or conditions, parenthetically grouped by statements inside of blocks" do
where = Where.new {|w|
w.or {
w.or "x = ?", 1
w.or "x = ?", 2
}
w.or {
w.or "y = ?", 1
w.or "y = ?", 2
}
}.to_s
where.to_s.should == "((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))"
end
it "returns the where object so that it can be daisy chained" do
Where.new("x=1").or("x=2").to_sql.should == "(x=1) OR (x=2)"
end
it "can receive another Where object" do
where = Where.new
where.or Where.new("x=1")
where.to_s.should == "((x=1))"
end
+
+ it "ignores nils" do
+ where = Where.new("field1 = 1")
+ where.and(nil)
+ where.and("field2 = 2")
+ where.to_sql.should == "(field1 = 1) AND (field2 = 2)"
+ end
end
describe "#and" do
it "appends and conditions, parenthetically grouped by statements inside of blocks" do
where = Where.new {|w|
w.and {
w.or "x = ?", 1
w.or "x = ?", 2
}
w.and {
w.or "y = ?", 1
w.or "y = ?", 2
}
}.to_s
where.to_s.should == "((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))"
end
it "returns the where object so that it can be daisy chained" do
Where.new("x=1").and("x=2").to_sql.should == "(x=1) AND (x=2)"
end
it "receives a hash and converts each key/value pair as a AND criteria" do
Where.new("boogy").and({:field1 => "value1", :field2 => "value2"}).to_sql.should == "(boogy) AND (field1 = 'value1' AND field2 = 'value2')"
end
it "can receive another Where object" do
where = Where.new
where.and Where.new("x=1")
where.to_s.should == "((x=1))"
end
end
describe "#and_not" do
it "prepends NOT before the condition, even if only one condition exists" do
w = Where.new
w.and_not { w.or("x = ?", 1).or("x = ?", 2) }
w.to_s.should == "NOT ((x = 1) OR (x = 2))"
end
end
describe "#or_not" do
it "prepends NOT before the condition, even if only one condition exists" do
w = Where.new
w.and_not "x = ?", 1
w.and_not "y = ?", 1
w.to_s.should == "NOT (x = 1) AND NOT (y = 1)"
end
it "receives a block and parenthetically groups all statements within" do
w = Where.new
w.or_not { w.or("x = ?", 1).or("x = ?", 2) }
w.to_s.should == "NOT ((x = 1) OR (x = 2))"
end
it "appends the 2nd condition with an or NOT" do
w = Where.new
w.or_not "x = ?", 1
w.or_not "y = ?", 1
w.to_s.should == "NOT (x = 1) OR NOT (y = 1)"
end
end
describe "Kernel#Where" do
it "Behaves like a shortcut for Where.new" do
Where { |w| w & ["x=?", 1] }.to_s.should == "(x=1)"
end
end
it "should nest mixed AND / OR clauses properly" do
w = Where.new
w.and {
w.or "x = 1"
w.or "x = 2"
}
w.and "y = 1"
w.to_sql.should == "((x = 1) OR (x = 2)) AND (y = 1)"
end
describe "#to_s{ql}" do
it "returns a valid clause when the where clause is empty" do
Where.new.to_s.should == "(true)"
end
end
end
|
timcharper/railswhere
|
0ffc740f30d201767c6cdeae46325720909fa343
|
adds gemspec and bundler
|
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c111b33
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.gem
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..e0a7662
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1 @@
+gemspec
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644
index 0000000..5d1181c
--- /dev/null
+++ b/Gemfile.lock
@@ -0,0 +1,52 @@
+PATH
+ remote: .
+ specs:
+ railswhere (0.1)
+ activerecord (> 3.0)
+
+GEM
+ specs:
+ activemodel (3.0.7)
+ activesupport (= 3.0.7)
+ builder (~> 2.1.2)
+ i18n (~> 0.5.0)
+ activerecord (3.0.7)
+ activemodel (= 3.0.7)
+ activesupport (= 3.0.7)
+ arel (~> 2.0.2)
+ tzinfo (~> 0.3.23)
+ activesupport (3.0.7)
+ arel (2.0.9)
+ builder (2.1.2)
+ columnize (0.3.3)
+ diff-lcs (1.1.2)
+ i18n (0.5.0)
+ linecache (0.46)
+ rbx-require-relative (> 0.0.4)
+ rbx-require-relative (0.0.5)
+ rspec (2.5.0)
+ rspec-core (~> 2.5.0)
+ rspec-expectations (~> 2.5.0)
+ rspec-mocks (~> 2.5.0)
+ rspec-core (2.5.2)
+ rspec-expectations (2.5.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.5.0)
+ ruby-debug (0.10.4)
+ columnize (>= 0.1)
+ ruby-debug-base (~> 0.10.4.0)
+ ruby-debug-base (0.10.4)
+ linecache (>= 0.3)
+ sqlite3 (1.3.3)
+ sqlite3-ruby (1.3.3)
+ sqlite3 (>= 1.3.3)
+ tzinfo (0.3.27)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ railswhere!
+ rspec (= 2.5.0)
+ ruby-debug
+ sqlite3-ruby
diff --git a/MIT-LISCENSE b/MIT-LICENSE
similarity index 100%
rename from MIT-LISCENSE
rename to MIT-LICENSE
diff --git a/railswhere.gemspec b/railswhere.gemspec
new file mode 100644
index 0000000..af38ca1
--- /dev/null
+++ b/railswhere.gemspec
@@ -0,0 +1,25 @@
+# -*- encoding: utf-8 -*-
+lib = File.expand_path('../lib/', __FILE__)
+$:.unshift lib unless $:.include?(lib)
+
+Gem::Specification.new do |s|
+ s.name = "railswhere"
+ s.version = "0.1"
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["Tim Harper"]
+ s.email = ["timcharper@gmail.com"]
+ s.homepage = "http://tim.theenchanter.com/"
+ s.summary = "Easily generate SQL statements"
+ s.description = "Obligatory description when the summary suits."
+
+ s.required_rubygems_version = ">= 1.3.6"
+
+ s.add_dependency "activerecord", "> 3.0 "
+ s.add_development_dependency "sqlite3-ruby"
+ s.add_development_dependency "rspec", "2.5.0"
+ s.add_development_dependency "ruby-debug"
+
+ s.files = Dir.glob("lib/**/*") + %w(MIT-LICENSE)
+ s.executables = []
+ s.require_path = 'lib'
+end
|
timcharper/railswhere
|
0aae258870f7cd1b8eb5cc973cacea806f606d8d
|
whitespace fix
|
diff --git a/lib/where.rb b/lib/where.rb
index aa9bd53..ab9af9b 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,207 +1,207 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
# # Sweet chaining action!
class Where
attr_accessor :default_params
attr_reader :clauses, :target
# Constructs a new where clause
#
# optionally, you can provide a criteria, like the following:
#
# Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
def initialize(criteria_or_options=nil, *params, &block)
@clauses=Array.new
@target = self
if criteria_or_options.is_a?(Hash)
criteria = nil
options = criteria_or_options
else
criteria = criteria_or_options
options = {}
end
self.and(criteria, *params) unless criteria.nil?
self.default_params = options[:default_params] || {}
yield(self) if block_given?
end
def initialize_copy(from)
@clauses = from.instance_variable_get("@clauses").clone
end
# Appends an <b>and</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.and("name = ?", "Tim O'brien")
# where.to_s
#
# # => "(name = 'Tim O''brien')
def and(*params, &block)
@target.append_clause(params, "AND", &block)
end
alias << and
# Appends an <b>or</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.or("name = ?", "Tim O'brien")
# where.or("name = ?", "Tim O'neal")
# where.to_s
#
# # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
def or(*params, &block)
@target.append_clause(params, "OR", &block)
end
# Same as or, but negates the whole expression
def or_not(*params, &block)
@target.append_clause(params, "OR NOT", &block)
end
# Same as and, but negates the whole expression
def and_not(*params, &block)
@target.append_clause(params, "AND NOT", &block)
end
def &(params)
self.and(*params)
end
def |(params)
self.or(*params)
end
def self.&(params)
Where.new(*params)
end
def self.|(params)
Where.new.or(*params)
end
# Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
@clauses.each_index{|index|
omit_conjuction = (index==0)
output << @clauses[index].to_s(omit_conjuction) # Omit the clause if index=0
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
output.empty? ? "(true)" : output
end
end
alias :to_sql :to_s
# Determines if any clauses have been added.
#
# where = Where.new
# where.blank?
# # => true
#
# where.and(nil)
# where.blank?
# # => true
#
# where.and(Where.new(nil))
# where.blank?
# # => true
#
# where.and("name=1")
# where.blank?
# # => false
def blank?
@clauses.empty?
end
alias :empty? :blank?
protected
def append_clause(params, conjuction = "AND", &block) # :nodoc:
if block_given?
previous_target = @target
@target = Where.new(:default_params => default_params)
yield
previous_target.clauses << Clause.new(@target, conjuction)
@target = previous_target
else
params = params + [default_params] if params.length == 1 && params.first.is_a?(String)
@target.clauses << Clause.new(params, conjuction) unless params.first.blank?
end
self
end
# Used internally to +Where+. You shouldn't have any reason to interact with this class.
class Clause
def initialize(criteria, conjuction = "AND") # :nodoc:
@conjuction=conjuction.upcase
criteria = criteria.first if criteria.class==Array && criteria.length==1
case criteria
when Array # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql_array, criteria)
when Hash
return nil if criteria.empty?
@criteria = criteria.keys.sort_by { |v| v.to_s }.map do |field|
ActiveRecord::Base.send(:sanitize_sql_array, ["#{field} = ?", criteria[field]])
end.join(' AND ')
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_conjuction=false) # :nodoc:
if omit_conjuction
output = @conjuction.include?("NOT") ? "NOT " : ""
output << "(#{@criteria})"
else
" #{@conjuction} (#{@criteria})"
end
end
end
end
def Where(*params, &block)
Where.new(*params, &block)
-end
\ No newline at end of file
+end
diff --git a/spec/lib/where_spec.rb b/spec/lib/where_spec.rb
index e1cf558..11cff02 100644
--- a/spec/lib/where_spec.rb
+++ b/spec/lib/where_spec.rb
@@ -1,136 +1,136 @@
require File.join(File.dirname(__FILE__), '../spec_helper.rb')
describe Where do
describe "#new" do
it "yields the instance to the optional block, much like tap" do
Where.new { |w| w.and("hi = ?", "1") }.to_s.should == "(hi = '1')"
end
it "sets default_params, which are used when params not provided" do
where = Where.new(:default_params => {:x => 1})
where.default_params.should == {:x => 1}
where.and("x = :x")
where.to_s.should == "(x = 1)"
end
end
describe "#or" do
it "appends or conditions, parenthetically grouped by statements inside of blocks" do
where = Where.new {|w|
w.or {
w.or "x = ?", 1
w.or "x = ?", 2
}
w.or {
w.or "y = ?", 1
w.or "y = ?", 2
}
}.to_s
where.to_s.should == "((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))"
end
it "returns the where object so that it can be daisy chained" do
Where.new("x=1").or("x=2").to_sql.should == "(x=1) OR (x=2)"
end
it "can receive another Where object" do
where = Where.new
where.or Where.new("x=1")
where.to_s.should == "((x=1))"
end
end
describe "#and" do
it "appends and conditions, parenthetically grouped by statements inside of blocks" do
where = Where.new {|w|
w.and {
w.or "x = ?", 1
w.or "x = ?", 2
}
w.and {
w.or "y = ?", 1
w.or "y = ?", 2
}
}.to_s
where.to_s.should == "((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))"
end
it "returns the where object so that it can be daisy chained" do
Where.new("x=1").and("x=2").to_sql.should == "(x=1) AND (x=2)"
end
it "receives a hash and converts each key/value pair as a AND criteria" do
Where.new("boogy").and({:field1 => "value1", :field2 => "value2"}).to_sql.should == "(boogy) AND (field1 = 'value1' AND field2 = 'value2')"
end
it "can receive another Where object" do
where = Where.new
where.and Where.new("x=1")
where.to_s.should == "((x=1))"
end
end
describe "#and_not" do
it "prepends NOT before the condition, even if only one condition exists" do
w = Where.new
w.and_not { w.or("x = ?", 1).or("x = ?", 2) }
w.to_s.should == "NOT ((x = 1) OR (x = 2))"
end
end
describe "#or_not" do
it "prepends NOT before the condition, even if only one condition exists" do
w = Where.new
w.and_not "x = ?", 1
w.and_not "y = ?", 1
w.to_s.should == "NOT (x = 1) AND NOT (y = 1)"
end
it "receives a block and parenthetically groups all statements within" do
w = Where.new
w.or_not { w.or("x = ?", 1).or("x = ?", 2) }
w.to_s.should == "NOT ((x = 1) OR (x = 2))"
end
it "appends the 2nd condition with an or NOT" do
w = Where.new
w.or_not "x = ?", 1
w.or_not "y = ?", 1
w.to_s.should == "NOT (x = 1) OR NOT (y = 1)"
end
end
describe "Kernel#Where" do
it "Behaves like a shortcut for Where.new" do
Where { |w| w & ["x=?", 1] }.to_s.should == "(x=1)"
end
end
it "should nest mixed AND / OR clauses properly" do
w = Where.new
w.and {
w.or "x = 1"
w.or "x = 2"
}
w.and "y = 1"
w.to_sql.should == "((x = 1) OR (x = 2)) AND (y = 1)"
end
describe "#to_s{ql}" do
it "returns a valid clause when the where clause is empty" do
Where.new.to_s.should == "(true)"
end
end
-end
\ No newline at end of file
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 397f640..a8ce412 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,18 +1,18 @@
require "rubygems"
require 'active_record'
require 'rspec'
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => File.join(File.dirname(__FILE__), "db/test.db")
)
for file in ["../lib/where.rb", "../lib/search_builder.rb"]
require File.expand_path(File.join(File.dirname(__FILE__), file))
end
class Object
def to_regexp
is_a?(Regexp) ? self : Regexp.new(Regexp.escape(self.to_s))
end
-end
\ No newline at end of file
+end
|
timcharper/railswhere
|
0ea45da35bf3d9830ceedb3b660ed3118106cf69
|
upgrade to rspec 2.5
|
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index bfd6bf0..397f640 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,18 +1,18 @@
require "rubygems"
require 'active_record'
-require 'spec'
+require 'rspec'
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => File.join(File.dirname(__FILE__), "db/test.db")
)
for file in ["../lib/where.rb", "../lib/search_builder.rb"]
require File.expand_path(File.join(File.dirname(__FILE__), file))
end
class Object
def to_regexp
is_a?(Regexp) ? self : Regexp.new(Regexp.escape(self.to_s))
end
end
\ No newline at end of file
|
timcharper/railswhere
|
798c46d6416baaf053a8f9c9effe759777051a36
|
Reorganized specs. Adds Where.and({field => value}) syntax.
|
diff --git a/lib/where.rb b/lib/where.rb
index 2349757..aa9bd53 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,201 +1,207 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
# # Sweet chaining action!
class Where
attr_accessor :default_params
attr_reader :clauses, :target
# Constructs a new where clause
#
# optionally, you can provide a criteria, like the following:
#
# Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
def initialize(criteria_or_options=nil, *params, &block)
@clauses=Array.new
@target = self
if criteria_or_options.is_a?(Hash)
criteria = nil
options = criteria_or_options
else
criteria = criteria_or_options
options = {}
end
self.and(criteria, *params) unless criteria.nil?
self.default_params = options[:default_params] || {}
yield(self) if block_given?
end
def initialize_copy(from)
@clauses = from.instance_variable_get("@clauses").clone
end
# Appends an <b>and</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.and("name = ?", "Tim O'brien")
# where.to_s
#
# # => "(name = 'Tim O''brien')
def and(*params, &block)
@target.append_clause(params, "AND", &block)
end
alias << and
# Appends an <b>or</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.or("name = ?", "Tim O'brien")
# where.or("name = ?", "Tim O'neal")
# where.to_s
#
# # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
def or(*params, &block)
@target.append_clause(params, "OR", &block)
end
# Same as or, but negates the whole expression
def or_not(*params, &block)
@target.append_clause(params, "OR NOT", &block)
end
# Same as and, but negates the whole expression
def and_not(*params, &block)
@target.append_clause(params, "AND NOT", &block)
end
def &(params)
self.and(*params)
end
def |(params)
self.or(*params)
end
def self.&(params)
Where.new(*params)
end
def self.|(params)
Where.new.or(*params)
end
# Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
@clauses.each_index{|index|
omit_conjuction = (index==0)
output << @clauses[index].to_s(omit_conjuction) # Omit the clause if index=0
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
output.empty? ? "(true)" : output
end
end
alias :to_sql :to_s
# Determines if any clauses have been added.
#
# where = Where.new
# where.blank?
# # => true
#
# where.and(nil)
# where.blank?
# # => true
#
# where.and(Where.new(nil))
# where.blank?
# # => true
#
# where.and("name=1")
# where.blank?
# # => false
def blank?
@clauses.empty?
end
alias :empty? :blank?
protected
def append_clause(params, conjuction = "AND", &block) # :nodoc:
if block_given?
previous_target = @target
@target = Where.new(:default_params => default_params)
yield
previous_target.clauses << Clause.new(@target, conjuction)
@target = previous_target
else
params = params + [default_params] if params.length == 1 && params.first.is_a?(String)
@target.clauses << Clause.new(params, conjuction) unless params.first.blank?
end
self
end
# Used internally to +Where+. You shouldn't have any reason to interact with this class.
class Clause
def initialize(criteria, conjuction = "AND") # :nodoc:
@conjuction=conjuction.upcase
criteria = criteria.first if criteria.class==Array && criteria.length==1
- if criteria.class==Array # if it's an array, sanitize it
+ case criteria
+ when Array # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql_array, criteria)
+ when Hash
+ return nil if criteria.empty?
+ @criteria = criteria.keys.sort_by { |v| v.to_s }.map do |field|
+ ActiveRecord::Base.send(:sanitize_sql_array, ["#{field} = ?", criteria[field]])
+ end.join(' AND ')
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_conjuction=false) # :nodoc:
if omit_conjuction
output = @conjuction.include?("NOT") ? "NOT " : ""
output << "(#{@criteria})"
else
" #{@conjuction} (#{@criteria})"
end
end
end
end
def Where(*params, &block)
Where.new(*params, &block)
end
\ No newline at end of file
diff --git a/spec/lib/where_spec.rb b/spec/lib/where_spec.rb
index 921b55e..e1cf558 100644
--- a/spec/lib/where_spec.rb
+++ b/spec/lib/where_spec.rb
@@ -1,121 +1,136 @@
require File.join(File.dirname(__FILE__), '../spec_helper.rb')
describe Where do
- it "where_new__block__should_yield" do
- Where.new {|w| w.and("hi = ?", "1")}.to_s.should == "(hi = '1')"
- end
-
- it "where_or_block__should_work" do
- where = Where.new {|w|
- w.or {
- w.or "x = ?", 1
- w.or "x = ?", 2
- }
-
- w.or {
- w.or "y = ?", 1
- w.or "y = ?", 2
- }
- }.to_s
-
- where.to_s.should == "((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))"
- end
-
- it "where_and_block__should_work" do
- where = Where.new {|w|
- w.and {
- w.or "x = ?", 1
- w.or "x = ?", 2
- }
-
- w.and {
- w.or "y = ?", 1
- w.or "y = ?", 2
- }
- }.to_s
+ describe "#new" do
+ it "yields the instance to the optional block, much like tap" do
+ Where.new { |w| w.and("hi = ?", "1") }.to_s.should == "(hi = '1')"
+ end
- where.to_s.should == "((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))"
+ it "sets default_params, which are used when params not provided" do
+ where = Where.new(:default_params => {:x => 1})
+ where.default_params.should == {:x => 1}
+ where.and("x = :x")
+ where.to_s.should == "(x = 1)"
+ end
end
-
- it "where__and_not__no_perfix__should_work" do
- w = Where.new
+
+ describe "#or" do
+ it "appends or conditions, parenthetically grouped by statements inside of blocks" do
+ where = Where.new {|w|
+ w.or {
+ w.or "x = ?", 1
+ w.or "x = ?", 2
+ }
+
+ w.or {
+ w.or "y = ?", 1
+ w.or "y = ?", 2
+ }
+ }.to_s
+
+ where.to_s.should == "((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))"
+ end
- w.and_not { w.or("x = ?", 1).or("x = ?", 2) }
+ it "returns the where object so that it can be daisy chained" do
+ Where.new("x=1").or("x=2").to_sql.should == "(x=1) OR (x=2)"
+ end
- w.to_s.should == "NOT ((x = 1) OR (x = 2))"
+ it "can receive another Where object" do
+ where = Where.new
+ where.or Where.new("x=1")
+ where.to_s.should == "((x=1))"
+ end
end
-
- it "where__and_not__with_prefix__should_work" do
- w = Where.new
+ describe "#and" do
+ it "appends and conditions, parenthetically grouped by statements inside of blocks" do
+ where = Where.new {|w|
+ w.and {
+ w.or "x = ?", 1
+ w.or "x = ?", 2
+ }
+
+ w.and {
+ w.or "y = ?", 1
+ w.or "y = ?", 2
+ }
+ }.to_s
+
+ where.to_s.should == "((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))"
+ end
- w.and_not "x = ?", 1
- w.and_not "y = ?", 1
+ it "returns the where object so that it can be daisy chained" do
+ Where.new("x=1").and("x=2").to_sql.should == "(x=1) AND (x=2)"
+ end
+
+ it "receives a hash and converts each key/value pair as a AND criteria" do
+ Where.new("boogy").and({:field1 => "value1", :field2 => "value2"}).to_sql.should == "(boogy) AND (field1 = 'value1' AND field2 = 'value2')"
+ end
- w.to_s.should == "NOT (x = 1) AND NOT (y = 1)"
+ it "can receive another Where object" do
+ where = Where.new
+ where.and Where.new("x=1")
+ where.to_s.should == "((x=1))"
+ end
end
-
- it "where__or_not__no_perfix__should_work" do
- w = Where.new
-
- w.or_not{ w.or("x = ?", 1).or("x = ?", 2) }
-
- w.to_s.should == "NOT ((x = 1) OR (x = 2))"
+
+ describe "#and_not" do
+ it "prepends NOT before the condition, even if only one condition exists" do
+ w = Where.new
+
+ w.and_not { w.or("x = ?", 1).or("x = ?", 2) }
+
+ w.to_s.should == "NOT ((x = 1) OR (x = 2))"
+ end
end
-
- it "where__or_not__with_prefix__should_work" do
- w = Where.new
+ describe "#or_not" do
+ it "prepends NOT before the condition, even if only one condition exists" do
+ w = Where.new
+
+ w.and_not "x = ?", 1
+ w.and_not "y = ?", 1
+
+ w.to_s.should == "NOT (x = 1) AND NOT (y = 1)"
+ end
- w.or_not "x = ?", 1
- w.or_not "y = ?", 1
+ it "receives a block and parenthetically groups all statements within" do
+ w = Where.new
+
+ w.or_not { w.or("x = ?", 1).or("x = ?", 2) }
+
+ w.to_s.should == "NOT ((x = 1) OR (x = 2))"
+ end
- w.to_s.should == "NOT (x = 1) OR NOT (y = 1)"
- end
-
-
- it "where_new_chained_or" do
- Where.new("x=1").or("x=2").to_sql.should == "(x=1) OR (x=2)"
- end
-
- it "where_new_chained_and" do
- Where.new("x=1").and("x=2").to_sql.should == "(x=1) AND (x=2)"
- end
-
- it "where_and_where" do
- where = Where.new
- where.and Where.new("x=1")
- where.to_s.should == "((x=1))"
- end
-
- it "where_or_where" do
- where = Where.new
- where.or Where.new("x=1")
- where.to_s.should == "((x=1))"
+ it "appends the 2nd condition with an or NOT" do
+ w = Where.new
+
+ w.or_not "x = ?", 1
+ w.or_not "y = ?", 1
+
+ w.to_s.should == "NOT (x = 1) OR NOT (y = 1)"
+ end
end
- it "where_method_invocation" do
- Where{|w| w & ["x=?", 1] }.to_s.should == "(x=1)"
+ describe "Kernel#Where" do
+ it "Behaves like a shortcut for Where.new" do
+ Where { |w| w & ["x=?", 1] }.to_s.should == "(x=1)"
+ end
end
- it "should nest clauses" do
+ it "should nest mixed AND / OR clauses properly" do
w = Where.new
w.and {
w.or "x = 1"
w.or "x = 2"
}
w.and "y = 1"
w.to_sql.should == "((x = 1) OR (x = 2)) AND (y = 1)"
end
-
- it "should use default params when rendering sql" do
- where = Where.new(:default_params => {:x => 1})
- where.default_params.should == {:x => 1}
- where.and("x = :x")
- where.to_s.should == "(x = 1)"
- end
-
- it "should return a valid clause when the where clause is empty" do
- Where.new.to_s.should == "(true)"
+
+ describe "#to_s{ql}" do
+ it "returns a valid clause when the where clause is empty" do
+ Where.new.to_s.should == "(true)"
+ end
end
end
\ No newline at end of file
|
timcharper/railswhere
|
52475e921a516150329222dc9dbd94855c61c01c
|
:sanitize_sql_array is the new :sanitize_sql
|
diff --git a/lib/where.rb b/lib/where.rb
index a4241f5..2349757 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,201 +1,201 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
# # Sweet chaining action!
class Where
attr_accessor :default_params
attr_reader :clauses, :target
# Constructs a new where clause
#
# optionally, you can provide a criteria, like the following:
#
# Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
def initialize(criteria_or_options=nil, *params, &block)
@clauses=Array.new
@target = self
if criteria_or_options.is_a?(Hash)
criteria = nil
options = criteria_or_options
else
criteria = criteria_or_options
options = {}
end
self.and(criteria, *params) unless criteria.nil?
self.default_params = options[:default_params] || {}
yield(self) if block_given?
end
def initialize_copy(from)
@clauses = from.instance_variable_get("@clauses").clone
end
# Appends an <b>and</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.and("name = ?", "Tim O'brien")
# where.to_s
#
# # => "(name = 'Tim O''brien')
def and(*params, &block)
@target.append_clause(params, "AND", &block)
end
alias << and
# Appends an <b>or</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.or("name = ?", "Tim O'brien")
# where.or("name = ?", "Tim O'neal")
# where.to_s
#
# # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
def or(*params, &block)
@target.append_clause(params, "OR", &block)
end
# Same as or, but negates the whole expression
def or_not(*params, &block)
@target.append_clause(params, "OR NOT", &block)
end
# Same as and, but negates the whole expression
def and_not(*params, &block)
@target.append_clause(params, "AND NOT", &block)
end
def &(params)
self.and(*params)
end
def |(params)
self.or(*params)
end
def self.&(params)
Where.new(*params)
end
def self.|(params)
Where.new.or(*params)
end
# Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
@clauses.each_index{|index|
omit_conjuction = (index==0)
output << @clauses[index].to_s(omit_conjuction) # Omit the clause if index=0
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
output.empty? ? "(true)" : output
end
end
alias :to_sql :to_s
# Determines if any clauses have been added.
#
# where = Where.new
# where.blank?
# # => true
#
# where.and(nil)
# where.blank?
# # => true
#
# where.and(Where.new(nil))
# where.blank?
# # => true
#
# where.and("name=1")
# where.blank?
# # => false
def blank?
@clauses.empty?
end
alias :empty? :blank?
protected
def append_clause(params, conjuction = "AND", &block) # :nodoc:
if block_given?
previous_target = @target
@target = Where.new(:default_params => default_params)
yield
previous_target.clauses << Clause.new(@target, conjuction)
@target = previous_target
else
params = params + [default_params] if params.length == 1 && params.first.is_a?(String)
@target.clauses << Clause.new(params, conjuction) unless params.first.blank?
end
self
end
# Used internally to +Where+. You shouldn't have any reason to interact with this class.
class Clause
def initialize(criteria, conjuction = "AND") # :nodoc:
@conjuction=conjuction.upcase
criteria = criteria.first if criteria.class==Array && criteria.length==1
if criteria.class==Array # if it's an array, sanitize it
- @criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
+ @criteria = ActiveRecord::Base.send(:sanitize_sql_array, criteria)
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_conjuction=false) # :nodoc:
if omit_conjuction
output = @conjuction.include?("NOT") ? "NOT " : ""
output << "(#{@criteria})"
else
" #{@conjuction} (#{@criteria})"
end
end
end
end
def Where(*params, &block)
Where.new(*params, &block)
end
\ No newline at end of file
|
timcharper/railswhere
|
ad9dac43ac7ace4869e526c504eee9043745768d
|
default sql is (true)
|
diff --git a/spec/lib/search_builder_spec.rb b/spec/lib/search_builder_spec.rb
index 20eb195..8e7eaaa 100644
--- a/spec/lib/search_builder_spec.rb
+++ b/spec/lib/search_builder_spec.rb
@@ -1,75 +1,75 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe "SearchBuilder" do
before(:each) do
@object = OpenStruct.new
@sb = SearchBuilder.new(@object)
end
it "search_builder_date_range" do
@object.created_at_min = "Jan 2 2007 5:30"
@object.created_at_max = "Jan 5 2007 5:30"
@sb.range_on("proposals.created_at", :cast => :date)
@sb.to_sql.should == "(proposals.created_at >= '2007-01-02') AND (proposals.created_at <= '2007-01-05')"
end
it "search_builder_date_range__nil_values__shouldnt_append_anything" do
@sb.range_on("users.created_at", :cast => :date)
- @sb.to_sql.should be_nil
+ @sb.to_sql.should == "(true)"
end
it "like_search" do
@object.first_name = "Tim"
@sb.like_on("users.first_name")
@sb.to_sql.should == "(users.first_name like 'Tim%')"
end
it "equal_search" do
@object.first_name = "Tim"
@sb.equal_on("users.first_name")
@sb.to_sql.should == "(users.first_name = 'Tim')"
end
it "in_search" do
@object.value = [1,2,3,4]
@sb.in_on "attributes.value"
@sb.to_sql.should == "(attributes.value in (1,2,3,4))"
end
it "dot_in_field__should_be_smart_and_figure_it_out" do
@object.first_name = "Tim"
@sb.equal_on("users.first_name")
@sb.to_sql.should == "(users.first_name = 'Tim')"
end
it "for_table__should_prepend" do
@object.first_name = "Tim"
@sb.for_table "users" do
@sb.equal_on("first_name")
end
@sb.to_sql.should == "(users.first_name = 'Tim')"
end
it "for_table_no_block__should_prepend" do
@object.first_name = "Tim"
@sb.for_table "users"
@sb.equal_on("first_name")
@sb.to_sql.should == "(users.first_name = 'Tim')"
end
it "use_symbol__should_process_ok__should_append" do
@object.first_name = "Tim"
@sb.equal_on(:first_name)
@sb.to_sql.should == "(first_name = 'Tim')"
end
end
|
timcharper/railswhere
|
61b25d8090534e517c8d9b8ab50345c77cc9541d
|
Where.new.to_s returned nil - not very desirable. Now it returns "(true)"
|
diff --git a/lib/where.rb b/lib/where.rb
index 16d5beb..a4241f5 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,201 +1,201 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
# # Sweet chaining action!
class Where
attr_accessor :default_params
attr_reader :clauses, :target
# Constructs a new where clause
#
# optionally, you can provide a criteria, like the following:
#
# Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
def initialize(criteria_or_options=nil, *params, &block)
@clauses=Array.new
@target = self
if criteria_or_options.is_a?(Hash)
criteria = nil
options = criteria_or_options
else
criteria = criteria_or_options
options = {}
end
self.and(criteria, *params) unless criteria.nil?
self.default_params = options[:default_params] || {}
yield(self) if block_given?
end
def initialize_copy(from)
@clauses = from.instance_variable_get("@clauses").clone
end
# Appends an <b>and</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.and("name = ?", "Tim O'brien")
# where.to_s
#
# # => "(name = 'Tim O''brien')
def and(*params, &block)
@target.append_clause(params, "AND", &block)
end
alias << and
# Appends an <b>or</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.or("name = ?", "Tim O'brien")
# where.or("name = ?", "Tim O'neal")
# where.to_s
#
# # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
def or(*params, &block)
@target.append_clause(params, "OR", &block)
end
# Same as or, but negates the whole expression
def or_not(*params, &block)
@target.append_clause(params, "OR NOT", &block)
end
# Same as and, but negates the whole expression
def and_not(*params, &block)
@target.append_clause(params, "AND NOT", &block)
end
def &(params)
self.and(*params)
end
def |(params)
self.or(*params)
end
def self.&(params)
Where.new(*params)
end
def self.|(params)
Where.new.or(*params)
end
# Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
@clauses.each_index{|index|
omit_conjuction = (index==0)
output << @clauses[index].to_s(omit_conjuction) # Omit the clause if index=0
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
- output.empty? ? nil : output
+ output.empty? ? "(true)" : output
end
end
alias :to_sql :to_s
# Determines if any clauses have been added.
#
# where = Where.new
# where.blank?
# # => true
#
# where.and(nil)
# where.blank?
# # => true
#
# where.and(Where.new(nil))
# where.blank?
# # => true
#
# where.and("name=1")
# where.blank?
# # => false
def blank?
@clauses.empty?
end
alias :empty? :blank?
protected
def append_clause(params, conjuction = "AND", &block) # :nodoc:
if block_given?
previous_target = @target
@target = Where.new(:default_params => default_params)
yield
previous_target.clauses << Clause.new(@target, conjuction)
@target = previous_target
else
params = params + [default_params] if params.length == 1 && params.first.is_a?(String)
@target.clauses << Clause.new(params, conjuction) unless params.first.blank?
end
self
end
# Used internally to +Where+. You shouldn't have any reason to interact with this class.
class Clause
def initialize(criteria, conjuction = "AND") # :nodoc:
@conjuction=conjuction.upcase
criteria = criteria.first if criteria.class==Array && criteria.length==1
if criteria.class==Array # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_conjuction=false) # :nodoc:
if omit_conjuction
output = @conjuction.include?("NOT") ? "NOT " : ""
output << "(#{@criteria})"
else
" #{@conjuction} (#{@criteria})"
end
end
end
end
def Where(*params, &block)
Where.new(*params, &block)
end
\ No newline at end of file
diff --git a/spec/lib/where_spec.rb b/spec/lib/where_spec.rb
index c42c502..921b55e 100644
--- a/spec/lib/where_spec.rb
+++ b/spec/lib/where_spec.rb
@@ -1,118 +1,121 @@
require File.join(File.dirname(__FILE__), '../spec_helper.rb')
describe Where do
it "where_new__block__should_yield" do
Where.new {|w| w.and("hi = ?", "1")}.to_s.should == "(hi = '1')"
end
it "where_or_block__should_work" do
where = Where.new {|w|
w.or {
w.or "x = ?", 1
w.or "x = ?", 2
}
w.or {
w.or "y = ?", 1
w.or "y = ?", 2
}
}.to_s
where.to_s.should == "((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))"
end
it "where_and_block__should_work" do
where = Where.new {|w|
w.and {
w.or "x = ?", 1
w.or "x = ?", 2
}
w.and {
w.or "y = ?", 1
w.or "y = ?", 2
}
}.to_s
where.to_s.should == "((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))"
end
it "where__and_not__no_perfix__should_work" do
w = Where.new
w.and_not { w.or("x = ?", 1).or("x = ?", 2) }
w.to_s.should == "NOT ((x = 1) OR (x = 2))"
end
it "where__and_not__with_prefix__should_work" do
w = Where.new
w.and_not "x = ?", 1
w.and_not "y = ?", 1
w.to_s.should == "NOT (x = 1) AND NOT (y = 1)"
end
it "where__or_not__no_perfix__should_work" do
w = Where.new
w.or_not{ w.or("x = ?", 1).or("x = ?", 2) }
w.to_s.should == "NOT ((x = 1) OR (x = 2))"
end
it "where__or_not__with_prefix__should_work" do
w = Where.new
w.or_not "x = ?", 1
w.or_not "y = ?", 1
w.to_s.should == "NOT (x = 1) OR NOT (y = 1)"
end
it "where_new_chained_or" do
Where.new("x=1").or("x=2").to_sql.should == "(x=1) OR (x=2)"
end
it "where_new_chained_and" do
Where.new("x=1").and("x=2").to_sql.should == "(x=1) AND (x=2)"
end
it "where_and_where" do
where = Where.new
where.and Where.new("x=1")
where.to_s.should == "((x=1))"
end
it "where_or_where" do
where = Where.new
where.or Where.new("x=1")
where.to_s.should == "((x=1))"
end
it "where_method_invocation" do
Where{|w| w & ["x=?", 1] }.to_s.should == "(x=1)"
end
it "should nest clauses" do
w = Where.new
w.and {
w.or "x = 1"
w.or "x = 2"
}
w.and "y = 1"
w.to_sql.should == "((x = 1) OR (x = 2)) AND (y = 1)"
end
it "should use default params when rendering sql" do
where = Where.new(:default_params => {:x => 1})
where.default_params.should == {:x => 1}
where.and("x = :x")
where.to_s.should == "(x = 1)"
end
+ it "should return a valid clause when the where clause is empty" do
+ Where.new.to_s.should == "(true)"
+ end
end
\ No newline at end of file
|
timcharper/railswhere
|
db01d91c2039ca271c7df9bcc4cacf7e949d74c2
|
added changelog
|
diff --git a/CHANGELOG b/CHANGELOG
new file mode 100644
index 0000000..13148fe
--- /dev/null
+++ b/CHANGELOG
@@ -0,0 +1,8 @@
+Version 1.2 [Oct 30 2007]
+ - and_not, or_not support
+
+Version 1.1 - [Oct 3 2007]
+ - block support.
+
+Version 1.0 - [Jul 1 2007]
+ - Initial release
\ No newline at end of file
|
timcharper/railswhere
|
b9276ab1ad9aee7c3688b365072fe0a616b68b71
|
block notation no longer uses a parameter. ability to set input hash of elements. converted tests to specs
|
diff --git a/lib/search_builder.rb b/lib/search_builder.rb
index beb7ba6..11c0067 100644
--- a/lib/search_builder.rb
+++ b/lib/search_builder.rb
@@ -1,135 +1,134 @@
require 'ostruct'
class SearchBuilder
attr_reader :object
attr_accessor :where
def object=(value)
value=OpenStruct.new(value) if Hash===value
@object = value
end
def initialize(target_object, options={})
self.object = target_object.is_a?(Hash) ? OpenStruct.new(target_object) : target_object
self.where = options[:append_to] || Where.new
@table_prefix = ""
end
def self.delegate_to(object_name, methods = [])
for method_name in methods
class_eval <<-EOF, __FILE__, __LINE__ +1
def #{method_name}(*params, &block)
#{object_name} && #{object_name}.#{method_name}(*params, &block)
end
EOF
end
end
delegate_to "@where", %w[and or to_sql to_s empty?]
def range_on(field, options={})
options = options.clone
min_param = options[:min_param] || "#{options[:param] || field}_min"
max_param = options[:max_param] || "#{options[:param] || field}_max"
cast = options[:cast] || :string
process_clause(field, ">= ?", options.merge(:param => min_param))
process_clause(field, "<= ?", options.merge(:param => max_param))
self
end
def like_on(field, options={})
options = options.clone
options[:suffix] ||= "%"
process_clause(field, "like ?", options)
end
def for_table(table, &block)
if block_given?
last_table_prefix = @table_prefix
end
@table_prefix = "#{table}."
if block_given?
yield
@table_prefix = last_table_prefix
end
end
def equal_on(field, options={})
options = options.clone
options[:cast] = :string
process_clause(field, "= ?", options)
end
def in_on(field, options={})
options = options.clone
options[:cast] ||= :array
process_clause(field, "in (?)", options)
end
def process_clause(field, operator_clause, options={})
param = options[:param] || field
self.and_unless_blank("#{@table_prefix}#{field} #{operator_clause}", value_for(param, options[:cast]), options)
self
end
def and_unless_blank(condition, value, options={})
value = value.compact if (Array === value)
# if value is an empty array or a blank string, don't filter on it
return self if value.blank?
prefix = options[:prefix]
suffix = options[:suffix]
if prefix || suffix
@where.and(condition, [prefix, value, suffix].compact.to_s )
else
@where.and(condition, value)
end
self
end
def value_for(param, cast=:string)
param = param.to_s
if param.include?(".")
param=param.split(".").last
end
cast_to( object.send(param), cast)
end
def cast_to(value, type)
self.class.cast_to(value, type)
end
def self.cast_to(value, type)
- return nil if value.blank?
+ return value if value.nil?
case type
when nil
value
when :array
value = Array===value ? value : [value]
- value.reject{|v| v.blank?}
when :time
Time.parse(value)
when :date
Time.parse(value).to_date
when :i, :int, :integer
value.to_i
when :f, :float
value.to_f
when :string
value.to_s
else
raise "unknown cast type: #{type}"
end
end
end
\ No newline at end of file
diff --git a/lib/where.rb b/lib/where.rb
index cc8c077..16d5beb 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,189 +1,201 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
# # Sweet chaining action!
class Where
-
+ attr_accessor :default_params
+ attr_reader :clauses, :target
# Constructs a new where clause
#
# optionally, you can provide a criteria, like the following:
#
# Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
- def initialize(criteria=nil, *params, &block)
+ def initialize(criteria_or_options=nil, *params, &block)
@clauses=Array.new
-
+ @target = self
+ if criteria_or_options.is_a?(Hash)
+ criteria = nil
+ options = criteria_or_options
+ else
+ criteria = criteria_or_options
+ options = {}
+ end
self.and(criteria, *params) unless criteria.nil?
+ self.default_params = options[:default_params] || {}
yield(self) if block_given?
end
def initialize_copy(from)
@clauses = from.instance_variable_get("@clauses").clone
end
# Appends an <b>and</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.and("name = ?", "Tim O'brien")
# where.to_s
#
# # => "(name = 'Tim O''brien')
def and(*params, &block)
- append_clause(params, "AND", &block)
+ @target.append_clause(params, "AND", &block)
end
alias << and
# Appends an <b>or</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.or("name = ?", "Tim O'brien")
# where.or("name = ?", "Tim O'neal")
# where.to_s
#
# # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
def or(*params, &block)
- append_clause(params, "OR", &block)
+ @target.append_clause(params, "OR", &block)
end
# Same as or, but negates the whole expression
def or_not(*params, &block)
- append_clause(params, "OR NOT", &block)
+ @target.append_clause(params, "OR NOT", &block)
end
# Same as and, but negates the whole expression
def and_not(*params, &block)
- append_clause(params, "AND NOT", &block)
+ @target.append_clause(params, "AND NOT", &block)
end
def &(params)
self.and(*params)
end
def |(params)
self.or(*params)
end
def self.&(params)
Where.new(*params)
end
def self.|(params)
Where.new.or(*params)
end
# Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
- @clauses.each_with_index{|clause, index|
- clause_output = clause.to_s(index==0) # Omit the clause if index==0
- output << clause_output unless clause_output.blank?
+ @clauses.each_index{|index|
+ omit_conjuction = (index==0)
+ output << @clauses[index].to_s(omit_conjuction) # Omit the clause if index=0
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
- output.empty? ? "" : output
+ output.empty? ? nil : output
end
end
alias :to_sql :to_s
# Determines if any clauses have been added.
#
# where = Where.new
# where.blank?
# # => true
#
# where.and(nil)
# where.blank?
# # => true
#
# where.and(Where.new(nil))
# where.blank?
# # => true
#
# where.and("name=1")
# where.blank?
# # => false
def blank?
@clauses.empty?
end
alias :empty? :blank?
protected
def append_clause(params, conjuction = "AND", &block) # :nodoc:
if block_given?
- yield(w = Where.new)
- @clauses << Clause.new(w, conjuction)
+ previous_target = @target
+ @target = Where.new(:default_params => default_params)
+ yield
+ previous_target.clauses << Clause.new(@target, conjuction)
+ @target = previous_target
else
- @clauses << Clause.new(params, conjuction) unless params.first.blank?
+ params = params + [default_params] if params.length == 1 && params.first.is_a?(String)
+ @target.clauses << Clause.new(params, conjuction) unless params.first.blank?
end
self
end
# Used internally to +Where+. You shouldn't have any reason to interact with this class.
class Clause
def initialize(criteria, conjuction = "AND") # :nodoc:
@conjuction=conjuction.upcase
criteria = criteria.first if criteria.class==Array && criteria.length==1
if criteria.class==Array # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_conjuction=false) # :nodoc:
- return "" if @criteria.blank?
if omit_conjuction
output = @conjuction.include?("NOT") ? "NOT " : ""
output << "(#{@criteria})"
else
" #{@conjuction} (#{@criteria})"
end
end
end
end
def Where(*params, &block)
Where.new(*params, &block)
end
\ No newline at end of file
diff --git a/test/db/test.db b/spec/db/test.db
similarity index 100%
rename from test/db/test.db
rename to spec/db/test.db
diff --git a/spec/lib/search_builder_spec.rb b/spec/lib/search_builder_spec.rb
new file mode 100644
index 0000000..20eb195
--- /dev/null
+++ b/spec/lib/search_builder_spec.rb
@@ -0,0 +1,75 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+
+describe "SearchBuilder" do
+ before(:each) do
+ @object = OpenStruct.new
+ @sb = SearchBuilder.new(@object)
+ end
+
+ it "search_builder_date_range" do
+ @object.created_at_min = "Jan 2 2007 5:30"
+ @object.created_at_max = "Jan 5 2007 5:30"
+ @sb.range_on("proposals.created_at", :cast => :date)
+
+ @sb.to_sql.should == "(proposals.created_at >= '2007-01-02') AND (proposals.created_at <= '2007-01-05')"
+ end
+
+ it "search_builder_date_range__nil_values__shouldnt_append_anything" do
+ @sb.range_on("users.created_at", :cast => :date)
+
+ @sb.to_sql.should be_nil
+ end
+
+ it "like_search" do
+ @object.first_name = "Tim"
+ @sb.like_on("users.first_name")
+
+ @sb.to_sql.should == "(users.first_name like 'Tim%')"
+ end
+
+ it "equal_search" do
+ @object.first_name = "Tim"
+ @sb.equal_on("users.first_name")
+
+ @sb.to_sql.should == "(users.first_name = 'Tim')"
+ end
+
+ it "in_search" do
+ @object.value = [1,2,3,4]
+ @sb.in_on "attributes.value"
+ @sb.to_sql.should == "(attributes.value in (1,2,3,4))"
+ end
+
+ it "dot_in_field__should_be_smart_and_figure_it_out" do
+ @object.first_name = "Tim"
+ @sb.equal_on("users.first_name")
+ @sb.to_sql.should == "(users.first_name = 'Tim')"
+ end
+
+ it "for_table__should_prepend" do
+ @object.first_name = "Tim"
+ @sb.for_table "users" do
+ @sb.equal_on("first_name")
+ end
+
+ @sb.to_sql.should == "(users.first_name = 'Tim')"
+ end
+
+ it "for_table_no_block__should_prepend" do
+ @object.first_name = "Tim"
+ @sb.for_table "users"
+ @sb.equal_on("first_name")
+
+ @sb.to_sql.should == "(users.first_name = 'Tim')"
+ end
+
+ it "use_symbol__should_process_ok__should_append" do
+ @object.first_name = "Tim"
+ @sb.equal_on(:first_name)
+
+ @sb.to_sql.should == "(first_name = 'Tim')"
+
+ end
+
+
+end
diff --git a/spec/lib/where_spec.rb b/spec/lib/where_spec.rb
new file mode 100644
index 0000000..c42c502
--- /dev/null
+++ b/spec/lib/where_spec.rb
@@ -0,0 +1,118 @@
+require File.join(File.dirname(__FILE__), '../spec_helper.rb')
+
+describe Where do
+ it "where_new__block__should_yield" do
+ Where.new {|w| w.and("hi = ?", "1")}.to_s.should == "(hi = '1')"
+ end
+
+ it "where_or_block__should_work" do
+ where = Where.new {|w|
+ w.or {
+ w.or "x = ?", 1
+ w.or "x = ?", 2
+ }
+
+ w.or {
+ w.or "y = ?", 1
+ w.or "y = ?", 2
+ }
+ }.to_s
+
+ where.to_s.should == "((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))"
+ end
+
+ it "where_and_block__should_work" do
+ where = Where.new {|w|
+ w.and {
+ w.or "x = ?", 1
+ w.or "x = ?", 2
+ }
+
+ w.and {
+ w.or "y = ?", 1
+ w.or "y = ?", 2
+ }
+ }.to_s
+
+ where.to_s.should == "((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))"
+ end
+
+ it "where__and_not__no_perfix__should_work" do
+ w = Where.new
+
+ w.and_not { w.or("x = ?", 1).or("x = ?", 2) }
+
+ w.to_s.should == "NOT ((x = 1) OR (x = 2))"
+ end
+
+
+ it "where__and_not__with_prefix__should_work" do
+ w = Where.new
+
+ w.and_not "x = ?", 1
+ w.and_not "y = ?", 1
+
+ w.to_s.should == "NOT (x = 1) AND NOT (y = 1)"
+ end
+
+ it "where__or_not__no_perfix__should_work" do
+ w = Where.new
+
+ w.or_not{ w.or("x = ?", 1).or("x = ?", 2) }
+
+ w.to_s.should == "NOT ((x = 1) OR (x = 2))"
+ end
+
+
+ it "where__or_not__with_prefix__should_work" do
+ w = Where.new
+
+ w.or_not "x = ?", 1
+ w.or_not "y = ?", 1
+
+ w.to_s.should == "NOT (x = 1) OR NOT (y = 1)"
+ end
+
+
+ it "where_new_chained_or" do
+ Where.new("x=1").or("x=2").to_sql.should == "(x=1) OR (x=2)"
+ end
+
+ it "where_new_chained_and" do
+ Where.new("x=1").and("x=2").to_sql.should == "(x=1) AND (x=2)"
+ end
+
+ it "where_and_where" do
+ where = Where.new
+ where.and Where.new("x=1")
+ where.to_s.should == "((x=1))"
+ end
+
+ it "where_or_where" do
+ where = Where.new
+ where.or Where.new("x=1")
+ where.to_s.should == "((x=1))"
+ end
+
+ it "where_method_invocation" do
+ Where{|w| w & ["x=?", 1] }.to_s.should == "(x=1)"
+ end
+
+ it "should nest clauses" do
+ w = Where.new
+ w.and {
+ w.or "x = 1"
+ w.or "x = 2"
+ }
+ w.and "y = 1"
+ w.to_sql.should == "((x = 1) OR (x = 2)) AND (y = 1)"
+ end
+
+ it "should use default params when rendering sql" do
+ where = Where.new(:default_params => {:x => 1})
+ where.default_params.should == {:x => 1}
+ where.and("x = :x")
+ where.to_s.should == "(x = 1)"
+ end
+
+end
\ No newline at end of file
diff --git a/test/test_helper.rb b/spec/spec_helper.rb
similarity index 85%
rename from test/test_helper.rb
rename to spec/spec_helper.rb
index c3e16b1..bfd6bf0 100644
--- a/test/test_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,22 +1,18 @@
require "rubygems"
-
-require 'test/unit'
require 'active_record'
-
+require 'spec'
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => File.join(File.dirname(__FILE__), "db/test.db")
)
for file in ["../lib/where.rb", "../lib/search_builder.rb"]
require File.expand_path(File.join(File.dirname(__FILE__), file))
end
-def dbg; require 'ruby-debug'; debugger; end
-
class Object
def to_regexp
is_a?(Regexp) ? self : Regexp.new(Regexp.escape(self.to_s))
end
end
\ No newline at end of file
diff --git a/test/functional/search_builder_test.rb b/test/functional/search_builder_test.rb
deleted file mode 100644
index 477b2f4..0000000
--- a/test/functional/search_builder_test.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-class SearchBuilderTest < Test::Unit::TestCase
- def setup
- @object = OpenStruct.new
- @sb = SearchBuilder.new(@object)
- end
-
- def test__search_builder_date_range
- @object.created_at_min = "Jan 2 2007 5:30"
- @object.created_at_max = "Jan 5 2007 5:30"
- @sb.range_on("proposals.created_at", :cast => :date)
-
- assert_equal("(proposals.created_at >= '2007-01-02') AND (proposals.created_at <= '2007-01-05')", @sb.to_sql)
- end
-
- def test__search_builder_date_range__nil_values__shouldnt_append_anything
- @sb.range_on("users.created_at", :cast => :date)
-
- assert_nil(@sb.to_sql)
- end
-
- def test__like_search
- @object.first_name = "Tim"
- @sb.like_on("users.first_name")
-
- assert_equal("(users.first_name like 'Tim%')", @sb.to_sql)
- end
-
- def test__equal_search
- @object.first_name = "Tim"
- @sb.equal_on("users.first_name")
-
- assert_equal("(users.first_name = 'Tim')", @sb.to_sql)
- end
-
- def test__in_search
- @object.value = [1,2,3,4]
- @sb.in_on "attributes.value"
- assert_equal("(attributes.value in (1,2,3,4))", @sb.to_sql)
- end
-
- def test__dot_in_field__should_be_smart_and_figure_it_out
- @object.first_name = "Tim"
- @sb.equal_on("users.first_name")
- assert_equal("(users.first_name = 'Tim')", @sb.to_sql)
- end
-
- def test__for_table__should_prepend
- @object.first_name = "Tim"
- @sb.for_table "users" do
- @sb.equal_on("first_name")
- end
-
- assert_equal("(users.first_name = 'Tim')", @sb.to_sql)
- end
-
- def test__for_table_no_block__should_prepend
- @object.first_name = "Tim"
- @sb.for_table "users"
- @sb.equal_on("first_name")
-
- assert_equal("(users.first_name = 'Tim')", @sb.to_sql)
- end
-
- def test__use_symbol__should_process_ok__should_append
- @object.first_name = "Tim"
- @sb.equal_on(:first_name)
-
- assert_equal("(first_name = 'Tim')", @sb.to_sql)
-
- end
-
-
-end
diff --git a/test/functional/where_test.rb b/test/functional/where_test.rb
deleted file mode 100644
index a26e9d1..0000000
--- a/test/functional/where_test.rb
+++ /dev/null
@@ -1,113 +0,0 @@
-require File.join(File.dirname(__FILE__), '../test_helper.rb')
-
-class WhereTest < Test::Unit::TestCase
- def test__where_new__block__should_yield
- assert_equal("(hi = '1')", Where.new {|w| w.and("hi = ?", "1")}.to_s)
- end
-
- def test__where_or_block__should_work
- where = Where.new {|w|
- w.or {|y|
- y.or "x = ?", 1
- y.or "x = ?", 2
- }
-
- w.or {|y|
- y.or "y = ?", 1
- y.or "y = ?", 2
- }
- }.to_s
-
- assert_equal("((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))", where.to_s)
- end
-
- def test__where_and_block__should_work
- where = Where.new {|w|
- w.and {|y|
- y.or "x = ?", 1
- y.or "x = ?", 2
- }
-
- w.and {|y|
- y.or "y = ?", 1
- y.or "y = ?", 2
- }
- }.to_s
-
- assert_equal("((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))", where.to_s)
- end
-
- def test__where__and_not__no_prefix__should_work
- w = Where.new
-
- w.and_not{|y| y.or("x = ?", 1).or("x = ?", 2) }
-
- assert_equal("NOT ((x = 1) OR (x = 2))", w.to_s)
- end
-
- def test__and_nested_blank__should_ignore
-
- w = Where("x = ?", 1)
- w.and{|inner|
- inner.and "x = ?", 2 if false
- }
- assert_equal("(x = 1)", w.to_sql)
- end
-
- def test__where__and_not__with_prefix__should_work
- w = Where.new
-
- w.and_not "x = ?", 1
- w.and_not "y = ?", 1
-
- assert_equal("NOT (x = 1) AND NOT (y = 1)", w.to_s)
- end
-
- def test__where__or_not__no_perfix__should_work
- w = Where.new
-
- w.or_not{|y| y.or("x = ?", 1).or("x = ?", 2) }
-
- assert_equal("NOT ((x = 1) OR (x = 2))", w.to_s)
- end
-
-
- def test__where__or_not__with_prefix__should_work
- w = Where.new
-
- w.or_not "x = ?", 1
- w.or_not "y = ?", 1
-
- assert_equal("NOT (x = 1) OR NOT (y = 1)", w.to_s)
- end
-
-
- def test__where_new_chained_or
- assert_equal("(x=1) OR (x=2)", Where.new("x=1").or("x=2").to_sql)
- end
-
- def test__where_new_chained_and
- assert_equal("(x=1) AND (x=2)", Where.new("x=1").and("x=2").to_sql)
- end
-
- def test__where_to_s__when_blank__returns_empty_string
- assert_equal "", Where.new.to_s
- end
-
- def test__where_and_where
- where = Where.new
- where.and Where.new("x=1")
- assert_equal("((x=1))", where.to_s)
- end
-
- def test__where_or_where
- where = Where.new
- where.or Where.new("x=1")
- assert_equal("((x=1))", where.to_s)
- end
-
- def test__where_method_invocation
- assert_equal( "(x=1)", Where{|w| w & ["x=?", 1] }.to_s)
- end
-
-end
\ No newline at end of file
|
timcharper/railswhere
|
aa759eb9a93811f40f7d11a8918de47829fbbfb5
|
return "" when to_s on blank Where - test case
|
diff --git a/test/functional/where_test.rb b/test/functional/where_test.rb
index 01e2e1b..a26e9d1 100644
--- a/test/functional/where_test.rb
+++ b/test/functional/where_test.rb
@@ -1,109 +1,113 @@
require File.join(File.dirname(__FILE__), '../test_helper.rb')
class WhereTest < Test::Unit::TestCase
def test__where_new__block__should_yield
assert_equal("(hi = '1')", Where.new {|w| w.and("hi = ?", "1")}.to_s)
end
def test__where_or_block__should_work
where = Where.new {|w|
w.or {|y|
y.or "x = ?", 1
y.or "x = ?", 2
}
w.or {|y|
y.or "y = ?", 1
y.or "y = ?", 2
}
}.to_s
assert_equal("((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))", where.to_s)
end
def test__where_and_block__should_work
where = Where.new {|w|
w.and {|y|
y.or "x = ?", 1
y.or "x = ?", 2
}
w.and {|y|
y.or "y = ?", 1
y.or "y = ?", 2
}
}.to_s
assert_equal("((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))", where.to_s)
end
def test__where__and_not__no_prefix__should_work
w = Where.new
w.and_not{|y| y.or("x = ?", 1).or("x = ?", 2) }
assert_equal("NOT ((x = 1) OR (x = 2))", w.to_s)
end
def test__and_nested_blank__should_ignore
w = Where("x = ?", 1)
w.and{|inner|
inner.and "x = ?", 2 if false
}
assert_equal("(x = 1)", w.to_sql)
end
def test__where__and_not__with_prefix__should_work
w = Where.new
w.and_not "x = ?", 1
w.and_not "y = ?", 1
assert_equal("NOT (x = 1) AND NOT (y = 1)", w.to_s)
end
def test__where__or_not__no_perfix__should_work
w = Where.new
w.or_not{|y| y.or("x = ?", 1).or("x = ?", 2) }
assert_equal("NOT ((x = 1) OR (x = 2))", w.to_s)
end
def test__where__or_not__with_prefix__should_work
w = Where.new
w.or_not "x = ?", 1
w.or_not "y = ?", 1
assert_equal("NOT (x = 1) OR NOT (y = 1)", w.to_s)
end
def test__where_new_chained_or
assert_equal("(x=1) OR (x=2)", Where.new("x=1").or("x=2").to_sql)
end
def test__where_new_chained_and
assert_equal("(x=1) AND (x=2)", Where.new("x=1").and("x=2").to_sql)
end
+ def test__where_to_s__when_blank__returns_empty_string
+ assert_equal "", Where.new.to_s
+ end
+
def test__where_and_where
where = Where.new
where.and Where.new("x=1")
assert_equal("((x=1))", where.to_s)
end
def test__where_or_where
where = Where.new
where.or Where.new("x=1")
assert_equal("((x=1))", where.to_s)
end
def test__where_method_invocation
assert_equal( "(x=1)", Where{|w| w & ["x=?", 1] }.to_s)
end
end
\ No newline at end of file
|
timcharper/railswhere
|
e622994a18aebd45611d33874268209f0be26e7b
|
return "" when to_s on blank Where
|
diff --git a/lib/where.rb b/lib/where.rb
index 940dbc6..cc8c077 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,189 +1,189 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
# # Sweet chaining action!
class Where
# Constructs a new where clause
#
# optionally, you can provide a criteria, like the following:
#
# Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
def initialize(criteria=nil, *params, &block)
@clauses=Array.new
self.and(criteria, *params) unless criteria.nil?
yield(self) if block_given?
end
def initialize_copy(from)
@clauses = from.instance_variable_get("@clauses").clone
end
# Appends an <b>and</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.and("name = ?", "Tim O'brien")
# where.to_s
#
# # => "(name = 'Tim O''brien')
def and(*params, &block)
append_clause(params, "AND", &block)
end
alias << and
# Appends an <b>or</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.or("name = ?", "Tim O'brien")
# where.or("name = ?", "Tim O'neal")
# where.to_s
#
# # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
def or(*params, &block)
append_clause(params, "OR", &block)
end
# Same as or, but negates the whole expression
def or_not(*params, &block)
append_clause(params, "OR NOT", &block)
end
# Same as and, but negates the whole expression
def and_not(*params, &block)
append_clause(params, "AND NOT", &block)
end
def &(params)
self.and(*params)
end
def |(params)
self.or(*params)
end
def self.&(params)
Where.new(*params)
end
def self.|(params)
Where.new.or(*params)
end
# Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
@clauses.each_with_index{|clause, index|
clause_output = clause.to_s(index==0) # Omit the clause if index==0
output << clause_output unless clause_output.blank?
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
- output.empty? ? nil : output
+ output.empty? ? "" : output
end
end
alias :to_sql :to_s
# Determines if any clauses have been added.
#
# where = Where.new
# where.blank?
# # => true
#
# where.and(nil)
# where.blank?
# # => true
#
# where.and(Where.new(nil))
# where.blank?
# # => true
#
# where.and("name=1")
# where.blank?
# # => false
def blank?
@clauses.empty?
end
alias :empty? :blank?
protected
def append_clause(params, conjuction = "AND", &block) # :nodoc:
if block_given?
yield(w = Where.new)
@clauses << Clause.new(w, conjuction)
else
@clauses << Clause.new(params, conjuction) unless params.first.blank?
end
self
end
# Used internally to +Where+. You shouldn't have any reason to interact with this class.
class Clause
def initialize(criteria, conjuction = "AND") # :nodoc:
@conjuction=conjuction.upcase
criteria = criteria.first if criteria.class==Array && criteria.length==1
if criteria.class==Array # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_conjuction=false) # :nodoc:
- return nil if @criteria.blank?
+ return "" if @criteria.blank?
if omit_conjuction
output = @conjuction.include?("NOT") ? "NOT " : ""
output << "(#{@criteria})"
else
" #{@conjuction} (#{@criteria})"
end
end
end
end
def Where(*params, &block)
Where.new(*params, &block)
end
\ No newline at end of file
|
timcharper/railswhere
|
5f7e38be38153a2ae51464c71630e6060d8c65d5
|
added where#and to exclude blank nested conditions
|
diff --git a/lib/search_builder.rb b/lib/search_builder.rb
index 11c0067..beb7ba6 100644
--- a/lib/search_builder.rb
+++ b/lib/search_builder.rb
@@ -1,134 +1,135 @@
require 'ostruct'
class SearchBuilder
attr_reader :object
attr_accessor :where
def object=(value)
value=OpenStruct.new(value) if Hash===value
@object = value
end
def initialize(target_object, options={})
self.object = target_object.is_a?(Hash) ? OpenStruct.new(target_object) : target_object
self.where = options[:append_to] || Where.new
@table_prefix = ""
end
def self.delegate_to(object_name, methods = [])
for method_name in methods
class_eval <<-EOF, __FILE__, __LINE__ +1
def #{method_name}(*params, &block)
#{object_name} && #{object_name}.#{method_name}(*params, &block)
end
EOF
end
end
delegate_to "@where", %w[and or to_sql to_s empty?]
def range_on(field, options={})
options = options.clone
min_param = options[:min_param] || "#{options[:param] || field}_min"
max_param = options[:max_param] || "#{options[:param] || field}_max"
cast = options[:cast] || :string
process_clause(field, ">= ?", options.merge(:param => min_param))
process_clause(field, "<= ?", options.merge(:param => max_param))
self
end
def like_on(field, options={})
options = options.clone
options[:suffix] ||= "%"
process_clause(field, "like ?", options)
end
def for_table(table, &block)
if block_given?
last_table_prefix = @table_prefix
end
@table_prefix = "#{table}."
if block_given?
yield
@table_prefix = last_table_prefix
end
end
def equal_on(field, options={})
options = options.clone
options[:cast] = :string
process_clause(field, "= ?", options)
end
def in_on(field, options={})
options = options.clone
options[:cast] ||= :array
process_clause(field, "in (?)", options)
end
def process_clause(field, operator_clause, options={})
param = options[:param] || field
self.and_unless_blank("#{@table_prefix}#{field} #{operator_clause}", value_for(param, options[:cast]), options)
self
end
def and_unless_blank(condition, value, options={})
value = value.compact if (Array === value)
# if value is an empty array or a blank string, don't filter on it
return self if value.blank?
prefix = options[:prefix]
suffix = options[:suffix]
if prefix || suffix
@where.and(condition, [prefix, value, suffix].compact.to_s )
else
@where.and(condition, value)
end
self
end
def value_for(param, cast=:string)
param = param.to_s
if param.include?(".")
param=param.split(".").last
end
cast_to( object.send(param), cast)
end
def cast_to(value, type)
self.class.cast_to(value, type)
end
def self.cast_to(value, type)
- return value if value.nil?
+ return nil if value.blank?
case type
when nil
value
when :array
value = Array===value ? value : [value]
+ value.reject{|v| v.blank?}
when :time
Time.parse(value)
when :date
Time.parse(value).to_date
when :i, :int, :integer
value.to_i
when :f, :float
value.to_f
when :string
value.to_s
else
raise "unknown cast type: #{type}"
end
end
end
\ No newline at end of file
diff --git a/lib/where.rb b/lib/where.rb
index a615d52..940dbc6 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,188 +1,189 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
# # Sweet chaining action!
class Where
# Constructs a new where clause
#
# optionally, you can provide a criteria, like the following:
#
# Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
def initialize(criteria=nil, *params, &block)
@clauses=Array.new
self.and(criteria, *params) unless criteria.nil?
yield(self) if block_given?
end
def initialize_copy(from)
@clauses = from.instance_variable_get("@clauses").clone
end
# Appends an <b>and</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.and("name = ?", "Tim O'brien")
# where.to_s
#
# # => "(name = 'Tim O''brien')
def and(*params, &block)
append_clause(params, "AND", &block)
end
alias << and
# Appends an <b>or</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.or("name = ?", "Tim O'brien")
# where.or("name = ?", "Tim O'neal")
# where.to_s
#
# # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
def or(*params, &block)
append_clause(params, "OR", &block)
end
# Same as or, but negates the whole expression
def or_not(*params, &block)
append_clause(params, "OR NOT", &block)
end
# Same as and, but negates the whole expression
def and_not(*params, &block)
append_clause(params, "AND NOT", &block)
end
def &(params)
self.and(*params)
end
def |(params)
self.or(*params)
end
def self.&(params)
Where.new(*params)
end
def self.|(params)
Where.new.or(*params)
end
# Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
- @clauses.each_index{|index|
- omit_conjuction = (index==0)
- output << @clauses[index].to_s(omit_conjuction) # Omit the clause if index=0
+ @clauses.each_with_index{|clause, index|
+ clause_output = clause.to_s(index==0) # Omit the clause if index==0
+ output << clause_output unless clause_output.blank?
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
output.empty? ? nil : output
end
end
alias :to_sql :to_s
# Determines if any clauses have been added.
#
# where = Where.new
# where.blank?
# # => true
#
# where.and(nil)
# where.blank?
# # => true
#
# where.and(Where.new(nil))
# where.blank?
# # => true
#
# where.and("name=1")
# where.blank?
# # => false
def blank?
@clauses.empty?
end
alias :empty? :blank?
protected
def append_clause(params, conjuction = "AND", &block) # :nodoc:
if block_given?
yield(w = Where.new)
@clauses << Clause.new(w, conjuction)
else
@clauses << Clause.new(params, conjuction) unless params.first.blank?
end
self
end
# Used internally to +Where+. You shouldn't have any reason to interact with this class.
class Clause
def initialize(criteria, conjuction = "AND") # :nodoc:
@conjuction=conjuction.upcase
criteria = criteria.first if criteria.class==Array && criteria.length==1
if criteria.class==Array # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_conjuction=false) # :nodoc:
+ return nil if @criteria.blank?
if omit_conjuction
output = @conjuction.include?("NOT") ? "NOT " : ""
output << "(#{@criteria})"
else
" #{@conjuction} (#{@criteria})"
end
end
end
end
def Where(*params, &block)
Where.new(*params, &block)
end
\ No newline at end of file
diff --git a/test/functional/where_test.rb b/test/functional/where_test.rb
index 747406f..01e2e1b 100644
--- a/test/functional/where_test.rb
+++ b/test/functional/where_test.rb
@@ -1,101 +1,109 @@
require File.join(File.dirname(__FILE__), '../test_helper.rb')
class WhereTest < Test::Unit::TestCase
def test__where_new__block__should_yield
assert_equal("(hi = '1')", Where.new {|w| w.and("hi = ?", "1")}.to_s)
end
def test__where_or_block__should_work
where = Where.new {|w|
w.or {|y|
y.or "x = ?", 1
y.or "x = ?", 2
}
w.or {|y|
y.or "y = ?", 1
y.or "y = ?", 2
}
}.to_s
assert_equal("((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))", where.to_s)
end
def test__where_and_block__should_work
where = Where.new {|w|
w.and {|y|
y.or "x = ?", 1
y.or "x = ?", 2
}
w.and {|y|
y.or "y = ?", 1
y.or "y = ?", 2
}
}.to_s
assert_equal("((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))", where.to_s)
end
- def test__where__and_not__no_perfix__should_work
+ def test__where__and_not__no_prefix__should_work
w = Where.new
w.and_not{|y| y.or("x = ?", 1).or("x = ?", 2) }
assert_equal("NOT ((x = 1) OR (x = 2))", w.to_s)
end
+ def test__and_nested_blank__should_ignore
+
+ w = Where("x = ?", 1)
+ w.and{|inner|
+ inner.and "x = ?", 2 if false
+ }
+ assert_equal("(x = 1)", w.to_sql)
+ end
def test__where__and_not__with_prefix__should_work
w = Where.new
w.and_not "x = ?", 1
w.and_not "y = ?", 1
assert_equal("NOT (x = 1) AND NOT (y = 1)", w.to_s)
end
def test__where__or_not__no_perfix__should_work
w = Where.new
w.or_not{|y| y.or("x = ?", 1).or("x = ?", 2) }
assert_equal("NOT ((x = 1) OR (x = 2))", w.to_s)
end
def test__where__or_not__with_prefix__should_work
w = Where.new
w.or_not "x = ?", 1
w.or_not "y = ?", 1
assert_equal("NOT (x = 1) OR NOT (y = 1)", w.to_s)
end
def test__where_new_chained_or
assert_equal("(x=1) OR (x=2)", Where.new("x=1").or("x=2").to_sql)
end
def test__where_new_chained_and
assert_equal("(x=1) AND (x=2)", Where.new("x=1").and("x=2").to_sql)
end
def test__where_and_where
where = Where.new
where.and Where.new("x=1")
assert_equal("((x=1))", where.to_s)
end
def test__where_or_where
where = Where.new
where.or Where.new("x=1")
assert_equal("((x=1))", where.to_s)
end
def test__where_method_invocation
assert_equal( "(x=1)", Where{|w| w & ["x=?", 1] }.to_s)
end
end
\ No newline at end of file
|
timcharper/railswhere
|
2d376c523733031499dc6febbc706b412bdfc835
|
search builder
|
diff --git a/init.rb b/init.rb
index 583795b..bd4169a 100644
--- a/init.rb
+++ b/init.rb
@@ -1,2 +1,3 @@
require 'where.rb'
+require 'search_builder.rb'
diff --git a/lib/search_builder.rb b/lib/search_builder.rb
new file mode 100644
index 0000000..14a8e4c
--- /dev/null
+++ b/lib/search_builder.rb
@@ -0,0 +1,136 @@
+require 'ostruct'
+class SearchBuilder
+ attr_reader :object
+ attr_accessor :where
+
+ def object=(value)
+ value=OpenStruct.new(value) if Hash===value
+ @object = value
+ end
+
+ def initialize(target_object, options={})
+ self.object = target_object.is_a?(Hash) ? OpenStruct.new(target_object) : target_object
+ self.where = options[:append_to] || Where.new
+ @table_prefix = ""
+ end
+
+ def and(*params, &block)
+ @where.and(*params, &block)
+ end
+
+ def or(*params, &block)
+ @where.or(*params, &block)
+ end
+
+ def to_sql(*params)
+ @where.to_sql(*params)
+ end
+
+ alias to_s :to_sql
+
+ def range_on(field, options={})
+ options = options.clone
+ min_param = options[:min_param] || "#{options[:param] || field}_min"
+ max_param = options[:max_param] || "#{options[:param] || field}_max"
+ cast = options[:cast] || :string
+
+ process_clause(field, ">= ?", options.merge(:param => min_param))
+ process_clause(field, "<= ?", options.merge(:param => max_param))
+
+ self
+ end
+
+ def like_on(field, options={})
+ options = options.clone
+ options[:suffix] ||= "%"
+
+ process_clause(field, "like ?", options)
+ end
+
+ def for_table(table, &block)
+ if block_given?
+ last_table_prefix = @table_prefix
+ end
+
+ @table_prefix = "#{table}."
+
+ if block_given?
+ yield
+
+ @table_prefix = last_table_prefix
+ end
+
+ end
+
+ def equal_on(field, options={})
+ options = options.clone
+ options[:cast] = :string
+ process_clause(field, "= ?", options)
+ end
+
+ def in_on(field, options={})
+ options = options.clone
+ options[:cast] ||= :array
+ process_clause(field, "in (?)", options)
+ end
+
+ def process_clause(field, operator_clause, options={})
+ param = options[:param] || field
+ self.and_unless_blank("#{@table_prefix}#{field} #{operator_clause}", value_for(param, options[:cast]), options)
+
+ self
+ end
+
+ def and_unless_blank(condition, value, options={})
+ value = value.compact if (Array === value)
+
+ # if value is an empty array or a blank string, don't filter on it
+ return self if value.blank?
+
+ prefix = options[:prefix]
+ suffix = options[:suffix]
+ if prefix || suffix
+ @where.and(condition, [prefix, value, suffix].compact.to_s )
+ else
+ @where.and(condition, value)
+ end
+
+ self
+ end
+
+ def value_for(param, cast=:string)
+ param = param.to_s
+ if param.include?(".")
+ param=param.split(".").last
+ end
+ cast_to( object.send(param), cast)
+ end
+
+ def cast_to(value, type)
+ self.class.cast_to(value, type)
+ end
+
+ def self.cast_to(value, type)
+ return value if value.nil?
+
+ case type
+ when nil
+ value
+ when :array
+ value = Array===value ? value : [value]
+ when :time
+ Time.parse(value)
+ when :date
+ Time.parse(value).to_date
+ when :i, :int, :integer
+ value.to_i
+ when :f, :float
+ value.to_f
+ when :string
+ value.to_s
+ else
+ raise "unknown cast type: #{type}"
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/lib/where.rb b/lib/where.rb
index f49bc74..a615d52 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,188 +1,188 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
# # Sweet chaining action!
class Where
# Constructs a new where clause
#
# optionally, you can provide a criteria, like the following:
#
# Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
def initialize(criteria=nil, *params, &block)
@clauses=Array.new
self.and(criteria, *params) unless criteria.nil?
yield(self) if block_given?
end
def initialize_copy(from)
@clauses = from.instance_variable_get("@clauses").clone
end
# Appends an <b>and</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.and("name = ?", "Tim O'brien")
# where.to_s
#
# # => "(name = 'Tim O''brien')
def and(*params, &block)
append_clause(params, "AND", &block)
end
alias << and
# Appends an <b>or</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.or("name = ?", "Tim O'brien")
# where.or("name = ?", "Tim O'neal")
# where.to_s
#
# # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
def or(*params, &block)
append_clause(params, "OR", &block)
end
# Same as or, but negates the whole expression
def or_not(*params, &block)
append_clause(params, "OR NOT", &block)
end
# Same as and, but negates the whole expression
def and_not(*params, &block)
append_clause(params, "AND NOT", &block)
end
def &(params)
self.and(*params)
end
def |(params)
self.or(*params)
end
def self.&(params)
Where.new(*params)
end
def self.|(params)
Where.new.or(*params)
end
# Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
@clauses.each_index{|index|
omit_conjuction = (index==0)
output << @clauses[index].to_s(omit_conjuction) # Omit the clause if index=0
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
output.empty? ? nil : output
end
end
alias :to_sql :to_s
# Determines if any clauses have been added.
#
# where = Where.new
# where.blank?
# # => true
#
# where.and(nil)
# where.blank?
# # => true
#
# where.and(Where.new(nil))
# where.blank?
# # => true
#
# where.and("name=1")
# where.blank?
# # => false
def blank?
@clauses.empty?
end
alias :empty? :blank?
protected
def append_clause(params, conjuction = "AND", &block) # :nodoc:
if block_given?
yield(w = Where.new)
@clauses << Clause.new(w, conjuction)
else
@clauses << Clause.new(params, conjuction) unless params.first.blank?
end
self
end
# Used internally to +Where+. You shouldn't have any reason to interact with this class.
class Clause
def initialize(criteria, conjuction = "AND") # :nodoc:
@conjuction=conjuction.upcase
criteria = criteria.first if criteria.class==Array && criteria.length==1
if criteria.class==Array # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_conjuction=false) # :nodoc:
if omit_conjuction
output = @conjuction.include?("NOT") ? "NOT " : ""
output << "(#{@criteria})"
else
" #{@conjuction} (#{@criteria})"
end
end
end
end
-def Where(&block)
- Where.new(&block)
+def Where(*params, &block)
+ Where.new(*params, &block)
end
\ No newline at end of file
diff --git a/test/functional/where_test.rb b/test/functional/where_test.rb
index c777b3f..747406f 100644
--- a/test/functional/where_test.rb
+++ b/test/functional/where_test.rb
@@ -1,101 +1,101 @@
require File.join(File.dirname(__FILE__), '../test_helper.rb')
class WhereTest < Test::Unit::TestCase
def test__where_new__block__should_yield
assert_equal("(hi = '1')", Where.new {|w| w.and("hi = ?", "1")}.to_s)
end
def test__where_or_block__should_work
where = Where.new {|w|
w.or {|y|
y.or "x = ?", 1
y.or "x = ?", 2
}
w.or {|y|
y.or "y = ?", 1
y.or "y = ?", 2
}
}.to_s
assert_equal("((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))", where.to_s)
end
def test__where_and_block__should_work
where = Where.new {|w|
w.and {|y|
- y | ["x = ?", 1]
- y | ["x = ?", 2]
+ y.or "x = ?", 1
+ y.or "x = ?", 2
}
w.and {|y|
- y | ["y = ?", 1]
- y | ["y = ?", 2]
+ y.or "y = ?", 1
+ y.or "y = ?", 2
}
}.to_s
assert_equal("((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))", where.to_s)
end
def test__where__and_not__no_perfix__should_work
w = Where.new
w.and_not{|y| y.or("x = ?", 1).or("x = ?", 2) }
assert_equal("NOT ((x = 1) OR (x = 2))", w.to_s)
end
def test__where__and_not__with_prefix__should_work
w = Where.new
w.and_not "x = ?", 1
w.and_not "y = ?", 1
assert_equal("NOT (x = 1) AND NOT (y = 1)", w.to_s)
end
def test__where__or_not__no_perfix__should_work
w = Where.new
w.or_not{|y| y.or("x = ?", 1).or("x = ?", 2) }
assert_equal("NOT ((x = 1) OR (x = 2))", w.to_s)
end
def test__where__or_not__with_prefix__should_work
w = Where.new
w.or_not "x = ?", 1
w.or_not "y = ?", 1
assert_equal("NOT (x = 1) OR NOT (y = 1)", w.to_s)
end
def test__where_new_chained_or
assert_equal("(x=1) OR (x=2)", Where.new("x=1").or("x=2").to_sql)
end
def test__where_new_chained_and
assert_equal("(x=1) AND (x=2)", Where.new("x=1").and("x=2").to_sql)
end
def test__where_and_where
where = Where.new
where.and Where.new("x=1")
assert_equal("((x=1))", where.to_s)
end
def test__where_or_where
where = Where.new
where.or Where.new("x=1")
assert_equal("((x=1))", where.to_s)
end
def test__where_method_invocation
assert_equal( "(x=1)", Where{|w| w & ["x=?", 1] }.to_s)
end
end
\ No newline at end of file
|
timcharper/railswhere
|
5b1a51bd4677c45eb96410b86be2b7ae21082097
|
| & operator shortcuts
|
diff --git a/lib/where.rb b/lib/where.rb
index f869701..f49bc74 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,168 +1,188 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
# # Sweet chaining action!
class Where
# Constructs a new where clause
#
# optionally, you can provide a criteria, like the following:
#
# Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
def initialize(criteria=nil, *params, &block)
@clauses=Array.new
self.and(criteria, *params) unless criteria.nil?
yield(self) if block_given?
end
def initialize_copy(from)
@clauses = from.instance_variable_get("@clauses").clone
end
# Appends an <b>and</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.and("name = ?", "Tim O'brien")
# where.to_s
#
# # => "(name = 'Tim O''brien')
def and(*params, &block)
append_clause(params, "AND", &block)
end
alias << and
# Appends an <b>or</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.or("name = ?", "Tim O'brien")
# where.or("name = ?", "Tim O'neal")
# where.to_s
#
# # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
def or(*params, &block)
append_clause(params, "OR", &block)
end
# Same as or, but negates the whole expression
def or_not(*params, &block)
append_clause(params, "OR NOT", &block)
end
# Same as and, but negates the whole expression
def and_not(*params, &block)
append_clause(params, "AND NOT", &block)
end
+ def &(params)
+ self.and(*params)
+ end
+
+ def |(params)
+ self.or(*params)
+ end
+
+ def self.&(params)
+ Where.new(*params)
+ end
+
+ def self.|(params)
+ Where.new.or(*params)
+ end
+
# Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
@clauses.each_index{|index|
omit_conjuction = (index==0)
output << @clauses[index].to_s(omit_conjuction) # Omit the clause if index=0
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
output.empty? ? nil : output
end
end
alias :to_sql :to_s
# Determines if any clauses have been added.
#
# where = Where.new
# where.blank?
# # => true
#
# where.and(nil)
# where.blank?
# # => true
#
# where.and(Where.new(nil))
# where.blank?
# # => true
#
# where.and("name=1")
# where.blank?
# # => false
def blank?
@clauses.empty?
end
alias :empty? :blank?
protected
def append_clause(params, conjuction = "AND", &block) # :nodoc:
if block_given?
yield(w = Where.new)
@clauses << Clause.new(w, conjuction)
else
@clauses << Clause.new(params, conjuction) unless params.first.blank?
end
self
end
# Used internally to +Where+. You shouldn't have any reason to interact with this class.
class Clause
def initialize(criteria, conjuction = "AND") # :nodoc:
@conjuction=conjuction.upcase
criteria = criteria.first if criteria.class==Array && criteria.length==1
if criteria.class==Array # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_conjuction=false) # :nodoc:
if omit_conjuction
output = @conjuction.include?("NOT") ? "NOT " : ""
output << "(#{@criteria})"
else
" #{@conjuction} (#{@criteria})"
end
end
end
end
+
+def Where(&block)
+ Where.new(&block)
+end
\ No newline at end of file
diff --git a/test/functional/where_test.rb b/test/functional/where_test.rb
index 71f0e95..c777b3f 100644
--- a/test/functional/where_test.rb
+++ b/test/functional/where_test.rb
@@ -1,96 +1,101 @@
require File.join(File.dirname(__FILE__), '../test_helper.rb')
class WhereTest < Test::Unit::TestCase
def test__where_new__block__should_yield
assert_equal("(hi = '1')", Where.new {|w| w.and("hi = ?", "1")}.to_s)
end
def test__where_or_block__should_work
where = Where.new {|w|
w.or {|y|
y.or "x = ?", 1
y.or "x = ?", 2
}
w.or {|y|
y.or "y = ?", 1
y.or "y = ?", 2
}
}.to_s
assert_equal("((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))", where.to_s)
end
def test__where_and_block__should_work
where = Where.new {|w|
w.and {|y|
- y.or "x = ?", 1
- y.or "x = ?", 2
+ y | ["x = ?", 1]
+ y | ["x = ?", 2]
}
w.and {|y|
- y.or "y = ?", 1
- y.or "y = ?", 2
+ y | ["y = ?", 1]
+ y | ["y = ?", 2]
}
}.to_s
assert_equal("((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))", where.to_s)
end
def test__where__and_not__no_perfix__should_work
w = Where.new
w.and_not{|y| y.or("x = ?", 1).or("x = ?", 2) }
assert_equal("NOT ((x = 1) OR (x = 2))", w.to_s)
end
def test__where__and_not__with_prefix__should_work
w = Where.new
w.and_not "x = ?", 1
w.and_not "y = ?", 1
assert_equal("NOT (x = 1) AND NOT (y = 1)", w.to_s)
end
def test__where__or_not__no_perfix__should_work
w = Where.new
w.or_not{|y| y.or("x = ?", 1).or("x = ?", 2) }
assert_equal("NOT ((x = 1) OR (x = 2))", w.to_s)
end
def test__where__or_not__with_prefix__should_work
w = Where.new
w.or_not "x = ?", 1
w.or_not "y = ?", 1
assert_equal("NOT (x = 1) OR NOT (y = 1)", w.to_s)
end
def test__where_new_chained_or
assert_equal("(x=1) OR (x=2)", Where.new("x=1").or("x=2").to_sql)
end
def test__where_new_chained_and
assert_equal("(x=1) AND (x=2)", Where.new("x=1").and("x=2").to_sql)
end
def test__where_and_where
where = Where.new
where.and Where.new("x=1")
assert_equal("((x=1))", where.to_s)
end
def test__where_or_where
where = Where.new
where.or Where.new("x=1")
assert_equal("((x=1))", where.to_s)
end
+
+ def test__where_method_invocation
+ assert_equal( "(x=1)", Where{|w| w & ["x=?", 1] }.to_s)
+ end
+
end
\ No newline at end of file
|
timcharper/railswhere
|
760c995be840f24a3147c48a81fb57fc2691e8d0
|
or_not, and_not
|
diff --git a/lib/where.rb b/lib/where.rb
index af6b21c..f869701 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,156 +1,168 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
# # Sweet chaining action!
class Where
# Constructs a new where clause
#
# optionally, you can provide a criteria, like the following:
#
# Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
def initialize(criteria=nil, *params, &block)
@clauses=Array.new
self.and(criteria, *params) unless criteria.nil?
yield(self) if block_given?
end
def initialize_copy(from)
@clauses = from.instance_variable_get("@clauses").clone
end
# Appends an <b>and</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.and("name = ?", "Tim O'brien")
# where.to_s
#
# # => "(name = 'Tim O''brien')
def and(*params, &block)
- if block_given?
- yield(w = Where.new)
- @clauses << Clause.new(w)
- else
- @clauses << Clause.new(params) unless params.blank?
- end
- self
+ append_clause(params, "AND", &block)
end
alias << and
# Appends an <b>or</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.or("name = ?", "Tim O'brien")
# where.or("name = ?", "Tim O'neal")
# where.to_s
#
# # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
def or(*params, &block)
- if block_given?
- yield(w = Where.new)
- @clauses << Clause.new(w, true)
- else
- @clauses << Clause.new(params, true) unless params.blank?
- end
- self
+ append_clause(params, "OR", &block)
+ end
+
+ # Same as or, but negates the whole expression
+ def or_not(*params, &block)
+ append_clause(params, "OR NOT", &block)
+ end
+
+ # Same as and, but negates the whole expression
+ def and_not(*params, &block)
+ append_clause(params, "AND NOT", &block)
end
# Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
@clauses.each_index{|index|
- omit_clause = (index==0)
- output << @clauses[index].to_s(omit_clause) # Omit the clause if index=0
+ omit_conjuction = (index==0)
+ output << @clauses[index].to_s(omit_conjuction) # Omit the clause if index=0
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
output.empty? ? nil : output
end
end
alias :to_sql :to_s
# Determines if any clauses have been added.
#
# where = Where.new
# where.blank?
# # => true
#
# where.and(nil)
# where.blank?
# # => true
#
# where.and(Where.new(nil))
# where.blank?
# # => true
#
# where.and("name=1")
# where.blank?
# # => false
def blank?
@clauses.empty?
end
alias :empty? :blank?
+protected
+ def append_clause(params, conjuction = "AND", &block) # :nodoc:
+ if block_given?
+ yield(w = Where.new)
+ @clauses << Clause.new(w, conjuction)
+ else
+ @clauses << Clause.new(params, conjuction) unless params.first.blank?
+ end
+ self
+ end
+
# Used internally to +Where+. You shouldn't have any reason to interact with this class.
- class Clause
- def initialize(criteria, is_or = false)
- @is_or=is_or
-
- if criteria.class==Array && criteria.length>1 # if it's an array, sanitize it
+ class Clause
+
+ def initialize(criteria, conjuction = "AND") # :nodoc:
+ @conjuction=conjuction.upcase
+ criteria = criteria.first if criteria.class==Array && criteria.length==1
+
+ if criteria.class==Array # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
- def to_s(omit_clause=false)
- if omit_clause
- "(#{@criteria})"
+ def to_s(omit_conjuction=false) # :nodoc:
+ if omit_conjuction
+ output = @conjuction.include?("NOT") ? "NOT " : ""
+ output << "(#{@criteria})"
else
- " #{@is_or ? 'OR' : 'AND'} (#{@criteria})"
+ " #{@conjuction} (#{@criteria})"
end
end
end
end
diff --git a/test/functional/where_test.rb b/test/functional/where_test.rb
index 33ea2d0..71f0e95 100644
--- a/test/functional/where_test.rb
+++ b/test/functional/where_test.rb
@@ -1,59 +1,96 @@
require File.join(File.dirname(__FILE__), '../test_helper.rb')
class WhereTest < Test::Unit::TestCase
def test__where_new__block__should_yield
assert_equal("(hi = '1')", Where.new {|w| w.and("hi = ?", "1")}.to_s)
end
def test__where_or_block__should_work
where = Where.new {|w|
w.or {|y|
y.or "x = ?", 1
y.or "x = ?", 2
}
w.or {|y|
y.or "y = ?", 1
y.or "y = ?", 2
}
}.to_s
assert_equal("((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))", where.to_s)
end
def test__where_and_block__should_work
where = Where.new {|w|
w.and {|y|
y.or "x = ?", 1
y.or "x = ?", 2
}
w.and {|y|
y.or "y = ?", 1
y.or "y = ?", 2
}
}.to_s
assert_equal("((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))", where.to_s)
end
+ def test__where__and_not__no_perfix__should_work
+ w = Where.new
+
+ w.and_not{|y| y.or("x = ?", 1).or("x = ?", 2) }
+
+ assert_equal("NOT ((x = 1) OR (x = 2))", w.to_s)
+ end
+
+
+ def test__where__and_not__with_prefix__should_work
+ w = Where.new
+
+ w.and_not "x = ?", 1
+ w.and_not "y = ?", 1
+
+ assert_equal("NOT (x = 1) AND NOT (y = 1)", w.to_s)
+ end
+
+ def test__where__or_not__no_perfix__should_work
+ w = Where.new
+
+ w.or_not{|y| y.or("x = ?", 1).or("x = ?", 2) }
+
+ assert_equal("NOT ((x = 1) OR (x = 2))", w.to_s)
+ end
+
+
+ def test__where__or_not__with_prefix__should_work
+ w = Where.new
+
+ w.or_not "x = ?", 1
+ w.or_not "y = ?", 1
+
+ assert_equal("NOT (x = 1) OR NOT (y = 1)", w.to_s)
+ end
+
+
def test__where_new_chained_or
assert_equal("(x=1) OR (x=2)", Where.new("x=1").or("x=2").to_sql)
end
def test__where_new_chained_and
assert_equal("(x=1) AND (x=2)", Where.new("x=1").and("x=2").to_sql)
end
def test__where_and_where
where = Where.new
where.and Where.new("x=1")
assert_equal("((x=1))", where.to_s)
end
def test__where_or_where
where = Where.new
where.or Where.new("x=1")
assert_equal("((x=1))", where.to_s)
end
end
\ No newline at end of file
|
timcharper/railswhere
|
21360ae236919bd5a0965ad4711c678d35a0784f
|
bugfix with where.and Where.new
|
diff --git a/lib/where.rb b/lib/where.rb
index 776e38f..af6b21c 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,156 +1,156 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
# # Sweet chaining action!
class Where
# Constructs a new where clause
#
# optionally, you can provide a criteria, like the following:
#
# Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
def initialize(criteria=nil, *params, &block)
@clauses=Array.new
self.and(criteria, *params) unless criteria.nil?
yield(self) if block_given?
end
def initialize_copy(from)
@clauses = from.instance_variable_get("@clauses").clone
end
# Appends an <b>and</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.and("name = ?", "Tim O'brien")
# where.to_s
#
# # => "(name = 'Tim O''brien')
def and(*params, &block)
if block_given?
yield(w = Where.new)
@clauses << Clause.new(w)
else
@clauses << Clause.new(params) unless params.blank?
end
self
end
alias << and
# Appends an <b>or</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.or("name = ?", "Tim O'brien")
# where.or("name = ?", "Tim O'neal")
# where.to_s
#
# # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
def or(*params, &block)
if block_given?
yield(w = Where.new)
@clauses << Clause.new(w, true)
else
@clauses << Clause.new(params, true) unless params.blank?
end
self
end
# Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
@clauses.each_index{|index|
omit_clause = (index==0)
output << @clauses[index].to_s(omit_clause) # Omit the clause if index=0
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
output.empty? ? nil : output
end
end
alias :to_sql :to_s
# Determines if any clauses have been added.
#
# where = Where.new
# where.blank?
# # => true
#
# where.and(nil)
# where.blank?
# # => true
#
# where.and(Where.new(nil))
# where.blank?
# # => true
#
# where.and("name=1")
# where.blank?
# # => false
def blank?
@clauses.empty?
end
alias :empty? :blank?
# Used internally to +Where+. You shouldn't have any reason to interact with this class.
class Clause
def initialize(criteria, is_or = false)
@is_or=is_or
- if criteria.class==Array # if it's an array, sanitize it
+ if criteria.class==Array && criteria.length>1 # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_clause=false)
if omit_clause
"(#{@criteria})"
else
" #{@is_or ? 'OR' : 'AND'} (#{@criteria})"
end
end
end
end
diff --git a/test/functional/where_test.rb b/test/functional/where_test.rb
index 4e492fa..33ea2d0 100644
--- a/test/functional/where_test.rb
+++ b/test/functional/where_test.rb
@@ -1,47 +1,59 @@
require File.join(File.dirname(__FILE__), '../test_helper.rb')
class WhereTest < Test::Unit::TestCase
def test__where_new__block__should_yield
assert_equal("(hi = '1')", Where.new {|w| w.and("hi = ?", "1")}.to_s)
end
def test__where_or_block__should_work
where = Where.new {|w|
w.or {|y|
y.or "x = ?", 1
y.or "x = ?", 2
}
w.or {|y|
y.or "y = ?", 1
y.or "y = ?", 2
}
}.to_s
assert_equal("((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))", where.to_s)
end
def test__where_and_block__should_work
where = Where.new {|w|
w.and {|y|
y.or "x = ?", 1
y.or "x = ?", 2
}
w.and {|y|
y.or "y = ?", 1
y.or "y = ?", 2
}
}.to_s
assert_equal("((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))", where.to_s)
end
def test__where_new_chained_or
assert_equal("(x=1) OR (x=2)", Where.new("x=1").or("x=2").to_sql)
end
def test__where_new_chained_and
assert_equal("(x=1) AND (x=2)", Where.new("x=1").and("x=2").to_sql)
end
+
+ def test__where_and_where
+ where = Where.new
+ where.and Where.new("x=1")
+ assert_equal("((x=1))", where.to_s)
+ end
+
+ def test__where_or_where
+ where = Where.new
+ where.or Where.new("x=1")
+ assert_equal("((x=1))", where.to_s)
+ end
end
\ No newline at end of file
|
timcharper/railswhere
|
dab4427315b196d7f147206102d6f25625b29800
|
now with block support
|
diff --git a/lib/where.rb b/lib/where.rb
index 3f9d234..776e38f 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,142 +1,156 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
# # Sweet chaining action!
class Where
# Constructs a new where clause
#
# optionally, you can provide a criteria, like the following:
#
# Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
- def initialize(criteria=nil, *params)
+ def initialize(criteria=nil, *params, &block)
@clauses=Array.new
self.and(criteria, *params) unless criteria.nil?
+
+ yield(self) if block_given?
+ end
+
+ def initialize_copy(from)
+ @clauses = from.instance_variable_get("@clauses").clone
end
# Appends an <b>and</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.and("name = ?", "Tim O'brien")
# where.to_s
#
# # => "(name = 'Tim O''brien')
- def and(criteria, *params)
- criteria = [criteria] + params unless params.empty?
- @clauses << Clause.new(criteria) unless criteria.blank?
+ def and(*params, &block)
+ if block_given?
+ yield(w = Where.new)
+ @clauses << Clause.new(w)
+ else
+ @clauses << Clause.new(params) unless params.blank?
+ end
self
end
alias << and
# Appends an <b>or</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.or("name = ?", "Tim O'brien")
# where.or("name = ?", "Tim O'neal")
# where.to_s
#
# # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
- def or(criteria, *params)
- criteria = [criteria] + params unless params.empty?
- @clauses << Clause.new(criteria, true) unless criteria.blank?
+ def or(*params, &block)
+ if block_given?
+ yield(w = Where.new)
+ @clauses << Clause.new(w, true)
+ else
+ @clauses << Clause.new(params, true) unless params.blank?
+ end
self
end
# Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
@clauses.each_index{|index|
omit_clause = (index==0)
output << @clauses[index].to_s(omit_clause) # Omit the clause if index=0
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
output.empty? ? nil : output
end
end
alias :to_sql :to_s
# Determines if any clauses have been added.
#
# where = Where.new
# where.blank?
# # => true
#
# where.and(nil)
# where.blank?
# # => true
#
# where.and(Where.new(nil))
# where.blank?
# # => true
#
# where.and("name=1")
# where.blank?
# # => false
def blank?
@clauses.empty?
end
alias :empty? :blank?
# Used internally to +Where+. You shouldn't have any reason to interact with this class.
class Clause
def initialize(criteria, is_or = false)
@is_or=is_or
if criteria.class==Array # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_clause=false)
if omit_clause
"(#{@criteria})"
else
" #{@is_or ? 'OR' : 'AND'} (#{@criteria})"
end
end
end
end
diff --git a/test/db/test.db b/test/db/test.db
new file mode 100644
index 0000000..e69de29
diff --git a/test/functional/where_test.rb b/test/functional/where_test.rb
new file mode 100644
index 0000000..4e492fa
--- /dev/null
+++ b/test/functional/where_test.rb
@@ -0,0 +1,47 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class WhereTest < Test::Unit::TestCase
+ def test__where_new__block__should_yield
+ assert_equal("(hi = '1')", Where.new {|w| w.and("hi = ?", "1")}.to_s)
+ end
+
+ def test__where_or_block__should_work
+ where = Where.new {|w|
+ w.or {|y|
+ y.or "x = ?", 1
+ y.or "x = ?", 2
+ }
+
+ w.or {|y|
+ y.or "y = ?", 1
+ y.or "y = ?", 2
+ }
+ }.to_s
+
+ assert_equal("((x = 1) OR (x = 2)) OR ((y = 1) OR (y = 2))", where.to_s)
+ end
+
+ def test__where_and_block__should_work
+ where = Where.new {|w|
+ w.and {|y|
+ y.or "x = ?", 1
+ y.or "x = ?", 2
+ }
+
+ w.and {|y|
+ y.or "y = ?", 1
+ y.or "y = ?", 2
+ }
+ }.to_s
+
+ assert_equal("((x = 1) OR (x = 2)) AND ((y = 1) OR (y = 2))", where.to_s)
+ end
+
+ def test__where_new_chained_or
+ assert_equal("(x=1) OR (x=2)", Where.new("x=1").or("x=2").to_sql)
+ end
+
+ def test__where_new_chained_and
+ assert_equal("(x=1) AND (x=2)", Where.new("x=1").and("x=2").to_sql)
+ end
+end
\ No newline at end of file
diff --git a/test/test_helper.rb b/test/test_helper.rb
new file mode 100644
index 0000000..e3ef874
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,22 @@
+require "rubygems"
+
+require 'test/unit'
+require 'active_record'
+
+
+ActiveRecord::Base.establish_connection(
+ :adapter => "sqlite3",
+ :database => File.join(File.dirname(__FILE__), "db/test.db")
+)
+
+for file in ["../lib/where.rb"]
+ require File.expand_path(File.join(File.dirname(__FILE__), file))
+end
+
+def dbg; require 'ruby-debug'; debugger; end
+
+class Object
+ def to_regexp
+ is_a?(Regexp) ? self : Regexp.new(Regexp.escape(self.to_s))
+ end
+end
\ No newline at end of file
|
timcharper/railswhere
|
e18b01e8a80042270fb42909d325eacfceafd42f
|
blank where clauses were causing sql error
|
diff --git a/lib/where.rb b/lib/where.rb
index 64f3ec6..3f9d234 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,142 +1,142 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
# # Sweet chaining action!
class Where
# Constructs a new where clause
#
# optionally, you can provide a criteria, like the following:
#
# Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
def initialize(criteria=nil, *params)
@clauses=Array.new
self.and(criteria, *params) unless criteria.nil?
end
# Appends an <b>and</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.and("name = ?", "Tim O'brien")
# where.to_s
#
# # => "(name = 'Tim O''brien')
def and(criteria, *params)
criteria = [criteria] + params unless params.empty?
@clauses << Clause.new(criteria) unless criteria.blank?
self
end
alias << and
# Appends an <b>or</b> expression to your where clause
#
# Example:
#
# where = Where.new
# where.or("name = ?", "Tim O'brien")
# where.or("name = ?", "Tim O'neal")
# where.to_s
#
# # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
def or(criteria, *params)
criteria = [criteria] + params unless params.empty?
@clauses << Clause.new(criteria, true) unless criteria.blank?
self
end
# Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
@clauses.each_index{|index|
omit_clause = (index==0)
output << @clauses[index].to_s(omit_clause) # Omit the clause if index=0
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
- output
+ output.empty? ? nil : output
end
end
alias :to_sql :to_s
# Determines if any clauses have been added.
#
# where = Where.new
# where.blank?
# # => true
#
# where.and(nil)
# where.blank?
# # => true
#
# where.and(Where.new(nil))
# where.blank?
# # => true
#
# where.and("name=1")
# where.blank?
# # => false
def blank?
@clauses.empty?
end
alias :empty? :blank?
# Used internally to +Where+. You shouldn't have any reason to interact with this class.
class Clause
def initialize(criteria, is_or = false)
@is_or=is_or
if criteria.class==Array # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_clause=false)
if omit_clause
"(#{@criteria})"
else
" #{@is_or ? 'OR' : 'AND'} (#{@criteria})"
end
end
end
end
|
timcharper/railswhere
|
c752092dfa8b2117cd4b33151cc0cb2fb4ed8197
|
rdoc documentation
|
diff --git a/README b/README
index a6d462f..ac79f98 100644
--- a/README
+++ b/README
@@ -1,54 +1,33 @@
-=RailsWhere=
-==A Rails Active Record Where clause generator==
-By Tim Harper (Tim - C - Harper at gmail dot com)
-
-
-Easily and safely construct where clause queries for some of the most
-complicated examples, including nested and/or query expressions. Simple to use,
-fast, lightweight, and secure (uses rails sanitize_sql method to prevent SQL
-injection)
-
-It's especially useful generating search queries.
-
-
-
-It can:
-
-===Generating SQL===
-
-{{{
-sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
-# returns (x=5) and ( ( x=6 ) or ( x=7 ) )
-}}}
-
-===Building a complicated where clause made easy===
-
-{{{
-def get_search_query_string
-
- where = Where.new
- where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
- where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
-
- status_where = Where.new
- for status in params[search_statuses].split(',')
- status_where.or 'status=?', status
- end
- where.and status_where unless status_where.blank?
-
- where.to_s
-end
-
+= Where clause generator
+== Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
+
+<b>Usage example</b>
+
+=== Returning SQL
+
+ sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
+ # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
+
+=== Building a complicated where clause made easy
+
+ def get_search_query_string
+
+ where = Where.new
+ where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
+ where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
+
+ status_where = Where.new
+ for status in params[search_statuses].split(',')
+ status_where.or 'status=?', status
+ end
+ where.and status_where unless status_where.blank?
+
+ where.to_s
+ end
+
User.find(:all, :conditions => get_search_query_string)
-
-}}}
-
-===Inline===
-{{{
-
- User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
-
-}}}
-
-==Installation==
-
+
+=== Inline
+
+ User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
+ # Sweet chaining action!
diff --git a/doc/classes/Where.html b/doc/classes/Where.html
new file mode 100644
index 0000000..5556a7c
--- /dev/null
+++ b/doc/classes/Where.html
@@ -0,0 +1,349 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Class: Where</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
+ <script type="text/javascript">
+ // <![CDATA[
+
+ function popupCode( url ) {
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
+ }
+
+ function toggleCode( id ) {
+ if ( document.getElementById )
+ elem = document.getElementById( id );
+ else if ( document.all )
+ elem = eval( "document.all." + id );
+ else
+ return false;
+
+ elemStyle = elem.style;
+
+ if ( elemStyle.display != "block" ) {
+ elemStyle.display = "block"
+ } else {
+ elemStyle.display = "none"
+ }
+
+ return true;
+ }
+
+ // Make codeblocks hidden by default
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
+
+ // ]]>
+ </script>
+
+</head>
+<body>
+
+
+
+ <div id="classHeader">
+ <table class="header-table">
+ <tr class="top-aligned-row">
+ <td><strong>Class</strong></td>
+ <td class="class-name-in-header">Where</td>
+ </tr>
+ <tr class="top-aligned-row">
+ <td><strong>In:</strong></td>
+ <td>
+ <a href="../files/lib/where_rb.html">
+ lib/where.rb
+ </a>
+ <br />
+ </td>
+ </tr>
+
+ <tr class="top-aligned-row">
+ <td><strong>Parent:</strong></td>
+ <td>
+ Object
+ </td>
+ </tr>
+ </table>
+ </div>
+ <!-- banner header -->
+
+ <div id="bodyContent">
+
+
+
+ <div id="contextContent">
+
+ <div id="description">
+ <h1><a href="Where.html">Where</a> clause generator</h1>
+<h2>Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )</h2>
+<p>
+<b>Usage example</b>
+</p>
+<h3>Returning SQL</h3>
+<pre>
+ sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
+ # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
+</pre>
+<h3>Building a complicated where clause made easy</h3>
+<pre>
+ def get_search_query_string
+
+ where = Where.new
+ where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
+ where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
+
+ status_where = Where.new
+ for status in params[search_statuses].split(',')
+ status_where.or 'status=?', status
+ end
+ where.and status_where unless status_where.blank?
+
+ where.to_s
+ end
+</pre>
+<p>
+User.find(:all, :conditions => get_search_query_string)
+</p>
+<h3>Inline</h3>
+<pre>
+ User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
+ # Sweet chaining action!
+</pre>
+
+ </div>
+
+
+ </div>
+
+ <div id="method-list">
+ <h3 class="section-bar">Methods</h3>
+
+ <div class="name-list">
+ <a href="#M000003">Where#<<</a>
+ <a href="#M000002">Where#and</a>
+ <a href="#M000007">Where#blank?</a>
+ <a href="#M000008">Where#empty?</a>
+ <a href="#M000001">Where::new</a>
+ <a href="#M000004">Where#or</a>
+ <a href="#M000005">Where#to_s</a>
+ <a href="#M000006">Where#to_sql</a>
+ </div>
+ </div>
+
+ </div>
+
+
+ <!-- if includes -->
+
+ <div id="section">
+
+ <div id="class-list">
+ <h3 class="section-bar">Classes and Modules</h3>
+
+ Class <a href="Where/Clause.html" class="link">Where::Clause</a><br />
+
+ </div>
+
+
+
+
+
+
+
+ <!-- if method_list -->
+ <div id="methods">
+ <h3 class="section-bar">Public Class methods</h3>
+
+ <div id="method-M000001" class="method-detail">
+ <a name="M000001"></a>
+
+ <div class="method-heading">
+ <a href="Where.src/M000001.html" target="Code" class="method-signature"
+ onclick="popupCode('Where.src/M000001.html');return false;">
+ <span class="method-name">new</span><span class="method-args">(criteria=nil, *params)</span>
+ </a>
+ </div>
+
+ <div class="method-description">
+ <p>
+Constructs a <a href="Where.html#M000001">new</a> where clause
+</p>
+<p>
+optionally, you can provide a criteria, like the following:
+</p>
+<pre>
+ Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
+</pre>
+ </div>
+ </div>
+
+ <h3 class="section-bar">Public Instance methods</h3>
+
+ <div id="method-M000003" class="method-detail">
+ <a name="M000003"></a>
+
+ <div class="method-heading">
+ <span class="method-name"><<</span><span class="method-args">(criteria, *params)</span>
+ </div>
+
+ <div class="method-description">
+ <p>
+Alias for <a href="Where.html#M000002">and</a>
+</p>
+ </div>
+ </div>
+
+ <div id="method-M000002" class="method-detail">
+ <a name="M000002"></a>
+
+ <div class="method-heading">
+ <a href="Where.src/M000002.html" target="Code" class="method-signature"
+ onclick="popupCode('Where.src/M000002.html');return false;">
+ <span class="method-name">and</span><span class="method-args">(criteria, *params)</span>
+ </a>
+ </div>
+
+ <div class="method-description">
+ <p>
+Appends an <b><a href="Where.html#M000002">and</a></b> expression to your
+where clause
+</p>
+<p>
+Example:
+</p>
+<pre>
+ where = Where.new
+ where.and("name = ?", "Tim O'brien")
+ where.to_s
+
+ # => "(name = 'Tim O''brien')
+</pre>
+ </div>
+ </div>
+
+ <div id="method-M000007" class="method-detail">
+ <a name="M000007"></a>
+
+ <div class="method-heading">
+ <a href="Where.src/M000007.html" target="Code" class="method-signature"
+ onclick="popupCode('Where.src/M000007.html');return false;">
+ <span class="method-name">blank?</span><span class="method-args">()</span>
+ </a>
+ </div>
+
+ <div class="method-description">
+ <p>
+Determines if any clauses have been added.
+</p>
+<pre>
+ where = Where.new
+ where.blank?
+ # => true
+
+ where.and(nil)
+ where.blank?
+ # => true
+
+ where.and(Where.new(nil))
+ where.blank?
+ # => true
+
+ where.and("name=1")
+ where.blank?
+ # => false
+</pre>
+ </div>
+ </div>
+
+ <div id="method-M000008" class="method-detail">
+ <a name="M000008"></a>
+
+ <div class="method-heading">
+ <span class="method-name">empty?</span><span class="method-args">()</span>
+ </div>
+
+ <div class="method-description">
+ <p>
+Alias for blank?
+</p>
+ </div>
+ </div>
+
+ <div id="method-M000004" class="method-detail">
+ <a name="M000004"></a>
+
+ <div class="method-heading">
+ <a href="Where.src/M000004.html" target="Code" class="method-signature"
+ onclick="popupCode('Where.src/M000004.html');return false;">
+ <span class="method-name">or</span><span class="method-args">(criteria, *params)</span>
+ </a>
+ </div>
+
+ <div class="method-description">
+ <p>
+Appends an <b><a href="Where.html#M000004">or</a></b> expression to your
+where clause
+</p>
+<p>
+Example:
+</p>
+<pre>
+ where = Where.new
+ where.or("name = ?", "Tim O'brien")
+ where.or("name = ?", "Tim O'neal")
+ where.to_s
+
+ # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
+</pre>
+ </div>
+ </div>
+
+ <div id="method-M000005" class="method-detail">
+ <a name="M000005"></a>
+
+ <div class="method-heading">
+ <a href="Where.src/M000005.html" target="Code" class="method-signature"
+ onclick="popupCode('Where.src/M000005.html');return false;">
+ <span class="method-name">to_s</span><span class="method-args">(format=nil)</span>
+ </a>
+ </div>
+
+ <div class="method-description">
+ <p>
+Converts the where clause to a SQL string.
+</p>
+ </div>
+ </div>
+
+ <div id="method-M000006" class="method-detail">
+ <a name="M000006"></a>
+
+ <div class="method-heading">
+ <span class="method-name">to_sql</span><span class="method-args">(format=nil)</span>
+ </div>
+
+ <div class="method-description">
+ <p>
+Alias for <a href="Where.html#M000005">to_s</a>
+</p>
+ </div>
+ </div>
+
+
+ </div>
+
+
+ </div>
+
+
+<div id="validator-badges">
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/classes/Where.src/M000001.html b/doc/classes/Where.src/M000001.html
new file mode 100644
index 0000000..1b19c85
--- /dev/null
+++ b/doc/classes/Where.src/M000001.html
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head>
+ <title>new (Where)</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
+</head>
+<body class="standalone-code">
+ <pre><span class="ruby-comment cmt"># File lib/where.rb, line 42</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">criteria</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">params</span>)
+ <span class="ruby-ivar">@clauses</span>=<span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
+
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">and</span>(<span class="ruby-identifier">criteria</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">params</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">criteria</span>.<span class="ruby-identifier">nil?</span>
+ <span class="ruby-keyword kw">end</span></pre>
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/classes/Where.src/M000002.html b/doc/classes/Where.src/M000002.html
new file mode 100644
index 0000000..f3d27e4
--- /dev/null
+++ b/doc/classes/Where.src/M000002.html
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head>
+ <title>and (Where)</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
+</head>
+<body class="standalone-code">
+ <pre><span class="ruby-comment cmt"># File lib/where.rb, line 57</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">and</span>(<span class="ruby-identifier">criteria</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">params</span>)
+ <span class="ruby-identifier">criteria</span> = [<span class="ruby-identifier">criteria</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">params</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">empty?</span>
+ <span class="ruby-ivar">@clauses</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">Clause</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">criteria</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">criteria</span>.<span class="ruby-identifier">blank?</span>
+ <span class="ruby-keyword kw">self</span>
+ <span class="ruby-keyword kw">end</span></pre>
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/classes/Where.src/M000004.html b/doc/classes/Where.src/M000004.html
new file mode 100644
index 0000000..7731b4c
--- /dev/null
+++ b/doc/classes/Where.src/M000004.html
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head>
+ <title>or (Where)</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
+</head>
+<body class="standalone-code">
+ <pre><span class="ruby-comment cmt"># File lib/where.rb, line 75</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">or</span>(<span class="ruby-identifier">criteria</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">params</span>)
+ <span class="ruby-identifier">criteria</span> = [<span class="ruby-identifier">criteria</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">params</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">empty?</span>
+ <span class="ruby-ivar">@clauses</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">Clause</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">criteria</span>, <span class="ruby-keyword kw">true</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">criteria</span>.<span class="ruby-identifier">blank?</span>
+ <span class="ruby-keyword kw">self</span>
+ <span class="ruby-keyword kw">end</span></pre>
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/classes/Where.src/M000005.html b/doc/classes/Where.src/M000005.html
new file mode 100644
index 0000000..e055020
--- /dev/null
+++ b/doc/classes/Where.src/M000005.html
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head>
+ <title>to_s (Where)</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
+</head>
+<body class="standalone-code">
+ <pre><span class="ruby-comment cmt"># File lib/where.rb, line 82</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>(<span class="ruby-identifier">format</span>=<span class="ruby-keyword kw">nil</span>)
+ <span class="ruby-identifier">output</span>=<span class="ruby-value str">""</span>
+
+ <span class="ruby-ivar">@clauses</span>.<span class="ruby-identifier">each_index</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
+ <span class="ruby-identifier">omit_clause</span> = (<span class="ruby-identifier">index</span><span class="ruby-operator">==</span><span class="ruby-value">0</span>)
+ <span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@clauses</span>[<span class="ruby-identifier">index</span>].<span class="ruby-identifier">to_s</span>(<span class="ruby-identifier">omit_clause</span>) <span class="ruby-comment cmt"># Omit the clause if index=0</span>
+ }
+ <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">format</span>
+ <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:where</span>
+ <span class="ruby-identifier">output</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-value str">""</span> <span class="ruby-operator">:</span> <span class="ruby-node">" WHERE #{output}"</span>
+ <span class="ruby-keyword kw">else</span>
+ <span class="ruby-identifier">output</span>
+ <span class="ruby-keyword kw">end</span>
+ <span class="ruby-keyword kw">end</span></pre>
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/classes/Where.src/M000007.html b/doc/classes/Where.src/M000007.html
new file mode 100644
index 0000000..8ba96c4
--- /dev/null
+++ b/doc/classes/Where.src/M000007.html
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head>
+ <title>blank? (Where)</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
+</head>
+<body class="standalone-code">
+ <pre><span class="ruby-comment cmt"># File lib/where.rb, line 116</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">blank?</span>
+ <span class="ruby-ivar">@clauses</span>.<span class="ruby-identifier">empty?</span>
+ <span class="ruby-keyword kw">end</span></pre>
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/classes/Where/Clause.html b/doc/classes/Where/Clause.html
new file mode 100644
index 0000000..f4218b6
--- /dev/null
+++ b/doc/classes/Where/Clause.html
@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Class: Where::Clause</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
+ <script type="text/javascript">
+ // <![CDATA[
+
+ function popupCode( url ) {
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
+ }
+
+ function toggleCode( id ) {
+ if ( document.getElementById )
+ elem = document.getElementById( id );
+ else if ( document.all )
+ elem = eval( "document.all." + id );
+ else
+ return false;
+
+ elemStyle = elem.style;
+
+ if ( elemStyle.display != "block" ) {
+ elemStyle.display = "block"
+ } else {
+ elemStyle.display = "none"
+ }
+
+ return true;
+ }
+
+ // Make codeblocks hidden by default
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
+
+ // ]]>
+ </script>
+
+</head>
+<body>
+
+
+
+ <div id="classHeader">
+ <table class="header-table">
+ <tr class="top-aligned-row">
+ <td><strong>Class</strong></td>
+ <td class="class-name-in-header">Where::Clause</td>
+ </tr>
+ <tr class="top-aligned-row">
+ <td><strong>In:</strong></td>
+ <td>
+ <a href="../../files/lib/where_rb.html">
+ lib/where.rb
+ </a>
+ <br />
+ </td>
+ </tr>
+
+ <tr class="top-aligned-row">
+ <td><strong>Parent:</strong></td>
+ <td>
+ Object
+ </td>
+ </tr>
+ </table>
+ </div>
+ <!-- banner header -->
+
+ <div id="bodyContent">
+
+
+
+ <div id="contextContent">
+
+ <div id="description">
+ <p>
+Used internally to <tt><a href="../Where.html">Where</a></tt>. You
+shouldn‘t have any reason to interact with this class.
+</p>
+
+ </div>
+
+
+ </div>
+
+ <div id="method-list">
+ <h3 class="section-bar">Methods</h3>
+
+ <div class="name-list">
+ <a href="#M000009">Clause::new</a>
+ <a href="#M000010">Clause#to_s</a>
+ </div>
+ </div>
+
+ </div>
+
+
+ <!-- if includes -->
+
+ <div id="section">
+
+
+
+
+
+
+
+
+ <!-- if method_list -->
+ <div id="methods">
+ <h3 class="section-bar">Public Class methods</h3>
+
+ <div id="method-M000009" class="method-detail">
+ <a name="M000009"></a>
+
+ <div class="method-heading">
+ <a href="Clause.src/M000009.html" target="Code" class="method-signature"
+ onclick="popupCode('Clause.src/M000009.html');return false;">
+ <span class="method-name">new</span><span class="method-args">(criteria, is_or = false)</span>
+ </a>
+ </div>
+
+ <div class="method-description">
+ </div>
+ </div>
+
+ <h3 class="section-bar">Public Instance methods</h3>
+
+ <div id="method-M000010" class="method-detail">
+ <a name="M000010"></a>
+
+ <div class="method-heading">
+ <a href="Clause.src/M000010.html" target="Code" class="method-signature"
+ onclick="popupCode('Clause.src/M000010.html');return false;">
+ <span class="method-name">to_s</span><span class="method-args">(omit_clause=false)</span>
+ </a>
+ </div>
+
+ <div class="method-description">
+ </div>
+ </div>
+
+
+ </div>
+
+
+ </div>
+
+
+<div id="validator-badges">
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/classes/Where/Clause.src/M000009.html b/doc/classes/Where/Clause.src/M000009.html
new file mode 100644
index 0000000..b838ce3
--- /dev/null
+++ b/doc/classes/Where/Clause.src/M000009.html
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head>
+ <title>new (Where::Clause)</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
+</head>
+<body class="standalone-code">
+ <pre><span class="ruby-comment cmt"># File lib/where.rb, line 124</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">criteria</span>, <span class="ruby-identifier">is_or</span> = <span class="ruby-keyword kw">false</span>)
+ <span class="ruby-ivar">@is_or</span>=<span class="ruby-identifier">is_or</span>
+
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">criteria</span>.<span class="ruby-identifier">class</span><span class="ruby-operator">==</span><span class="ruby-constant">Array</span> <span class="ruby-comment cmt"># if it's an array, sanitize it</span>
+ <span class="ruby-ivar">@criteria</span> = <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:sanitize_sql</span>, <span class="ruby-identifier">criteria</span>)
+ <span class="ruby-keyword kw">else</span>
+ <span class="ruby-ivar">@criteria</span> = <span class="ruby-identifier">criteria</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-comment cmt"># otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need</span>
+ <span class="ruby-keyword kw">end</span>
+ <span class="ruby-keyword kw">end</span></pre>
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/classes/Where/Clause.src/M000010.html b/doc/classes/Where/Clause.src/M000010.html
new file mode 100644
index 0000000..2a610a7
--- /dev/null
+++ b/doc/classes/Where/Clause.src/M000010.html
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head>
+ <title>to_s (Where::Clause)</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
+</head>
+<body class="standalone-code">
+ <pre><span class="ruby-comment cmt"># File lib/where.rb, line 134</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>(<span class="ruby-identifier">omit_clause</span>=<span class="ruby-keyword kw">false</span>)
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">omit_clause</span>
+ <span class="ruby-node">"(#{@criteria})"</span>
+ <span class="ruby-keyword kw">else</span>
+ <span class="ruby-node">" #{@is_or ? 'OR' : 'AND'} (#{@criteria})"</span>
+ <span class="ruby-keyword kw">end</span>
+ <span class="ruby-keyword kw">end</span></pre>
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/created.rid b/doc/created.rid
new file mode 100644
index 0000000..3c4f996
--- /dev/null
+++ b/doc/created.rid
@@ -0,0 +1 @@
+Tue May 15 15:44:54 -0600 2007
diff --git a/doc/files/README.html b/doc/files/README.html
new file mode 100644
index 0000000..127eb46
--- /dev/null
+++ b/doc/files/README.html
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>File: README</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
+ <script type="text/javascript">
+ // <![CDATA[
+
+ function popupCode( url ) {
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
+ }
+
+ function toggleCode( id ) {
+ if ( document.getElementById )
+ elem = document.getElementById( id );
+ else if ( document.all )
+ elem = eval( "document.all." + id );
+ else
+ return false;
+
+ elemStyle = elem.style;
+
+ if ( elemStyle.display != "block" ) {
+ elemStyle.display = "block"
+ } else {
+ elemStyle.display = "none"
+ }
+
+ return true;
+ }
+
+ // Make codeblocks hidden by default
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
+
+ // ]]>
+ </script>
+
+</head>
+<body>
+
+
+
+ <div id="fileHeader">
+ <h1>README</h1>
+ <table class="header-table">
+ <tr class="top-aligned-row">
+ <td><strong>Path:</strong></td>
+ <td>README
+ </td>
+ </tr>
+ <tr class="top-aligned-row">
+ <td><strong>Last Update:</strong></td>
+ <td>Tue May 15 15:44:07 -0600 2007</td>
+ </tr>
+ </table>
+ </div>
+ <!-- banner header -->
+
+ <div id="bodyContent">
+
+
+
+ <div id="contextContent">
+
+ <div id="description">
+ <h1><a href="../classes/Where.html">Where</a> clause generator</h1>
+<h2>Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )</h2>
+<p>
+# <b>Usage example</b>
+</p>
+<h3>Returning SQL</h3>
+<p>
+#
+</p>
+<pre>
+ sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
+ # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
+</pre>
+<h3>Building a complicated where clause made easy</h3>
+<pre>
+ def get_search_query_string
+
+ where = Where.new
+ where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
+ where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
+
+ status_where = Where.new
+ for status in params[search_statuses].split(',')
+ status_where.or 'status=?', status
+ end
+ where.and status_where unless status_where.blank?
+
+ where.to_s
+ end
+</pre>
+<p>
+User.find(:all, :conditions => get_search_query_string)
+</p>
+<h3>Inline</h3>
+<pre>
+ User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
+ # Sweet chaining action!
+</pre>
+
+ </div>
+
+
+ </div>
+
+
+ </div>
+
+
+ <!-- if includes -->
+
+ <div id="section">
+
+
+
+
+
+
+
+
+ <!-- if method_list -->
+
+
+ </div>
+
+
+<div id="validator-badges">
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/files/init_rb.html b/doc/files/init_rb.html
new file mode 100644
index 0000000..43e80d1
--- /dev/null
+++ b/doc/files/init_rb.html
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>File: init.rb</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
+ <script type="text/javascript">
+ // <![CDATA[
+
+ function popupCode( url ) {
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
+ }
+
+ function toggleCode( id ) {
+ if ( document.getElementById )
+ elem = document.getElementById( id );
+ else if ( document.all )
+ elem = eval( "document.all." + id );
+ else
+ return false;
+
+ elemStyle = elem.style;
+
+ if ( elemStyle.display != "block" ) {
+ elemStyle.display = "block"
+ } else {
+ elemStyle.display = "none"
+ }
+
+ return true;
+ }
+
+ // Make codeblocks hidden by default
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
+
+ // ]]>
+ </script>
+
+</head>
+<body>
+
+
+
+ <div id="fileHeader">
+ <h1>init.rb</h1>
+ <table class="header-table">
+ <tr class="top-aligned-row">
+ <td><strong>Path:</strong></td>
+ <td>init.rb
+ </td>
+ </tr>
+ <tr class="top-aligned-row">
+ <td><strong>Last Update:</strong></td>
+ <td>Sun Apr 22 04:29:33 -0600 2007</td>
+ </tr>
+ </table>
+ </div>
+ <!-- banner header -->
+
+ <div id="bodyContent">
+
+
+
+ <div id="contextContent">
+
+
+ <div id="requires-list">
+ <h3 class="section-bar">Required files</h3>
+
+ <div class="name-list">
+ where.rb
+ </div>
+ </div>
+
+ </div>
+
+
+ </div>
+
+
+ <!-- if includes -->
+
+ <div id="section">
+
+
+
+
+
+
+
+
+ <!-- if method_list -->
+
+
+ </div>
+
+
+<div id="validator-badges">
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/files/lib/where_rb.html b/doc/files/lib/where_rb.html
new file mode 100644
index 0000000..62b117f
--- /dev/null
+++ b/doc/files/lib/where_rb.html
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>File: where.rb</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
+ <script type="text/javascript">
+ // <![CDATA[
+
+ function popupCode( url ) {
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
+ }
+
+ function toggleCode( id ) {
+ if ( document.getElementById )
+ elem = document.getElementById( id );
+ else if ( document.all )
+ elem = eval( "document.all." + id );
+ else
+ return false;
+
+ elemStyle = elem.style;
+
+ if ( elemStyle.display != "block" ) {
+ elemStyle.display = "block"
+ } else {
+ elemStyle.display = "none"
+ }
+
+ return true;
+ }
+
+ // Make codeblocks hidden by default
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
+
+ // ]]>
+ </script>
+
+</head>
+<body>
+
+
+
+ <div id="fileHeader">
+ <h1>where.rb</h1>
+ <table class="header-table">
+ <tr class="top-aligned-row">
+ <td><strong>Path:</strong></td>
+ <td>lib/where.rb
+ </td>
+ </tr>
+ <tr class="top-aligned-row">
+ <td><strong>Last Update:</strong></td>
+ <td>Tue May 15 15:42:56 -0600 2007</td>
+ </tr>
+ </table>
+ </div>
+ <!-- banner header -->
+
+ <div id="bodyContent">
+
+
+
+ <div id="contextContent">
+
+ <div id="description">
+ <h1><a href="../../classes/Where.html">Where</a> clause generator</h1>
+<h2>Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )</h2>
+<p>
+<b>Usage example</b>
+</p>
+<h3>Returning SQL</h3>
+<pre>
+ sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
+ # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
+</pre>
+<h3>Building a complicated where clause made easy</h3>
+<pre>
+ def get_search_query_string
+
+ where = Where.new
+ where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
+ where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
+
+ status_where = Where.new
+ for status in params[search_statuses].split(',')
+ status_where.or 'status=?', status
+ end
+ where.and status_where unless status_where.blank?
+
+ where.to_s
+ end
+</pre>
+<p>
+User.find(:all, :conditions => get_search_query_string)
+</p>
+<h3>Inline</h3>
+<pre>
+ User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
+ # Sweet chaining action!
+</pre>
+
+ </div>
+
+
+ </div>
+
+
+ </div>
+
+
+ <!-- if includes -->
+
+ <div id="section">
+
+
+
+
+
+
+
+
+ <!-- if method_list -->
+
+
+ </div>
+
+
+<div id="validator-badges">
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/fr_class_index.html b/doc/fr_class_index.html
new file mode 100644
index 0000000..722874d
--- /dev/null
+++ b/doc/fr_class_index.html
@@ -0,0 +1,28 @@
+
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+
+ Classes
+
+ -->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Classes</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
+ <base target="docwin" />
+</head>
+<body>
+<div id="index">
+ <h1 class="section-bar">Classes</h1>
+ <div id="index-entries">
+ <a href="classes/Where.html">Where</a><br />
+ <a href="classes/Where/Clause.html">Where::Clause</a><br />
+ </div>
+</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/fr_file_index.html b/doc/fr_file_index.html
new file mode 100644
index 0000000..9f18ef1
--- /dev/null
+++ b/doc/fr_file_index.html
@@ -0,0 +1,27 @@
+
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+
+ Files
+
+ -->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Files</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
+ <base target="docwin" />
+</head>
+<body>
+<div id="index">
+ <h1 class="section-bar">Files</h1>
+ <div id="index-entries">
+ <a href="files/lib/where_rb.html">lib/where.rb</a><br />
+ </div>
+</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/fr_method_index.html b/doc/fr_method_index.html
new file mode 100644
index 0000000..4f0f9d9
--- /dev/null
+++ b/doc/fr_method_index.html
@@ -0,0 +1,36 @@
+
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+
+ Methods
+
+ -->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Methods</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
+ <base target="docwin" />
+</head>
+<body>
+<div id="index">
+ <h1 class="section-bar">Methods</h1>
+ <div id="index-entries">
+ <a href="classes/Where.html#M000003"><< (Where)</a><br />
+ <a href="classes/Where.html#M000002">and (Where)</a><br />
+ <a href="classes/Where.html#M000007">blank? (Where)</a><br />
+ <a href="classes/Where.html#M000008">empty? (Where)</a><br />
+ <a href="classes/Where/Clause.html#M000009">new (Where::Clause)</a><br />
+ <a href="classes/Where.html#M000001">new (Where)</a><br />
+ <a href="classes/Where.html#M000004">or (Where)</a><br />
+ <a href="classes/Where.html#M000005">to_s (Where)</a><br />
+ <a href="classes/Where/Clause.html#M000010">to_s (Where::Clause)</a><br />
+ <a href="classes/Where.html#M000006">to_sql (Where)</a><br />
+ </div>
+</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/index.html b/doc/index.html
new file mode 100644
index 0000000..4f39556
--- /dev/null
+++ b/doc/index.html
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
+
+<!--
+
+ RDoc Documentation
+
+ -->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>RDoc Documentation</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+</head>
+<frameset rows="20%, 80%">
+ <frameset cols="25%,35%,45%">
+ <frame src="fr_file_index.html" title="Files" name="Files" />
+ <frame src="fr_class_index.html" name="Classes" />
+ <frame src="fr_method_index.html" name="Methods" />
+ </frameset>
+ <frame src="files/lib/where_rb.html" name="docwin" />
+</frameset>
+</html>
\ No newline at end of file
diff --git a/doc/rdoc-style.css b/doc/rdoc-style.css
new file mode 100644
index 0000000..fbf7326
--- /dev/null
+++ b/doc/rdoc-style.css
@@ -0,0 +1,208 @@
+
+body {
+ font-family: Verdana,Arial,Helvetica,sans-serif;
+ font-size: 90%;
+ margin: 0;
+ margin-left: 40px;
+ padding: 0;
+ background: white;
+}
+
+h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
+h1 { font-size: 150%; }
+h2,h3,h4 { margin-top: 1em; }
+
+a { background: #eef; color: #039; text-decoration: none; }
+a:hover { background: #039; color: #eef; }
+
+/* Override the base stylesheet's Anchor inside a table cell */
+td > a {
+ background: transparent;
+ color: #039;
+ text-decoration: none;
+}
+
+/* and inside a section title */
+.section-title > a {
+ background: transparent;
+ color: #eee;
+ text-decoration: none;
+}
+
+/* === Structural elements =================================== */
+
+div#index {
+ margin: 0;
+ margin-left: -40px;
+ padding: 0;
+ font-size: 90%;
+}
+
+
+div#index a {
+ margin-left: 0.7em;
+}
+
+div#index .section-bar {
+ margin-left: 0px;
+ padding-left: 0.7em;
+ background: #ccc;
+ font-size: small;
+}
+
+
+div#classHeader, div#fileHeader {
+ width: auto;
+ color: white;
+ padding: 0.5em 1.5em 0.5em 1.5em;
+ margin: 0;
+ margin-left: -40px;
+ border-bottom: 3px solid #006;
+}
+
+div#classHeader a, div#fileHeader a {
+ background: inherit;
+ color: white;
+}
+
+div#classHeader td, div#fileHeader td {
+ background: inherit;
+ color: white;
+}
+
+
+div#fileHeader {
+ background: #057;
+}
+
+div#classHeader {
+ background: #048;
+}
+
+
+.class-name-in-header {
+ font-size: 180%;
+ font-weight: bold;
+}
+
+
+div#bodyContent {
+ padding: 0 1.5em 0 1.5em;
+}
+
+div#description {
+ padding: 0.5em 1.5em;
+ background: #efefef;
+ border: 1px dotted #999;
+}
+
+div#description h1,h2,h3,h4,h5,h6 {
+ color: #125;;
+ background: transparent;
+}
+
+div#validator-badges {
+ text-align: center;
+}
+div#validator-badges img { border: 0; }
+
+div#copyright {
+ color: #333;
+ background: #efefef;
+ font: 0.75em sans-serif;
+ margin-top: 5em;
+ margin-bottom: 0;
+ padding: 0.5em 2em;
+}
+
+
+/* === Classes =================================== */
+
+table.header-table {
+ color: white;
+ font-size: small;
+}
+
+.type-note {
+ font-size: small;
+ color: #DEDEDE;
+}
+
+.xxsection-bar {
+ background: #eee;
+ color: #333;
+ padding: 3px;
+}
+
+.section-bar {
+ color: #333;
+ border-bottom: 1px solid #999;
+ margin-left: -20px;
+}
+
+
+.section-title {
+ background: #79a;
+ color: #eee;
+ padding: 3px;
+ margin-top: 2em;
+ margin-left: -30px;
+ border: 1px solid #999;
+}
+
+.top-aligned-row { vertical-align: top }
+.bottom-aligned-row { vertical-align: bottom }
+
+/* --- Context section classes ----------------------- */
+
+.context-row { }
+.context-item-name { font-family: monospace; font-weight: bold; color: black; }
+.context-item-value { font-size: small; color: #448; }
+.context-item-desc { color: #333; padding-left: 2em; }
+
+/* --- Method classes -------------------------- */
+.method-detail {
+ background: #efefef;
+ padding: 0;
+ margin-top: 0.5em;
+ margin-bottom: 1em;
+ border: 1px dotted #ccc;
+}
+.method-heading {
+ color: black;
+ background: #ccc;
+ border-bottom: 1px solid #666;
+ padding: 0.2em 0.5em 0 0.5em;
+}
+.method-signature { color: black; background: inherit; }
+.method-name { font-weight: bold; }
+.method-args { font-style: italic; }
+.method-description { padding: 0 0.5em 0 0.5em; }
+
+/* --- Source code sections -------------------- */
+
+a.source-toggle { font-size: 90%; }
+div.method-source-code {
+ background: #262626;
+ color: #ffdead;
+ margin: 1em;
+ padding: 0.5em;
+ border: 1px dashed #999;
+ overflow: hidden;
+}
+
+div.method-source-code pre { color: #ffdead; overflow: hidden; }
+
+/* --- Ruby keyword styles --------------------- */
+
+.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
+
+.ruby-constant { color: #7fffd4; background: transparent; }
+.ruby-keyword { color: #00ffff; background: transparent; }
+.ruby-ivar { color: #eedd82; background: transparent; }
+.ruby-operator { color: #00ffee; background: transparent; }
+.ruby-identifier { color: #ffdead; background: transparent; }
+.ruby-node { color: #ffa07a; background: transparent; }
+.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
+.ruby-regexp { color: #ffa07a; background: transparent; }
+.ruby-value { color: #7fffd4; background: transparent; }
\ No newline at end of file
diff --git a/lib/where.rb b/lib/where.rb
index 4b437c0..64f3ec6 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,97 +1,142 @@
# = Where clause generator
# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
# <b>Usage example</b>
# === Returning SQL
#
# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
#
# === Building a complicated where clause made easy
#
# def get_search_query_string
#
# where = Where.new
# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
#
# status_where = Where.new
# for status in params[search_statuses].split(',')
# status_where.or 'status=?', status
# end
# where.and status_where unless status_where.blank?
#
# where.to_s
# end
#
# User.find(:all, :conditions => get_search_query_string)
#
# === Inline
#
# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
+# # Sweet chaining action!
class Where
-
+ # Constructs a new where clause
+ #
+ # optionally, you can provide a criteria, like the following:
+ #
+ # Where.initialize "joke_title = ?", "He says, 'Under there', to which I reply, 'under where?'"
def initialize(criteria=nil, *params)
@clauses=Array.new
self.and(criteria, *params) unless criteria.nil?
end
+ # Appends an <b>and</b> expression to your where clause
+ #
+ # Example:
+ #
+ # where = Where.new
+ # where.and("name = ?", "Tim O'brien")
+ # where.to_s
+ #
+ # # => "(name = 'Tim O''brien')
def and(criteria, *params)
criteria = [criteria] + params unless params.empty?
@clauses << Clause.new(criteria) unless criteria.blank?
self
end
alias << and
+ # Appends an <b>or</b> expression to your where clause
+ #
+ # Example:
+ #
+ # where = Where.new
+ # where.or("name = ?", "Tim O'brien")
+ # where.or("name = ?", "Tim O'neal")
+ # where.to_s
+ #
+ # # => "(name = 'Tim O''brien') or (name = 'Tim O''neal')"
def or(criteria, *params)
criteria = [criteria] + params unless params.empty?
@clauses << Clause.new(criteria, true) unless criteria.blank?
self
end
+ # Converts the where clause to a SQL string.
def to_s(format=nil)
output=""
@clauses.each_index{|index|
omit_clause = (index==0)
output << @clauses[index].to_s(omit_clause) # Omit the clause if index=0
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
output
end
end
- def empty?
+ alias :to_sql :to_s
+
+ # Determines if any clauses have been added.
+ #
+ # where = Where.new
+ # where.blank?
+ # # => true
+ #
+ # where.and(nil)
+ # where.blank?
+ # # => true
+ #
+ # where.and(Where.new(nil))
+ # where.blank?
+ # # => true
+ #
+ # where.and("name=1")
+ # where.blank?
+ # # => false
+ def blank?
@clauses.empty?
end
- alias :blank? :empty?
+ alias :empty? :blank?
+ # Used internally to +Where+. You shouldn't have any reason to interact with this class.
class Clause
def initialize(criteria, is_or = false)
@is_or=is_or
if criteria.class==Array # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_clause=false)
if omit_clause
"(#{@criteria})"
else
" #{@is_or ? 'OR' : 'AND'} (#{@criteria})"
end
end
end
end
|
timcharper/railswhere
|
7f72b9c95ebd73f71f4f47ecd7388a13a5a993f5
|
getting ready for rdoc documentation
|
diff --git a/lib/where.rb b/lib/where.rb
index cae4415..4b437c0 100644
--- a/lib/where.rb
+++ b/lib/where.rb
@@ -1,69 +1,97 @@
-# Where clause generator
-# Copyright Tim Harper
-# Usage example
-# sql = Where.new(['x=?',5]).or( Where.new('x=5').or('x=7')).to_s
-#
-#
+# = Where clause generator
+# == Author: Tim Harper ( "timseeharperATgmail.seeom".gsub("see", "c").gsub("AT", "@") )
#
+# <b>Usage example</b>
+# === Returning SQL
+#
+# sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
+# # returns (x=5) and ( ( x=6 ) or ( x=7 ) )
+#
+# === Building a complicated where clause made easy
+#
+# def get_search_query_string
+#
+# where = Where.new
+# where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
+# where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
+#
+# status_where = Where.new
+# for status in params[search_statuses].split(',')
+# status_where.or 'status=?', status
+# end
+# where.and status_where unless status_where.blank?
+#
+# where.to_s
+# end
+#
+# User.find(:all, :conditions => get_search_query_string)
+#
+# === Inline
+#
+# User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
+
class Where
+
+
def initialize(criteria=nil, *params)
@clauses=Array.new
self.and(criteria, *params) unless criteria.nil?
end
def and(criteria, *params)
criteria = [criteria] + params unless params.empty?
@clauses << Clause.new(criteria) unless criteria.blank?
self
end
alias << and
def or(criteria, *params)
criteria = [criteria] + params unless params.empty?
@clauses << Clause.new(criteria, true) unless criteria.blank?
self
end
def to_s(format=nil)
output=""
@clauses.each_index{|index|
omit_clause = (index==0)
output << @clauses[index].to_s(omit_clause) # Omit the clause if index=0
}
case format
when :where
output.empty? ? "" : " WHERE #{output}"
else
output
end
end
def empty?
@clauses.empty?
end
- alias :blank? :empty?
+ alias :blank? :empty?
+
class Clause
def initialize(criteria, is_or = false)
@is_or=is_or
if criteria.class==Array # if it's an array, sanitize it
@criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
else
@criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
end
end
def to_s(omit_clause=false)
if omit_clause
"(#{@criteria})"
else
" #{@is_or ? 'OR' : 'AND'} (#{@criteria})"
end
end
end
-end
\ No newline at end of file
+end
|
timcharper/railswhere
|
f78994ba2fd766b26e6a89f7f8ea39891a4c750c
|
Initial import
|
diff --git a/MIT-LISCENSE b/MIT-LISCENSE
new file mode 100644
index 0000000..d4f8dbd
--- /dev/null
+++ b/MIT-LISCENSE
@@ -0,0 +1,20 @@
+All portions Copyright (c) 2007 Tim Harper
+
+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.
diff --git a/README b/README
new file mode 100644
index 0000000..a6d462f
--- /dev/null
+++ b/README
@@ -0,0 +1,54 @@
+=RailsWhere=
+==A Rails Active Record Where clause generator==
+By Tim Harper (Tim - C - Harper at gmail dot com)
+
+
+Easily and safely construct where clause queries for some of the most
+complicated examples, including nested and/or query expressions. Simple to use,
+fast, lightweight, and secure (uses rails sanitize_sql method to prevent SQL
+injection)
+
+It's especially useful generating search queries.
+
+
+
+It can:
+
+===Generating SQL===
+
+{{{
+sql = Where.new('x=?',5).and( Where.new('x=?',6).or('x=?',7)).to_s
+# returns (x=5) and ( ( x=6 ) or ( x=7 ) )
+}}}
+
+===Building a complicated where clause made easy===
+
+{{{
+def get_search_query_string
+
+ where = Where.new
+ where.and('users.first_name like ?', params[:search_first_name] + '%') unless params[:search_first_name].blank?
+ where.and('users.last_name like ?', params[:search_last_name] + '%') unless params[:search_last_name].blank?
+
+ status_where = Where.new
+ for status in params[search_statuses].split(',')
+ status_where.or 'status=?', status
+ end
+ where.and status_where unless status_where.blank?
+
+ where.to_s
+end
+
+User.find(:all, :conditions => get_search_query_string)
+
+}}}
+
+===Inline===
+{{{
+
+ User.find(:all, :conditions => Where.new('first_name like ?', 'Tim').and('last_name like ?', 'Harper') )
+
+}}}
+
+==Installation==
+
diff --git a/init.rb b/init.rb
new file mode 100644
index 0000000..583795b
--- /dev/null
+++ b/init.rb
@@ -0,0 +1,2 @@
+require 'where.rb'
+
diff --git a/lib/where.rb b/lib/where.rb
new file mode 100644
index 0000000..cae4415
--- /dev/null
+++ b/lib/where.rb
@@ -0,0 +1,69 @@
+# Where clause generator
+# Copyright Tim Harper
+# Usage example
+# sql = Where.new(['x=?',5]).or( Where.new('x=5').or('x=7')).to_s
+#
+#
+#
+
+class Where
+ def initialize(criteria=nil, *params)
+ @clauses=Array.new
+
+ self.and(criteria, *params) unless criteria.nil?
+ end
+
+ def and(criteria, *params)
+ criteria = [criteria] + params unless params.empty?
+ @clauses << Clause.new(criteria) unless criteria.blank?
+ self
+ end
+
+ alias << and
+
+ def or(criteria, *params)
+ criteria = [criteria] + params unless params.empty?
+ @clauses << Clause.new(criteria, true) unless criteria.blank?
+ self
+ end
+
+ def to_s(format=nil)
+ output=""
+
+ @clauses.each_index{|index|
+ omit_clause = (index==0)
+ output << @clauses[index].to_s(omit_clause) # Omit the clause if index=0
+ }
+ case format
+ when :where
+ output.empty? ? "" : " WHERE #{output}"
+ else
+ output
+ end
+ end
+
+ def empty?
+ @clauses.empty?
+ end
+
+ alias :blank? :empty?
+ class Clause
+ def initialize(criteria, is_or = false)
+ @is_or=is_or
+
+ if criteria.class==Array # if it's an array, sanitize it
+ @criteria = ActiveRecord::Base.send(:sanitize_sql, criteria)
+ else
+ @criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
+ end
+ end
+
+ def to_s(omit_clause=false)
+ if omit_clause
+ "(#{@criteria})"
+ else
+ " #{@is_or ? 'OR' : 'AND'} (#{@criteria})"
+ end
+ end
+ end
+end
\ No newline at end of file
|
dgl/TwitFolk
|
ba6a8fdda777ba74b9aac57d5b925f93fec5eb0a
|
For tinyurls that aren't very useful just show the original URL.
|
diff --git a/lib/TwitFolk/Client.pm b/lib/TwitFolk/Client.pm
index a76b878..b53e077 100644
--- a/lib/TwitFolk/Client.pm
+++ b/lib/TwitFolk/Client.pm
@@ -1,66 +1,71 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::Client;
use Moose;
use Encode qw(encode_utf8);
use HTML::Entities;
use Mail::SpamAssassin::Util::RegistrarBoundaries;
use TwitFolk::Log;
use URI;
has irc => (isa => "TwitFolk::IRC", is => "ro");
has target => (isa => "Str", is => "ro");
has friends => (isa => "TwitFolk::Friends", is => "ro");
has last_tweets => (isa => "TwitFolk::Last", is => "ro");
sub on_update {
my($self, $update) = @_;
my $screen_name = $update->{user}->{screen_name};
my $nick = $self->friends->lookup_nick($screen_name);
my $text = decode_entities $update->{text};
if($update->{retweeted_status}->{text}) {
$text = "RT \@" . $update->{retweeted_status}->{user}->{screen_name} . ": "
. decode_entities $update->{retweeted_status}->{text};
}
# Skip tweets from people who aren't friends
unless(grep { lc($_) eq lc $screen_name } keys %{$self->friends->friends}) {
debug("Ignoring tweet %s from [%s]", $update->{id}, $screen_name);
return;
}
# Skip tweets directed at others who aren't friends
if ($text =~ /^@([[:alnum:]_]+)/) {
my $other_sn = lc($1);
unless (grep { lc($_) eq $other_sn } keys %{$self->friends->friends}) {
debug("Ignoring reply tweet %s from [%s] to [%s]",
$update->{id}, $screen_name, $other_sn);
return;
}
}
debug("%s/%s: [%s/\@%s] %s", ref $self, $update->{id}, $nick, $screen_name, $text);
if ($text =~ /[\n\r]/) {
debug("%s/%s contains dangerous characters; removing!",
ref $self, $update->{id});
$text =~ s/[\n\r]/ /g;
}
if ($update->{entities}->{urls}) {
for my $url(@{$update->{entities}->{urls}}) {
- my $uri = URI->new($url->{expanded_url});
+ my $full_uri = $url->{expanded_url};
+ my $uri = URI->new($full_uri);
next unless $uri;
my(undef, $domain) = Mail::SpamAssassin::Util::RegistrarBoundaries::split_domain($uri->host);
# Use replacement rather than the given offset, makes doing the
# replacement easier.
- $text =~ s/(\Q$url->{url}\E)/"$1 [" . $domain . "]"/e;
+ if((5 + length $url->{url}) >= length $full_uri) {
+ $text =~ s/\Q$url->{url}\E/$full_uri/;
+ } else {
+ $text =~ s/(\Q$url->{url}\E)/"$1 [" . $domain . "]"/e;
+ }
}
}
$self->irc->notice($self->target, encode_utf8 sprintf("[%s/\@%s] %s",
$nick, $screen_name, $text));
}
1;
|
dgl/TwitFolk
|
84a0dc4df3ae9106349a770f457bd7ed361e3454
|
Show the domain of shortened links
|
diff --git a/README b/README
index ca51878..4f1f4b5 100644
--- a/README
+++ b/README
@@ -1,84 +1,85 @@
TwitFolk - an IRC/Twitter gateway bot
=====================================
Overview
--------
Gate the tweets/dents from a Twitter or Identi.ca account's list of friends
into an IRC channel.
History
-------
Some people in an IRC channel started noticing that conversations kept crossing
over between IRC and Twitter, so they talked about gating each other's tweets
into the channel:
http://wiki.blitzed.org/Channel:bitfolk/Twitter_Bot
Eventually someone quickly knocked a bot together:
http://wiki.blitzed.org/Channel:bitfolk/Twitfolk
Then a couple of other channels started using it.
Pre-requisites
--------------
- Perl (>=5.10)
- Some Perl modules:
- AnyEvent::Twitter::Stream
- AnyEvent::IRC
- Config::Tiny
- Crpyt::SSLeay
- Daemon::Control
- EV
- - HTML::Entities
+ - HTML::Entities
+ - Mail::SpamAssassin::Util::RegistrarBoundaries
- MooseX::Getopt
- - Net::Twitter
+ - Net::Twitter
- Try::Tiny
It might be easiest to use cpanm with a local::lib to use these modules:
wget -qO ~/bin/cpanm cpanmin.us
chmod 755 ~/bin/cpanm
- cpanm --local-lib=./twitfolk-libs Net::Twitter AnyEvent::Twitter::Stream AnyEvent::IRC Daemon::Control MooseX::Getopt Config::Tiny Try::Tiny EV Crypt::SSLeay Module::Refresh
+ cpanm --local-lib=./twitfolk-libs Net::Twitter AnyEvent::Twitter::Stream AnyEvent::IRC Daemon::Control MooseX::Getopt Config::Tiny Try::Tiny EV Crypt::SSLeay Module::Refresh NetAddr::IP Mail::SpamAssassin::Util::RegistrarBoundaries
[wait a rather long time]
Then run with:
bin/twitfolk-init.pl start
-
- (See perldoc Daemon::Control for help on other ways to run it).
+
+ (See perldoc Daemon::Control for help on other ways to run it).
- A twitter.com or identi.ca account
Source
------
You can get it from our Subversion repository:
https://svn.bitfolk.com/repos/twitfolk/
Support
-------
Limited community support is available from the TwitFolk users mailing list:
https://lists.bitfolk.com/mailman/listinfo/twitfolk
Feature suggestions would be great, too.
You can follow TwitFolk development on Identi.ca:
http://identi.ca/twitfolk
which is also gated to Twitter:
http://twitter.com/therealtwitfolk
(The "twitfolk" username was already taken on Twitter; if you own it and want
to give it up, please let us know!)
$Id:README 977 2009-07-26 02:50:08Z andy $
diff --git a/lib/TwitFolk/Client.pm b/lib/TwitFolk/Client.pm
index efdb259..a76b878 100644
--- a/lib/TwitFolk/Client.pm
+++ b/lib/TwitFolk/Client.pm
@@ -1,53 +1,66 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::Client;
use Moose;
-use TwitFolk::Log;
-use HTML::Entities;
use Encode qw(encode_utf8);
+use HTML::Entities;
+use Mail::SpamAssassin::Util::RegistrarBoundaries;
+use TwitFolk::Log;
+use URI;
has irc => (isa => "TwitFolk::IRC", is => "ro");
has target => (isa => "Str", is => "ro");
has friends => (isa => "TwitFolk::Friends", is => "ro");
has last_tweets => (isa => "TwitFolk::Last", is => "ro");
sub on_update {
my($self, $update) = @_;
my $screen_name = $update->{user}->{screen_name};
my $nick = $self->friends->lookup_nick($screen_name);
my $text = decode_entities $update->{text};
if($update->{retweeted_status}->{text}) {
$text = "RT \@" . $update->{retweeted_status}->{user}->{screen_name} . ": "
. decode_entities $update->{retweeted_status}->{text};
}
# Skip tweets from people who aren't friends
unless(grep { lc($_) eq lc $screen_name } keys %{$self->friends->friends}) {
debug("Ignoring tweet %s from [%s]", $update->{id}, $screen_name);
return;
}
# Skip tweets directed at others who aren't friends
if ($text =~ /^@([[:alnum:]_]+)/) {
my $other_sn = lc($1);
unless (grep { lc($_) eq $other_sn } keys %{$self->friends->friends}) {
debug("Ignoring reply tweet %s from [%s] to [%s]",
$update->{id}, $screen_name, $other_sn);
return;
}
}
debug("%s/%s: [%s/\@%s] %s", ref $self, $update->{id}, $nick, $screen_name, $text);
if ($text =~ /[\n\r]/) {
debug("%s/%s contains dangerous characters; removing!",
ref $self, $update->{id});
$text =~ s/[\n\r]/ /g;
}
+ if ($update->{entities}->{urls}) {
+ for my $url(@{$update->{entities}->{urls}}) {
+ my $uri = URI->new($url->{expanded_url});
+ next unless $uri;
+ my(undef, $domain) = Mail::SpamAssassin::Util::RegistrarBoundaries::split_domain($uri->host);
+ # Use replacement rather than the given offset, makes doing the
+ # replacement easier.
+ $text =~ s/(\Q$url->{url}\E)/"$1 [" . $domain . "]"/e;
+ }
+ }
+
$self->irc->notice($self->target, encode_utf8 sprintf("[%s/\@%s] %s",
$nick, $screen_name, $text));
}
1;
|
dgl/TwitFolk
|
b350dfa6bbb7b65954f4720356404153c255e5c3
|
Set autoflush, fixes issue #1
|
diff --git a/bin/twitfolk.pl b/bin/twitfolk.pl
index 7869631..246d1aa 100755
--- a/bin/twitfolk.pl
+++ b/bin/twitfolk.pl
@@ -1,43 +1,46 @@
#!/usr/bin/perl
# vim:set sw=4 cindent:
=pod
TwitFolk
Gate tweets from your Twitter/identi.ca friends into an IRC channel.
http://dev.bitfolk.com/twitfolk/
Copyright ©2008 Andy Smith <andy+twitfolk.pl@bitfolk.com>
Artistic license same as Perl.
$Id: twitfolk.pl 1580 2010-06-10 12:45:21Z andy $
=cut
use warnings;
use strict;
use Config;
use FindBin;
use lib "lib", map "twitfolk-libs/lib/perl5/$_", "", $Config{archname};
BEGIN {
chdir "$FindBin::Bin/..";
}
use TwitFolk;
my $twitfolk = TwitFolk->new_with_options;
$SIG{HUP} = sub {
$twitfolk->handle_sighup;
};
$SIG{TERM} = $SIG{INT} = sub {
$twitfolk->shutdown;
exit 0;
};
+STDOUT->autoflush(1);
+STDERR->autoflush(1);
+
$twitfolk->start;
|
dgl/TwitFolk
|
464ecaa7db4583a2589a22927f4a0c0065614804
|
Ignore files in etc/
|
diff --git a/etc/.gitignore b/etc/.gitignore
index 7e71a67..2a6d1bf 100644
--- a/etc/.gitignore
+++ b/etc/.gitignore
@@ -1,2 +1,4 @@
+last_tweet
+oauth.state
twitfolk.conf
twitfolk.friends
|
dgl/TwitFolk
|
ac04e347f178ac67616341cf6839b69f5e3960eb
|
Remove dead code
|
diff --git a/lib/TwitFolk.pm b/lib/TwitFolk.pm
old mode 100755
new mode 100644
index 29f96aa..c0033d4
--- a/lib/TwitFolk.pm
+++ b/lib/TwitFolk.pm
@@ -1,193 +1,178 @@
=pod
TwitFolk
Gate tweets from your Twitter/identi.ca friends into an IRC channel.
http://dev.bitfolk.com/twitfolk/
Copyright ©2008 Andy Smith <andy+twitfolk.pl@bitfolk.com>
Copyright ©2010 David Leadbeater <dgl@dgl.cx>
Artistic license same as Perl.
$Id: twitfolk.pl 1580 2010-06-10 12:45:21Z andy $
=cut
package TwitFolk;
our $VERSION = "0.2";
use Config::Tiny;
use Moose;
use MooseX::Getopt;
use Try::Tiny;
use TwitFolk::Client::Identica;
use TwitFolk::Client::Twitter;
use TwitFolk::Friends;
use TwitFolk::IRC;
use TwitFolk::Last;
with 'MooseX::Getopt';
has config_file => (
isa => "Str",
is => "ro",
default => sub { "etc/twitfolk.conf" }
);
has ircname => (
isa => "Str",
is => "ro",
default => sub { "twitfolk $VERSION" }
);
has _config => (
isa => "HashRef",
is => "ro",
);
has _irc => (
isa => "TwitFolk::IRC",
is => "ro",
default => sub { TwitFolk::IRC->new }
);
has _friends => (
isa => "TwitFolk::Friends",
is => "rw"
);
has _twitter => (
isa => "TwitFolk::Client",
is => "rw"
);
has _identica => (
isa => "TwitFolk::Client",
is => "rw"
);
sub BUILD {
my($self) = @_;
my $config = Config::Tiny->read($self->config_file)
or die Config::Tiny->errstr;
# Only care about the root section for now.
$self->{_config} = $config->{_};
$self->_friends(
TwitFolk::Friends->new(friends_file => $self->_config->{friends_file})
);
}
# The "main"
sub start {
my($self) = @_;
try {
$self->connect;
AnyEvent->condvar->recv;
} catch {
# Just the first line, Moose can spew rather long errors
$self->_irc->disconnect("Died: " . (/^(.*)$/m)[0]);
warn $_;
};
};
sub shutdown {
my($self) = @_;
$self->_irc->disconnect("Shutdown");
}
sub handle_sighup {
my($self) = @_;
$self->_friends->update;
$self->_twitter->sync if $self->_twitter;
$self->_identica->sync if $self->_identica;
}
sub connect {
my($self) = @_;
my $c = $self->_config;
$self->_irc->connect($self,
$c->{target_server}, $c->{target_port},
{
nick => $c->{nick},
nick_pass => $c->{nick_pass},
user => $c->{username},
real => $self->ircname,
password => $self->{target_pass},
channel => $c->{channel},
away => $c->{away}
}
);
}
# Bot is primed
sub on_join {
my($self) = @_;
return if $self->_twitter || $self->_identica;
my $last_tweets = TwitFolk::Last->new(
tweet_id_file => $self->_config->{tweet_id_file}
);
# Probably should use traits rather than hardcoded classes like this, too
# lazy though.
if($self->_config->{use_twitter}) {
$self->_twitter(
TwitFolk::Client::Twitter->new(
irc => $self->_irc,
target => "#" . $self->_config->{channel},
consumer_key => $self->_config->{twitter_consumer_key},
consumer_secret => $self->_config->{twitter_consumer_secret},
owner => $self->_config->{owner},
last_tweets => $last_tweets,
friends => $self->_friends,
)
);
$self->_friends->twitter($self->_twitter);
$self->_twitter->sync;
}
if($self->_config->{use_identica}) {
$self->_identica(
TwitFolk::Client::Identica->new(
irc => $self->_irc,
target => "#" . $self->_config->{channel},
username => $self->_config->{identica_user},
password => $self->_config->{identica_pass},
max_tweets => $self->_config->{max_tweets},
last_tweets => $last_tweets,
friends => $self->_friends,
)
);
$self->_friends->identica($self->_identica);
$self->_identica->sync;
}
$self->_friends->update;
}
-if(!caller) {
- my $twitfolk = __PACKAGE__->new_with_options;
-
- $SIG{HUP} = sub {
- $twitfolk->handle_sighup;
- };
-
- $SIG{TERM} = $SIG{INT} = sub {
- $twitfolk->shutdown;
- exit 0;
- };
-
- $twitfolk->start;
-}
-
1;
|
dgl/TwitFolk
|
f67bbc6a9eec830bb8afa1d38728d8eb0b33319d
|
Move last_tweet and oauth.state to etc.
|
diff --git a/etc/twitfolk.conf.sample b/etc/twitfolk.conf.sample
index 85e8e51..ce9dab3 100644
--- a/etc/twitfolk.conf.sample
+++ b/etc/twitfolk.conf.sample
@@ -1,58 +1,58 @@
# Example config file for twitfolk.pl
# $Id: twitfolk.conf.sample 1510 2010-05-19 09:08:45Z andy $
# Server hostname or IP.
target_server = uk.blitzed.org
# Port to connect to.
target_port = 6667
# password to use to connect to server (comment out to use no password)
target_pass = yournickpass
# IRC nick to use.
nick = Twitfolk
# If the nick is registered, identify to NickServ with this password.
nick_pass = yournickpass
# If there is no identd installed then use this ident.
username = twitfolk
# Away message to immediately set.
away = If you have a Twitter or Identi.ca account, ask grifferz to add you to me!
# Nickname of owner (the bot might message you to ask you to authorize it, so you should set this)
owner = dg
# Channel, without leading #
channel = bitfolk
# Use twitter.com, defaults to 1.
use_twitter = 1
# Register your "app" at: http://dev.twitter.com/apps
# Consumer key
twitter_consumer_key = noejmNfxtxZEaATRc1nJoA
# Consumer secret
twitter_consumer_secret = N05k9nZ3yxP9ywgkOy2XHsUTJIBuosrgVGa6DNimII
# Use identi.ca (instead or as well as twitter.com). Requires Net::Twitter version >= 2.0.
use_identica = 0
# Your screen name on identi.ca
identica_user = identiuser
# Your password on identi.ca
identica_pass = identipass
# File containing list of people to follow and their IRC nicknames
friends_file = etc/twitfolk.friends
# Where to store the most recent tweet id
-tweet_id_file = last_tweet
+tweet_id_file = etc/last_tweet
# How many tweets to relay at a time
max_tweets = 4
diff --git a/lib/TwitFolk/Client/OAuth.pm b/lib/TwitFolk/Client/OAuth.pm
index 519703d..a7e48bb 100644
--- a/lib/TwitFolk/Client/OAuth.pm
+++ b/lib/TwitFolk/Client/OAuth.pm
@@ -1,104 +1,104 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::Client::OAuth;
=head1 NAME
TwitFolk::Client::OAuth - Handle OAuth stuffs
=head1 DESCRIPTION
Twitter wants an OAuth login thesedays, this provides the handling for it, you
need to implement need_authorization in the class that does this role; it will
be given the URL Twitter wants you to go to, this will give the user a pin,
that should be passed back to authorization_response.
Probably should be two roles to separate out the state saving, but I'm lazy.
=cut
use Moose::Role;
use Net::Twitter;
use JSON qw(from_json to_json); # For serialisation
requires "need_authorization";
-has state_file => (isa => "Str", is => "ro", default => sub { "oauth.state" });
+has state_file => (isa => "Str", is => "ro", default => sub { "etc/oauth.state" });
has consumer_key => (isa => "Str", is => "ro");
has consumer_secret => (isa => "Str", is => "ro");
has access_token => (isa => "Str", is => "rw");
has access_token_secret => (isa => "Str", is => "rw");
has api => (isa => "Net::Twitter", is => "rw");
has api_args => (isa => "HashRef", is => "ro", default => sub { {} });
sub BUILD { }
# I'm bad, but this is easier.
after BUILD => sub {
my($self) = @_;
$self->api(Net::Twitter->new(
traits => [qw(API::REST OAuth)],
consumer_key => $self->consumer_key,
consumer_secret => $self->consumer_secret,
%{$self->api_args}
));
unless(open my $fh, "<", $self->state_file) {
warn "Unable to open '" . $self->state_file . "': $!" unless $!{ENOENT};
} else {
my $state = from_json(join "", <$fh>);
$self->access_token($state->{access_token});
$self->access_token_secret($state->{access_token_secret});
if($self->access_token) {
$self->api->access_token($self->access_token);
$self->api->access_token_secret($self->access_token_secret);
}
}
};
sub authorize {
my($self) = @_;
my $authorized = $self->api->authorized;
unless($authorized) {
$self->need_authorization($self->api->get_authorization_url);
}
return $authorized;
}
sub authorization_response {
my($self, $pin) = @_;
my($access_token, $access_token_secret, $user_id, $screen_name) =
$self->api->request_access_token(verifier => $pin);
$self->access_token($access_token);
$self->access_token_secret($access_token_secret);
$self->save_state;
return 1;
}
sub save_state {
my($self) = @_;
my $new = $self->state_file . ".new";
open my $fh, ">", $new or do {
warn "Unable to write to '$new': $!";
return;
};
print $fh to_json {
access_token => $self->access_token,
access_token_secret => $self->access_token_secret
};
rename $new => $self->state_file;
}
1;
|
dgl/TwitFolk
|
8bee150d6fbfbfcddbd1241c4c962fe826559af8
|
Drop MooseX::Daemonize, use Daemon::Control and a more standard layout
|
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..51974df
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+twitfolk-libs
diff --git a/README b/README
index 7faf65a..ca51878 100644
--- a/README
+++ b/README
@@ -1,81 +1,84 @@
TwitFolk - an IRC/Twitter gateway bot
=====================================
Overview
--------
Gate the tweets/dents from a Twitter or Identi.ca account's list of friends
into an IRC channel.
History
-------
Some people in an IRC channel started noticing that conversations kept crossing
over between IRC and Twitter, so they talked about gating each other's tweets
into the channel:
http://wiki.blitzed.org/Channel:bitfolk/Twitter_Bot
Eventually someone quickly knocked a bot together:
http://wiki.blitzed.org/Channel:bitfolk/Twitfolk
Then a couple of other channels started using it.
Pre-requisites
--------------
- Perl (>=5.10)
- Some Perl modules:
- AnyEvent::Twitter::Stream
- AnyEvent::IRC
- Config::Tiny
- Crpyt::SSLeay
+ - Daemon::Control
- EV
- HTML::Entities
- - MooseX::Daemonize
+ - MooseX::Getopt
- Net::Twitter
- Try::Tiny
It might be easiest to use cpanm with a local::lib to use these modules:
wget -qO ~/bin/cpanm cpanmin.us
chmod 755 ~/bin/cpanm
- cpanm --local-lib=./twitfolk-libs Net::Twitter AnyEvent::Twitter::Stream AnyEvent::IRC MooseX::Daemonize Config::Tiny Try::Tiny EV Crypt::SSLeay
+ cpanm --local-lib=./twitfolk-libs Net::Twitter AnyEvent::Twitter::Stream AnyEvent::IRC Daemon::Control MooseX::Getopt Config::Tiny Try::Tiny EV Crypt::SSLeay Module::Refresh
[wait a rather long time]
Then run with:
- PERL5LIB=./twitfolk-libs/lib/perl5 ./twitfolk.pl
+ bin/twitfolk-init.pl start
+
+ (See perldoc Daemon::Control for help on other ways to run it).
- A twitter.com or identi.ca account
Source
------
You can get it from our Subversion repository:
https://svn.bitfolk.com/repos/twitfolk/
Support
-------
Limited community support is available from the TwitFolk users mailing list:
https://lists.bitfolk.com/mailman/listinfo/twitfolk
Feature suggestions would be great, too.
You can follow TwitFolk development on Identi.ca:
http://identi.ca/twitfolk
which is also gated to Twitter:
http://twitter.com/therealtwitfolk
(The "twitfolk" username was already taken on Twitter; if you own it and want
to give it up, please let us know!)
$Id:README 977 2009-07-26 02:50:08Z andy $
diff --git a/bin/twitfolk-init.pl b/bin/twitfolk-init.pl
new file mode 100755
index 0000000..1cd2f8a
--- /dev/null
+++ b/bin/twitfolk-init.pl
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use FindBin;
+use Daemon::Control;
+
+my $bin = "$FindBin::Bin/..";
+
+Daemon::Control->new({
+ name => "TwitFolk",
+ path => $bin . '/bin/twitfolk-init.pl',
+ program => $bin . '/bin/twitfolk.pl',
+ pid_file => $bin . '/var/twitfolk.pid',
+ stderr_file => $bin . '/var/twitfolk.out',
+ stdout_file => $bin . '/var/twitfolk.out',
+ fork => 2,
+})->run;
diff --git a/bin/twitfolk.pl b/bin/twitfolk.pl
new file mode 100755
index 0000000..7869631
--- /dev/null
+++ b/bin/twitfolk.pl
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+
+# vim:set sw=4 cindent:
+
+=pod
+
+TwitFolk
+
+Gate tweets from your Twitter/identi.ca friends into an IRC channel.
+
+http://dev.bitfolk.com/twitfolk/
+
+Copyright ©2008 Andy Smith <andy+twitfolk.pl@bitfolk.com>
+
+Artistic license same as Perl.
+
+$Id: twitfolk.pl 1580 2010-06-10 12:45:21Z andy $
+=cut
+
+use warnings;
+use strict;
+use Config;
+use FindBin;
+use lib "lib", map "twitfolk-libs/lib/perl5/$_", "", $Config{archname};
+
+BEGIN {
+ chdir "$FindBin::Bin/..";
+}
+
+use TwitFolk;
+
+my $twitfolk = TwitFolk->new_with_options;
+
+$SIG{HUP} = sub {
+ $twitfolk->handle_sighup;
+};
+
+$SIG{TERM} = $SIG{INT} = sub {
+ $twitfolk->shutdown;
+ exit 0;
+};
+
+$twitfolk->start;
diff --git a/etc/.gitignore b/etc/.gitignore
new file mode 100644
index 0000000..7e71a67
--- /dev/null
+++ b/etc/.gitignore
@@ -0,0 +1,2 @@
+twitfolk.conf
+twitfolk.friends
diff --git a/twitfolk.conf.sample b/etc/twitfolk.conf.sample
similarity index 93%
rename from twitfolk.conf.sample
rename to etc/twitfolk.conf.sample
index 86728f7..85e8e51 100644
--- a/twitfolk.conf.sample
+++ b/etc/twitfolk.conf.sample
@@ -1,61 +1,58 @@
# Example config file for twitfolk.pl
# $Id: twitfolk.conf.sample 1510 2010-05-19 09:08:45Z andy $
# Server hostname or IP.
target_server = uk.blitzed.org
# Port to connect to.
target_port = 6667
# password to use to connect to server (comment out to use no password)
target_pass = yournickpass
# IRC nick to use.
nick = Twitfolk
# If the nick is registered, identify to NickServ with this password.
nick_pass = yournickpass
# If there is no identd installed then use this ident.
username = twitfolk
-# File to write PID to whilst running.
-pidfile = twitfolk.pid
-
# Away message to immediately set.
away = If you have a Twitter or Identi.ca account, ask grifferz to add you to me!
# Nickname of owner (the bot might message you to ask you to authorize it, so you should set this)
owner = dg
# Channel, without leading #
channel = bitfolk
# Use twitter.com, defaults to 1.
use_twitter = 1
# Register your "app" at: http://dev.twitter.com/apps
# Consumer key
twitter_consumer_key = noejmNfxtxZEaATRc1nJoA
# Consumer secret
twitter_consumer_secret = N05k9nZ3yxP9ywgkOy2XHsUTJIBuosrgVGa6DNimII
# Use identi.ca (instead or as well as twitter.com). Requires Net::Twitter version >= 2.0.
use_identica = 0
# Your screen name on identi.ca
identica_user = identiuser
# Your password on identi.ca
identica_pass = identipass
# File containing list of people to follow and their IRC nicknames
-friends_file = twitfolk.friends
+friends_file = etc/twitfolk.friends
# Where to store the most recent tweet id
tweet_id_file = last_tweet
# How many tweets to relay at a time
max_tweets = 4
diff --git a/twitfolk.friends.sample b/etc/twitfolk.friends.sample
similarity index 100%
rename from twitfolk.friends.sample
rename to etc/twitfolk.friends.sample
diff --git a/TwitFolk.pm b/lib/TwitFolk.pm
old mode 100644
new mode 100755
similarity index 88%
rename from TwitFolk.pm
rename to lib/TwitFolk.pm
index 426dce8..29f96aa
--- a/TwitFolk.pm
+++ b/lib/TwitFolk.pm
@@ -1,181 +1,193 @@
=pod
TwitFolk
Gate tweets from your Twitter/identi.ca friends into an IRC channel.
http://dev.bitfolk.com/twitfolk/
Copyright ©2008 Andy Smith <andy+twitfolk.pl@bitfolk.com>
Copyright ©2010 David Leadbeater <dgl@dgl.cx>
Artistic license same as Perl.
$Id: twitfolk.pl 1580 2010-06-10 12:45:21Z andy $
=cut
package TwitFolk;
our $VERSION = "0.2";
use Config::Tiny;
use Moose;
+use MooseX::Getopt;
use Try::Tiny;
use TwitFolk::Client::Identica;
use TwitFolk::Client::Twitter;
use TwitFolk::Friends;
use TwitFolk::IRC;
use TwitFolk::Last;
-with qw(MooseX::Daemonize);
+with 'MooseX::Getopt';
has config_file => (
isa => "Str",
is => "ro",
- default => sub { "twitfolk.conf" }
+ default => sub { "etc/twitfolk.conf" }
);
has ircname => (
isa => "Str",
is => "ro",
default => sub { "twitfolk $VERSION" }
);
has _config => (
isa => "HashRef",
is => "ro",
);
has _irc => (
isa => "TwitFolk::IRC",
is => "ro",
default => sub { TwitFolk::IRC->new }
);
has _friends => (
isa => "TwitFolk::Friends",
is => "rw"
);
has _twitter => (
isa => "TwitFolk::Client",
is => "rw"
);
has _identica => (
isa => "TwitFolk::Client",
is => "rw"
);
sub BUILD {
my($self) = @_;
my $config = Config::Tiny->read($self->config_file)
or die Config::Tiny->errstr;
# Only care about the root section for now.
$self->{_config} = $config->{_};
$self->_friends(
TwitFolk::Friends->new(friends_file => $self->_config->{friends_file})
);
-
- $self->pidfile($self->_config->{pidfile});
}
-
# The "main"
-after start => sub {
+sub start {
my($self) = @_;
- return unless $self->is_daemon;
-
- $SIG{HUP} = sub {
- $self->_friends->update;
- $self->_twitter->sync if $self->_twitter;
- $self->_identica->sync if $self->_identica;
- };
-
try {
$self->connect;
AnyEvent->condvar->recv;
} catch {
# Just the first line, Moose can spew rather long errors
$self->_irc->disconnect("Died: " . (/^(.*)$/m)[0]);
warn $_;
};
};
-before shutdown => sub {
+sub shutdown {
my($self) = @_;
$self->_irc->disconnect("Shutdown");
-};
+}
+
+sub handle_sighup {
+ my($self) = @_;
+ $self->_friends->update;
+ $self->_twitter->sync if $self->_twitter;
+ $self->_identica->sync if $self->_identica;
+}
sub connect {
my($self) = @_;
my $c = $self->_config;
$self->_irc->connect($self,
$c->{target_server}, $c->{target_port},
{
nick => $c->{nick},
nick_pass => $c->{nick_pass},
user => $c->{username},
real => $self->ircname,
password => $self->{target_pass},
channel => $c->{channel},
away => $c->{away}
}
);
}
# Bot is primed
sub on_join {
my($self) = @_;
return if $self->_twitter || $self->_identica;
my $last_tweets = TwitFolk::Last->new(
tweet_id_file => $self->_config->{tweet_id_file}
);
# Probably should use traits rather than hardcoded classes like this, too
# lazy though.
if($self->_config->{use_twitter}) {
$self->_twitter(
TwitFolk::Client::Twitter->new(
irc => $self->_irc,
target => "#" . $self->_config->{channel},
consumer_key => $self->_config->{twitter_consumer_key},
consumer_secret => $self->_config->{twitter_consumer_secret},
owner => $self->_config->{owner},
last_tweets => $last_tweets,
friends => $self->_friends,
)
);
$self->_friends->twitter($self->_twitter);
$self->_twitter->sync;
}
if($self->_config->{use_identica}) {
$self->_identica(
TwitFolk::Client::Identica->new(
irc => $self->_irc,
target => "#" . $self->_config->{channel},
username => $self->_config->{identica_user},
password => $self->_config->{identica_pass},
max_tweets => $self->_config->{max_tweets},
last_tweets => $last_tweets,
friends => $self->_friends,
)
);
$self->_friends->identica($self->_identica);
$self->_identica->sync;
}
$self->_friends->update;
}
+if(!caller) {
+ my $twitfolk = __PACKAGE__->new_with_options;
+
+ $SIG{HUP} = sub {
+ $twitfolk->handle_sighup;
+ };
+
+ $SIG{TERM} = $SIG{INT} = sub {
+ $twitfolk->shutdown;
+ exit 0;
+ };
+
+ $twitfolk->start;
+}
+
1;
diff --git a/TwitFolk/Client.pm b/lib/TwitFolk/Client.pm
similarity index 100%
rename from TwitFolk/Client.pm
rename to lib/TwitFolk/Client.pm
diff --git a/TwitFolk/Client/Basic.pm b/lib/TwitFolk/Client/Basic.pm
similarity index 100%
rename from TwitFolk/Client/Basic.pm
rename to lib/TwitFolk/Client/Basic.pm
diff --git a/TwitFolk/Client/Identica.pm b/lib/TwitFolk/Client/Identica.pm
similarity index 100%
rename from TwitFolk/Client/Identica.pm
rename to lib/TwitFolk/Client/Identica.pm
diff --git a/TwitFolk/Client/OAuth.pm b/lib/TwitFolk/Client/OAuth.pm
similarity index 100%
rename from TwitFolk/Client/OAuth.pm
rename to lib/TwitFolk/Client/OAuth.pm
diff --git a/TwitFolk/Client/Twitter.pm b/lib/TwitFolk/Client/Twitter.pm
similarity index 100%
rename from TwitFolk/Client/Twitter.pm
rename to lib/TwitFolk/Client/Twitter.pm
diff --git a/TwitFolk/Friends.pm b/lib/TwitFolk/Friends.pm
similarity index 100%
rename from TwitFolk/Friends.pm
rename to lib/TwitFolk/Friends.pm
diff --git a/TwitFolk/IRC.pm b/lib/TwitFolk/IRC.pm
similarity index 100%
rename from TwitFolk/IRC.pm
rename to lib/TwitFolk/IRC.pm
diff --git a/TwitFolk/Last.pm b/lib/TwitFolk/Last.pm
similarity index 100%
rename from TwitFolk/Last.pm
rename to lib/TwitFolk/Last.pm
diff --git a/TwitFolk/Log.pm b/lib/TwitFolk/Log.pm
similarity index 100%
rename from TwitFolk/Log.pm
rename to lib/TwitFolk/Log.pm
diff --git a/twitfolk.pl b/twitfolk.pl
deleted file mode 100755
index bb40732..0000000
--- a/twitfolk.pl
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/perl
-
-# vim:set sw=4 cindent:
-
-=pod
-
-TwitFolk
-
-Gate tweets from your Twitter/identi.ca friends into an IRC channel.
-
-http://dev.bitfolk.com/twitfolk/
-
-Copyright ©2008 Andy Smith <andy+twitfolk.pl@bitfolk.com>
-
-Artistic license same as Perl.
-
-$Id: twitfolk.pl 1580 2010-06-10 12:45:21Z andy $
-=cut
-
-use Cwd;
-use TwitFolk;
-
-my $twitfolk = TwitFolk->new_with_options(basedir => cwd);
-my $command = $twitfolk->extra_argv->[0] || "start";
-$twitfolk->$command;
-
-warn $twitfolk->status_message if $twitfolk->status_message;
-exit $twitfolk->exit_code;
diff --git a/var/.gitignore b/var/.gitignore
new file mode 100644
index 0000000..67d12c6
--- /dev/null
+++ b/var/.gitignore
@@ -0,0 +1,2 @@
+twitfolk.pid
+twitfolk.out
|
dgl/TwitFolk
|
0adf0f660db18e15d9ee7143d8f1178e3023e4c4
|
Work with freenode nicks
|
diff --git a/TwitFolk/IRC.pm b/TwitFolk/IRC.pm
index ddf2d21..7ca645b 100644
--- a/TwitFolk/IRC.pm
+++ b/TwitFolk/IRC.pm
@@ -1,131 +1,131 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::IRC;
use EV; # AnyEvent::Impl::Perl seems to behave oddly
use strict;
=head1 NAME
TwitFolk::IRC - Lame wrapper around AnyEvent::IRC::Client for TwitFolk
=cut
use base "AnyEvent::IRC::Client";
use AnyEvent::IRC::Util qw(prefix_nick);
use TwitFolk::Log;
sub connect {
my($self, $parent, $addr, $port, $args) = @_;
($self->{twitfolk_connect_cb} = sub {
$self->SUPER::connect($addr, $port, $args);
$self->{parent} = $parent;
$self->{args} = $args;
my $channel = $args->{channel};
$self->send_srv(JOIN => $channel =~ /^#/ ? $channel : "#$channel");
if($args->{away}) {
$self->send_srv(AWAY => $args->{away});
}
$EV::DIED = sub {
warn "Caught exception, will continue: $@";
$self->notice("@" . ($channel =~ /^#/ ? $channel : "#$channel"), $@ =~ /(.*)/);
};
$SIG{__WARN__} = sub {
warn @_;
$self->notice("@" . ($channel =~ /^#/ ? $channel : "#$channel"), $_[0] =~ /(.*)/);
};
})->();
$self->reg_cb(debug_cb => sub {
debug "@_";
});
# Register our callbacks
for(qw(registered connect disconnect join irc_433 irc_notice)) {
my $callback = "on_$_";
$self->reg_cb($_ => sub {
my $irc = shift;
debug "IRC: $callback: " . (ref($_[0]) eq 'HASH' ? JSON::to_json($_[0]) : "");
$self->$callback(@_)
});
}
}
sub msg {
my($self, $who, $text) = @_;
$self->send_srv(PRIVMSG => $who, $text);
}
sub notice {
my($self, $who, $text) = @_;
$self->send_srv(NOTICE => $who, $text);
}
sub on_registered {
my($self) = @_;
$self->enable_ping(90);
}
sub on_connect {
my($self, $error) = @_;
if($error) {
warn "Unable to connect: $error\n";
$self->on_disconnect;
}
}
sub on_disconnect {
my($self) = @_;
$self->{reconnect_timer} = AE::timer 10, 0, sub {
undef $self->{reconnect_timer};
$self->{twitfolk_connect_cb}->();
};
}
sub on_join {
my($self, $nick, $channel, $myself) = @_;
$self->{parent}->on_join if $myself;
}
# Nick in use
sub on_irc_433 {
my($self) = @_;
$self->send_srv(NICK => $self->{nick} . $$);
$self->msg("NickServ", "RECOVER $self->{args}->{nick} $self->{args}->{nick_pass}");
}
sub on_irc_notice {
my($self, $msg) = @_;
if(lc prefix_nick($msg) eq 'nickserv') {
local $_ = $msg->{params}->[-1];
if (/This nick is owned by someone else/ ||
- /This nickname is registered and protected/i) {
+ /This nickname is registered/i) {
debug("ID to NickServ at request of NickServ");
$self->msg("NickServ", "IDENTIFY $self->{args}->{nick_pass}");
} elsif (/Your nick has been recovered/i) {
debug("NickServ told me I recovered my nick, RELEASE'ing now");
$self->msg("NickServ", "RELEASE $self->{args}->{nick} $self->{args}->{nick_pass}");
} elsif (/Your nick has been released from custody/i) {
debug("NickServ told me my nick is released, /nick'ing now");
$self->send_srv(NICK => $self->{args}->{nick});
} else {
debug("Ignoring NickServ notice: %s", $_);
}
}
}
1;
|
dgl/TwitFolk
|
ccfecc0895dc3868440b75e86f2e60be73bc9f28
|
Only daemonize if asked
|
diff --git a/TwitFolk.pm b/TwitFolk.pm
index 67ee04a..426dce8 100644
--- a/TwitFolk.pm
+++ b/TwitFolk.pm
@@ -1,179 +1,181 @@
=pod
TwitFolk
Gate tweets from your Twitter/identi.ca friends into an IRC channel.
http://dev.bitfolk.com/twitfolk/
Copyright ©2008 Andy Smith <andy+twitfolk.pl@bitfolk.com>
Copyright ©2010 David Leadbeater <dgl@dgl.cx>
Artistic license same as Perl.
$Id: twitfolk.pl 1580 2010-06-10 12:45:21Z andy $
=cut
package TwitFolk;
our $VERSION = "0.2";
use Config::Tiny;
use Moose;
use Try::Tiny;
use TwitFolk::Client::Identica;
use TwitFolk::Client::Twitter;
use TwitFolk::Friends;
use TwitFolk::IRC;
use TwitFolk::Last;
with qw(MooseX::Daemonize);
has config_file => (
isa => "Str",
is => "ro",
default => sub { "twitfolk.conf" }
);
has ircname => (
isa => "Str",
is => "ro",
default => sub { "twitfolk $VERSION" }
);
has _config => (
isa => "HashRef",
is => "ro",
);
has _irc => (
isa => "TwitFolk::IRC",
is => "ro",
default => sub { TwitFolk::IRC->new }
);
has _friends => (
isa => "TwitFolk::Friends",
is => "rw"
);
has _twitter => (
isa => "TwitFolk::Client",
is => "rw"
);
has _identica => (
isa => "TwitFolk::Client",
is => "rw"
);
sub BUILD {
my($self) = @_;
my $config = Config::Tiny->read($self->config_file)
or die Config::Tiny->errstr;
# Only care about the root section for now.
$self->{_config} = $config->{_};
$self->_friends(
TwitFolk::Friends->new(friends_file => $self->_config->{friends_file})
);
$self->pidfile($self->_config->{pidfile});
}
# The "main"
after start => sub {
my($self) = @_;
+ return unless $self->is_daemon;
+
$SIG{HUP} = sub {
$self->_friends->update;
$self->_twitter->sync if $self->_twitter;
$self->_identica->sync if $self->_identica;
};
try {
$self->connect;
AnyEvent->condvar->recv;
} catch {
# Just the first line, Moose can spew rather long errors
$self->_irc->disconnect("Died: " . (/^(.*)$/m)[0]);
warn $_;
};
};
before shutdown => sub {
my($self) = @_;
$self->_irc->disconnect("Shutdown");
};
sub connect {
my($self) = @_;
my $c = $self->_config;
$self->_irc->connect($self,
$c->{target_server}, $c->{target_port},
{
nick => $c->{nick},
nick_pass => $c->{nick_pass},
user => $c->{username},
real => $self->ircname,
password => $self->{target_pass},
channel => $c->{channel},
away => $c->{away}
}
);
}
# Bot is primed
sub on_join {
my($self) = @_;
return if $self->_twitter || $self->_identica;
my $last_tweets = TwitFolk::Last->new(
tweet_id_file => $self->_config->{tweet_id_file}
);
# Probably should use traits rather than hardcoded classes like this, too
# lazy though.
if($self->_config->{use_twitter}) {
$self->_twitter(
TwitFolk::Client::Twitter->new(
irc => $self->_irc,
target => "#" . $self->_config->{channel},
consumer_key => $self->_config->{twitter_consumer_key},
consumer_secret => $self->_config->{twitter_consumer_secret},
owner => $self->_config->{owner},
last_tweets => $last_tweets,
friends => $self->_friends,
)
);
$self->_friends->twitter($self->_twitter);
$self->_twitter->sync;
}
if($self->_config->{use_identica}) {
$self->_identica(
TwitFolk::Client::Identica->new(
irc => $self->_irc,
target => "#" . $self->_config->{channel},
username => $self->_config->{identica_user},
password => $self->_config->{identica_pass},
max_tweets => $self->_config->{max_tweets},
last_tweets => $last_tweets,
friends => $self->_friends,
)
);
$self->_friends->identica($self->_identica);
$self->_identica->sync;
}
$self->_friends->update;
}
1;
|
dgl/TwitFolk
|
61d7717aeb273e6e4aac36776b2cd824cdc3ef1f
|
Actually display connection errors
|
diff --git a/TwitFolk/IRC.pm b/TwitFolk/IRC.pm
index 3a75a88..ddf2d21 100644
--- a/TwitFolk/IRC.pm
+++ b/TwitFolk/IRC.pm
@@ -1,116 +1,131 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::IRC;
use EV; # AnyEvent::Impl::Perl seems to behave oddly
use strict;
=head1 NAME
TwitFolk::IRC - Lame wrapper around AnyEvent::IRC::Client for TwitFolk
=cut
use base "AnyEvent::IRC::Client";
use AnyEvent::IRC::Util qw(prefix_nick);
use TwitFolk::Log;
sub connect {
my($self, $parent, $addr, $port, $args) = @_;
($self->{twitfolk_connect_cb} = sub {
$self->SUPER::connect($addr, $port, $args);
$self->{parent} = $parent;
$self->{args} = $args;
my $channel = $args->{channel};
$self->send_srv(JOIN => $channel =~ /^#/ ? $channel : "#$channel");
if($args->{away}) {
$self->send_srv(AWAY => $args->{away});
}
$EV::DIED = sub {
+ warn "Caught exception, will continue: $@";
$self->notice("@" . ($channel =~ /^#/ ? $channel : "#$channel"), $@ =~ /(.*)/);
};
$SIG{__WARN__} = sub {
+ warn @_;
$self->notice("@" . ($channel =~ /^#/ ? $channel : "#$channel"), $_[0] =~ /(.*)/);
};
})->();
+ $self->reg_cb(debug_cb => sub {
+ debug "@_";
+ });
+
# Register our callbacks
- for(qw(registered disconnect join irc_433 irc_notice)) {
+ for(qw(registered connect disconnect join irc_433 irc_notice)) {
my $callback = "on_$_";
$self->reg_cb($_ => sub {
my $irc = shift;
debug "IRC: $callback: " . (ref($_[0]) eq 'HASH' ? JSON::to_json($_[0]) : "");
$self->$callback(@_)
});
}
}
sub msg {
my($self, $who, $text) = @_;
$self->send_srv(PRIVMSG => $who, $text);
}
sub notice {
my($self, $who, $text) = @_;
$self->send_srv(NOTICE => $who, $text);
}
sub on_registered {
my($self) = @_;
$self->enable_ping(90);
}
+sub on_connect {
+ my($self, $error) = @_;
+
+ if($error) {
+ warn "Unable to connect: $error\n";
+ $self->on_disconnect;
+ }
+}
+
sub on_disconnect {
my($self) = @_;
$self->{reconnect_timer} = AE::timer 10, 0, sub {
undef $self->{reconnect_timer};
$self->{twitfolk_connect_cb}->();
};
}
sub on_join {
my($self, $nick, $channel, $myself) = @_;
$self->{parent}->on_join if $myself;
}
# Nick in use
sub on_irc_433 {
my($self) = @_;
$self->send_srv(NICK => $self->{nick} . $$);
$self->msg("NickServ", "RECOVER $self->{args}->{nick} $self->{args}->{nick_pass}");
}
sub on_irc_notice {
my($self, $msg) = @_;
if(lc prefix_nick($msg) eq 'nickserv') {
local $_ = $msg->{params}->[-1];
if (/This nick is owned by someone else/ ||
/This nickname is registered and protected/i) {
debug("ID to NickServ at request of NickServ");
$self->msg("NickServ", "IDENTIFY $self->{args}->{nick_pass}");
} elsif (/Your nick has been recovered/i) {
debug("NickServ told me I recovered my nick, RELEASE'ing now");
$self->msg("NickServ", "RELEASE $self->{args}->{nick} $self->{args}->{nick_pass}");
} elsif (/Your nick has been released from custody/i) {
debug("NickServ told me my nick is released, /nick'ing now");
$self->send_srv(NICK => $self->{args}->{nick});
} else {
debug("Ignoring NickServ notice: %s", $_);
}
}
}
1;
|
dgl/TwitFolk
|
472308ae80792ba6fc2f88b4bffa14499ee0b52a
|
Various changes
|
diff --git a/TwitFolk/Client.pm b/TwitFolk/Client.pm
index 9f4559e..efdb259 100644
--- a/TwitFolk/Client.pm
+++ b/TwitFolk/Client.pm
@@ -1,42 +1,53 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::Client;
use Moose;
use TwitFolk::Log;
use HTML::Entities;
use Encode qw(encode_utf8);
has irc => (isa => "TwitFolk::IRC", is => "ro");
has target => (isa => "Str", is => "ro");
has friends => (isa => "TwitFolk::Friends", is => "ro");
has last_tweets => (isa => "TwitFolk::Last", is => "ro");
sub on_update {
my($self, $update) = @_;
my $screen_name = $update->{user}->{screen_name};
my $nick = $self->friends->lookup_nick($screen_name);
my $text = decode_entities $update->{text};
+ if($update->{retweeted_status}->{text}) {
+ $text = "RT \@" . $update->{retweeted_status}->{user}->{screen_name} . ": "
+ . decode_entities $update->{retweeted_status}->{text};
+ }
+
+ # Skip tweets from people who aren't friends
+ unless(grep { lc($_) eq lc $screen_name } keys %{$self->friends->friends}) {
+ debug("Ignoring tweet %s from [%s]", $update->{id}, $screen_name);
+ return;
+ }
+
# Skip tweets directed at others who aren't friends
if ($text =~ /^@([[:alnum:]_]+)/) {
my $other_sn = lc($1);
unless (grep { lc($_) eq $other_sn } keys %{$self->friends->friends}) {
debug("Ignoring reply tweet %s from [%s] to [%s]",
$update->{id}, $screen_name, $other_sn);
return;
}
}
debug("%s/%s: [%s/\@%s] %s", ref $self, $update->{id}, $nick, $screen_name, $text);
if ($text =~ /[\n\r]/) {
debug("%s/%s contains dangerous characters; removing!",
ref $self, $update->{id});
$text =~ s/[\n\r]/ /g;
}
$self->irc->notice($self->target, encode_utf8 sprintf("[%s/\@%s] %s",
$nick, $screen_name, $text));
}
1;
diff --git a/TwitFolk/Client/Twitter.pm b/TwitFolk/Client/Twitter.pm
index d55a7d5..37df788 100644
--- a/TwitFolk/Client/Twitter.pm
+++ b/TwitFolk/Client/Twitter.pm
@@ -1,110 +1,115 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::Client::Twitter;
use Moose;
use AnyEvent::IRC::Util qw(prefix_nick);
use AnyEvent::Twitter::Stream;
use Try::Tiny;
use TwitFolk::Log;
+use Module::Refresh;
extends "TwitFolk::Client";
with qw(TwitFolk::Client::OAuth);
# Who to contact when we need OAuth fixing
has owner => (isa => "Str", is => "rw");
# Our listener for tweets
has listener => (isa => "Maybe[AnyEvent::Twitter::Stream]", is => "rw");
# Timer for reconnections
has reconnect_timer => (is => "rw");
sub BUILD {
my($self) = @_;
$self->irc->reg_cb(privatemsg => sub { $self->on_privmsg(@_) });
}
sub sync {
my($self) = @_;
try {
if($self->authorize) {
$self->start_stream;
}
} catch {
warn "Can't sync: $_";
};
}
sub need_authorization {
my($self, $url) = @_;
$self->irc->msg($self->owner,
"Please could you be so kind as to login as me on Twitter, go to $url and then msg me with the pin, thank you!");
}
sub on_privmsg {
my($self, $irc, $nick, $msg) = @_;
if(lc prefix_nick($msg) eq $self->owner
&& $msg->{params}->[-1] =~ /^(\d+)\s*$/) {
try {
$self->authorization_response($1);
$self->irc->msg($self->owner, "Most excellent, sir!");
$self->start_stream;
} catch {
$self->irc->msg($self->owner, "Sorry, that didn't seem to work: $_");
}
+ } elsif(lc prefix_nick($msg) eq $self->owner
+ && $msg->{params}->[-1] =~ /^refresh/) {
+ Module::Refresh->refresh;
}
}
sub reconnect {
my($self) = @_;
$self->listener(undef);
$self->reconnect_timer(
AE::timer 10, 0, sub {
$self->reconnect_timer(undef);
debug "Reconnecting to twitter...";
$self->sync;
}
);
}
sub start_stream {
my($self) = @_;
return if $self->listener;
debug "Starting stream";
$self->listener(
AnyEvent::Twitter::Stream->new(
consumer_key => $self->consumer_key,
consumer_secret => $self->consumer_secret,
token => $self->access_token,
token_secret => $self->access_token_secret,
method => "userstream",
+ replies => "all",
on_tweet => sub {
my($tweet) = @_;
debug "on_tweet: " . JSON::to_json($tweet);
return unless $tweet->{user};
$self->on_update($tweet);
$self->last_tweets->update(twitter => $tweet->{id}); # This is totally pointless with streaming API, but doesn't hurt
},
on_error => sub {
debug "Error from twitter stream: @_";
$self->reconnect;
},
on_eof => sub {
debug "EOF from twitter stream";
$self->reconnect;
},
)
);
}
1;
diff --git a/TwitFolk/Friends.pm b/TwitFolk/Friends.pm
index 47cb79c..6dc69f6 100644
--- a/TwitFolk/Friends.pm
+++ b/TwitFolk/Friends.pm
@@ -1,133 +1,137 @@
package TwitFolk::Friends;
use Moose;
use Try::Tiny;
use TwitFolk::Log;
has friends_file => (isa => "Str", is => "ro");
has twitter => (isa => "TwitFolk::Client", is => "rw");
has identica => (isa => "TwitFolk::Client", is => "rw");
has friends => (isa => "HashRef", is => "rw", default => sub { {} });
=head2 lookup_nick
Return the nick associated with the screen name, or the screen name if nick is
not known.
=cut
sub lookup_nick {
my($self, $screen_name) = @_;
if(exists $self->friends->{lc $screen_name}) {
return $self->friends->{lc $screen_name}->{nick};
}
return $screen_name;
}
=head2 update
Read a list of friends from the friends_file. These will be friended in
Twitter if they aren't already. Format is:
screen_name IRC_nick service
Start a line with # for a comment. Any kind of white space is okay.
Service column may be 'twitter' or 'identica', defaulting to twitter if
none is specified.
=cut
sub update
{
my $self = shift;
open my $ff, "<", $self->friends_file or die "Couldn't open friends_file: $!";
while (<$ff>) {
next if (/^#/);
if (/^(\S+)\s+(\S+)(?:\s+(\S+))?/) {
my $f = lc($1);
my $nick = $2;
my $svcname = $3 || 'twitter';
if (!exists $self->friends->{$f}) {
my $u;
my $svc;
# Friend may be on identi.ca OR twitter
- $svc = ($svcname =~ /dent/i) ? $self->identica->api : $self->twitter->api;
+ if($svcname =~ /dent/i) {
+ $svc = $self->identica && $self->identica->api;
+ } else {
+ $svc = $self->twitter->api;
+ }
try {
$u = $svc->show_user($f);
} catch {
debug("%s->show_user(%s) error: %s", $svcname, $f, $_);
};
my $id = $u->{id};
$self->friends->{$f}->{id} = $id;
debug("%s: Adding new friend '%s' (%lu)", $svcname,
$f, $id);
- try {
+ 0 && try {
$svc->create_friend($id);
} catch {
debug("%s->create_friend(%lu) error: %s",
$svcname, $id, $_);
};
$self->friends->{$f}->{nick} = $nick;
}
}
}
close $ff or warn "Something weird when closing friends_file: $!";
}
=head1 sync
Learn friends from those already added in Twitter, just in case they got added
from outside as well. Might make this update the friends file at some point.
=cut
sub sync
{
my $self = shift;
my $svc = shift;
my $svcname = shift;
my $twitter_friends;
try {
$twitter_friends = $svc->friends;
} catch {
debug("%s->friends() error: %s", $svcname, $_);
};
return unless $twitter_friends;
if (ref($twitter_friends) ne "ARRAY") {
debug("%s->friends() didn't return an arrayref!", $svcname);
return;
}
for my $f (@{$twitter_friends}) {
my $screen_name = lc($f->{screen_name});
my $id = $f->{id};
$self->friends->{$screen_name}->{id} = $id;
if (! defined $self->friends->{$screen_name}->{nick}) {
$self->friends->{$screen_name}->{nick} = $screen_name;
}
debug("%s: Already following '%s' (%lu)", $svcname, $screen_name,
$self->friends->{$screen_name}->{id});
}
}
1;
diff --git a/TwitFolk/IRC.pm b/TwitFolk/IRC.pm
index 565807c..3a75a88 100644
--- a/TwitFolk/IRC.pm
+++ b/TwitFolk/IRC.pm
@@ -1,108 +1,116 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::IRC;
use EV; # AnyEvent::Impl::Perl seems to behave oddly
use strict;
=head1 NAME
TwitFolk::IRC - Lame wrapper around AnyEvent::IRC::Client for TwitFolk
=cut
use base "AnyEvent::IRC::Client";
use AnyEvent::IRC::Util qw(prefix_nick);
use TwitFolk::Log;
sub connect {
my($self, $parent, $addr, $port, $args) = @_;
($self->{twitfolk_connect_cb} = sub {
$self->SUPER::connect($addr, $port, $args);
$self->{parent} = $parent;
$self->{args} = $args;
my $channel = $args->{channel};
$self->send_srv(JOIN => $channel =~ /^#/ ? $channel : "#$channel");
if($args->{away}) {
$self->send_srv(AWAY => $args->{away});
}
+ $EV::DIED = sub {
+ $self->notice("@" . ($channel =~ /^#/ ? $channel : "#$channel"), $@ =~ /(.*)/);
+ };
+
+ $SIG{__WARN__} = sub {
+ $self->notice("@" . ($channel =~ /^#/ ? $channel : "#$channel"), $_[0] =~ /(.*)/);
+ };
+
})->();
# Register our callbacks
for(qw(registered disconnect join irc_433 irc_notice)) {
my $callback = "on_$_";
$self->reg_cb($_ => sub {
my $irc = shift;
debug "IRC: $callback: " . (ref($_[0]) eq 'HASH' ? JSON::to_json($_[0]) : "");
$self->$callback(@_)
});
}
}
sub msg {
my($self, $who, $text) = @_;
$self->send_srv(PRIVMSG => $who, $text);
}
sub notice {
my($self, $who, $text) = @_;
$self->send_srv(NOTICE => $who, $text);
}
sub on_registered {
my($self) = @_;
$self->enable_ping(90);
}
sub on_disconnect {
my($self) = @_;
$self->{reconnect_timer} = AE::timer 10, 0, sub {
undef $self->{reconnect_timer};
$self->{twitfolk_connect_cb}->();
};
}
sub on_join {
my($self, $nick, $channel, $myself) = @_;
$self->{parent}->on_join if $myself;
}
# Nick in use
sub on_irc_433 {
my($self) = @_;
$self->send_srv(NICK => $self->{nick} . $$);
$self->msg("NickServ", "RECOVER $self->{args}->{nick} $self->{args}->{nick_pass}");
}
sub on_irc_notice {
my($self, $msg) = @_;
if(lc prefix_nick($msg) eq 'nickserv') {
local $_ = $msg->{params}->[-1];
if (/This nick is owned by someone else/ ||
/This nickname is registered and protected/i) {
debug("ID to NickServ at request of NickServ");
$self->msg("NickServ", "IDENTIFY $self->{args}->{nick_pass}");
} elsif (/Your nick has been recovered/i) {
debug("NickServ told me I recovered my nick, RELEASE'ing now");
$self->msg("NickServ", "RELEASE $self->{args}->{nick} $self->{args}->{nick_pass}");
} elsif (/Your nick has been released from custody/i) {
debug("NickServ told me my nick is released, /nick'ing now");
$self->send_srv(NICK => $self->{args}->{nick});
} else {
debug("Ignoring NickServ notice: %s", $_);
}
}
}
1;
diff --git a/TwitFolk/Log.pm b/TwitFolk/Log.pm
index 2cdb2f8..ff1b53f 100644
--- a/TwitFolk/Log.pm
+++ b/TwitFolk/Log.pm
@@ -1,11 +1,18 @@
package TwitFolk::Log;
use constant DEBUG => $ENV{IRC_DEBUG};
use parent "Exporter";
our @EXPORT = qw(debug);
+binmode STDERR, ":encoding(UTF-8)";
+
sub debug {
- warn sprintf "$_[0]\n", @_[1 .. $#_] if DEBUG;
+ eval {
+ printf(STDERR "$_[0]\n", @_[1 .. $#_]) if DEBUG;
+ };
+ if($@) {
+ warn "WTF: $@ (with @_)";
+ }
}
1;
|
dgl/TwitFolk
|
eca5eb87a064b7354003c48f64cdf52fa34057eb
|
Some thoughts
|
diff --git a/TODO b/TODO
index 28e617c..7586222 100644
--- a/TODO
+++ b/TODO
@@ -1,12 +1,39 @@
+- Fix friends list
+
+I broke adding/refreshing/some nick association stuff.
+
- Ignore features
Would be nice if people / hashtags could be (temporarily?) ignored in some
fashion, for example when an otherwise-interesting person is tweeting about a
conference that's not of interest.
+(Note twitter now extract these for us and provide some information, could make
+use of this).
+
- Self service features
There should be some way for users in the channel to indicate that they want to
be added or removed.
Similarly, they should be able to indicate that their IRC nick has changed.
+
+(Now we can do OAuth they could maybe login to TwitFolk via OAuth -- could even
+go mad and allow them to reply as themselves.)
+
+- Improve use of Streaming API
+
+See http://dev.twitter.com/pages/streaming_api_concepts
+ - Implement back off
+ - Can get duplicates, need to handle
+ - Get back log of tweets
+
+- Fix Identica
+
+I broke identica while refactoring to support streaming API, fix it.
+
+- Make the tweet format configurable
+
+In some cases including things like the geo tag from a tweet might be of
+interest.
+
|
dgl/TwitFolk
|
b9cd3cc99970b071de2ba7c29736882cf0c06f79
|
Fix reconnection
|
diff --git a/TwitFolk.pm b/TwitFolk.pm
index a56625b..67ee04a 100644
--- a/TwitFolk.pm
+++ b/TwitFolk.pm
@@ -1,177 +1,179 @@
=pod
TwitFolk
Gate tweets from your Twitter/identi.ca friends into an IRC channel.
http://dev.bitfolk.com/twitfolk/
Copyright ©2008 Andy Smith <andy+twitfolk.pl@bitfolk.com>
Copyright ©2010 David Leadbeater <dgl@dgl.cx>
Artistic license same as Perl.
$Id: twitfolk.pl 1580 2010-06-10 12:45:21Z andy $
=cut
package TwitFolk;
our $VERSION = "0.2";
use Config::Tiny;
use Moose;
use Try::Tiny;
use TwitFolk::Client::Identica;
use TwitFolk::Client::Twitter;
use TwitFolk::Friends;
use TwitFolk::IRC;
use TwitFolk::Last;
with qw(MooseX::Daemonize);
has config_file => (
isa => "Str",
is => "ro",
default => sub { "twitfolk.conf" }
);
has ircname => (
isa => "Str",
is => "ro",
default => sub { "twitfolk $VERSION" }
);
has _config => (
isa => "HashRef",
is => "ro",
);
has _irc => (
isa => "TwitFolk::IRC",
is => "ro",
default => sub { TwitFolk::IRC->new }
);
has _friends => (
isa => "TwitFolk::Friends",
is => "rw"
);
has _twitter => (
isa => "TwitFolk::Client",
is => "rw"
);
has _identica => (
isa => "TwitFolk::Client",
is => "rw"
);
sub BUILD {
my($self) = @_;
my $config = Config::Tiny->read($self->config_file)
or die Config::Tiny->errstr;
# Only care about the root section for now.
$self->{_config} = $config->{_};
$self->_friends(
TwitFolk::Friends->new(friends_file => $self->_config->{friends_file})
);
$self->pidfile($self->_config->{pidfile});
}
# The "main"
after start => sub {
my($self) = @_;
$SIG{HUP} = sub {
$self->_friends->update;
$self->_twitter->sync if $self->_twitter;
$self->_identica->sync if $self->_identica;
};
try {
$self->connect;
AnyEvent->condvar->recv;
} catch {
# Just the first line, Moose can spew rather long errors
$self->_irc->disconnect("Died: " . (/^(.*)$/m)[0]);
warn $_;
};
};
before shutdown => sub {
my($self) = @_;
$self->_irc->disconnect("Shutdown");
};
sub connect {
my($self) = @_;
my $c = $self->_config;
$self->_irc->connect($self,
$c->{target_server}, $c->{target_port},
{
nick => $c->{nick},
nick_pass => $c->{nick_pass},
user => $c->{username},
real => $self->ircname,
password => $self->{target_pass},
channel => $c->{channel},
away => $c->{away}
}
);
}
# Bot is primed
sub on_join {
my($self) = @_;
+ return if $self->_twitter || $self->_identica;
+
my $last_tweets = TwitFolk::Last->new(
tweet_id_file => $self->_config->{tweet_id_file}
);
# Probably should use traits rather than hardcoded classes like this, too
# lazy though.
if($self->_config->{use_twitter}) {
$self->_twitter(
TwitFolk::Client::Twitter->new(
irc => $self->_irc,
target => "#" . $self->_config->{channel},
consumer_key => $self->_config->{twitter_consumer_key},
consumer_secret => $self->_config->{twitter_consumer_secret},
owner => $self->_config->{owner},
last_tweets => $last_tweets,
friends => $self->_friends,
)
);
$self->_friends->twitter($self->_twitter);
$self->_twitter->sync;
}
if($self->_config->{use_identica}) {
$self->_identica(
TwitFolk::Client::Identica->new(
irc => $self->_irc,
target => "#" . $self->_config->{channel},
username => $self->_config->{identica_user},
password => $self->_config->{identica_pass},
max_tweets => $self->_config->{max_tweets},
last_tweets => $last_tweets,
friends => $self->_friends,
)
);
$self->_friends->identica($self->_identica);
$self->_identica->sync;
}
$self->_friends->update;
}
1;
diff --git a/TwitFolk/IRC.pm b/TwitFolk/IRC.pm
index 613f67b..565807c 100644
--- a/TwitFolk/IRC.pm
+++ b/TwitFolk/IRC.pm
@@ -1,106 +1,108 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::IRC;
-use EV;
+use EV; # AnyEvent::Impl::Perl seems to behave oddly
use strict;
=head1 NAME
TwitFolk::IRC - Lame wrapper around AnyEvent::IRC::Client for TwitFolk
=cut
use base "AnyEvent::IRC::Client";
use AnyEvent::IRC::Util qw(prefix_nick);
use TwitFolk::Log;
sub connect {
my($self, $parent, $addr, $port, $args) = @_;
($self->{twitfolk_connect_cb} = sub {
$self->SUPER::connect($addr, $port, $args);
$self->{parent} = $parent;
$self->{args} = $args;
my $channel = $args->{channel};
$self->send_srv(JOIN => $channel =~ /^#/ ? $channel : "#$channel");
if($args->{away}) {
$self->send_srv(AWAY => $args->{away});
}
- for(qw(registered disconnect join irc_433 irc_notice)) {
- my $callback = "on_$_";
- $self->reg_cb($_ => sub {
- my $irc = shift;
- debug "IRC: $callback: " . (ref($_[0]) eq 'HASH' ? JSON::to_json($_[0]) : "");
- $self->$callback(@_)
- });
- }
})->();
+
+ # Register our callbacks
+ for(qw(registered disconnect join irc_433 irc_notice)) {
+ my $callback = "on_$_";
+ $self->reg_cb($_ => sub {
+ my $irc = shift;
+ debug "IRC: $callback: " . (ref($_[0]) eq 'HASH' ? JSON::to_json($_[0]) : "");
+ $self->$callback(@_)
+ });
+ }
}
sub msg {
my($self, $who, $text) = @_;
$self->send_srv(PRIVMSG => $who, $text);
}
sub notice {
my($self, $who, $text) = @_;
$self->send_srv(NOTICE => $who, $text);
}
sub on_registered {
my($self) = @_;
$self->enable_ping(90);
}
sub on_disconnect {
my($self) = @_;
$self->{reconnect_timer} = AE::timer 10, 0, sub {
undef $self->{reconnect_timer};
$self->{twitfolk_connect_cb}->();
};
}
sub on_join {
my($self, $nick, $channel, $myself) = @_;
$self->{parent}->on_join if $myself;
}
# Nick in use
sub on_irc_433 {
my($self) = @_;
$self->send_srv(NICK => $self->{nick} . $$);
$self->msg("NickServ", "RECOVER $self->{args}->{nick} $self->{args}->{nick_pass}");
}
sub on_irc_notice {
my($self, $msg) = @_;
if(lc prefix_nick($msg) eq 'nickserv') {
local $_ = $msg->{params}->[-1];
if (/This nick is owned by someone else/ ||
/This nickname is registered and protected/i) {
debug("ID to NickServ at request of NickServ");
$self->msg("NickServ", "IDENTIFY $self->{args}->{nick_pass}");
} elsif (/Your nick has been recovered/i) {
debug("NickServ told me I recovered my nick, RELEASE'ing now");
$self->msg("NickServ", "RELEASE $self->{args}->{nick} $self->{args}->{nick_pass}");
} elsif (/Your nick has been released from custody/i) {
debug("NickServ told me my nick is released, /nick'ing now");
$self->send_srv(NICK => $self->{args}->{nick});
} else {
debug("Ignoring NickServ notice: %s", $_);
}
}
}
1;
|
dgl/TwitFolk
|
fea6e943b6cc97dcc655ee9ffeee00a7e9e40852
|
Fix IRC callbacks
|
diff --git a/TwitFolk/IRC.pm b/TwitFolk/IRC.pm
index 86e0be6..613f67b 100644
--- a/TwitFolk/IRC.pm
+++ b/TwitFolk/IRC.pm
@@ -1,105 +1,106 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::IRC;
use EV;
use strict;
=head1 NAME
TwitFolk::IRC - Lame wrapper around AnyEvent::IRC::Client for TwitFolk
=cut
use base "AnyEvent::IRC::Client";
use AnyEvent::IRC::Util qw(prefix_nick);
use TwitFolk::Log;
sub connect {
my($self, $parent, $addr, $port, $args) = @_;
($self->{twitfolk_connect_cb} = sub {
$self->SUPER::connect($addr, $port, $args);
$self->{parent} = $parent;
$self->{args} = $args;
my $channel = $args->{channel};
$self->send_srv(JOIN => $channel =~ /^#/ ? $channel : "#$channel");
if($args->{away}) {
$self->send_srv(AWAY => $args->{away});
}
for(qw(registered disconnect join irc_433 irc_notice)) {
my $callback = "on_$_";
$self->reg_cb($_ => sub {
- debug "IRC: $callback: " . (ref($_[1]) eq 'HASH' ? JSON::to_json($_[1]) : "");
+ my $irc = shift;
+ debug "IRC: $callback: " . (ref($_[0]) eq 'HASH' ? JSON::to_json($_[0]) : "");
$self->$callback(@_)
});
}
})->();
}
sub msg {
my($self, $who, $text) = @_;
$self->send_srv(PRIVMSG => $who, $text);
}
sub notice {
my($self, $who, $text) = @_;
$self->send_srv(NOTICE => $who, $text);
}
sub on_registered {
my($self) = @_;
$self->enable_ping(90);
}
sub on_disconnect {
my($self) = @_;
$self->{reconnect_timer} = AE::timer 10, 0, sub {
undef $self->{reconnect_timer};
$self->{twitfolk_connect_cb}->();
};
}
sub on_join {
my($self, $nick, $channel, $myself) = @_;
$self->{parent}->on_join if $myself;
}
# Nick in use
sub on_irc_433 {
my($self) = @_;
$self->send_srv(NICK => $self->{nick} . $$);
$self->msg("NickServ", "RECOVER $self->{args}->{nick} $self->{args}->{nick_pass}");
}
sub on_irc_notice {
- my($self, $irc, $msg) = @_;
+ my($self, $msg) = @_;
if(lc prefix_nick($msg) eq 'nickserv') {
local $_ = $msg->{params}->[-1];
if (/This nick is owned by someone else/ ||
/This nickname is registered and protected/i) {
debug("ID to NickServ at request of NickServ");
$self->msg("NickServ", "IDENTIFY $self->{args}->{nick_pass}");
} elsif (/Your nick has been recovered/i) {
debug("NickServ told me I recovered my nick, RELEASE'ing now");
$self->msg("NickServ", "RELEASE $self->{args}->{nick} $self->{args}->{nick_pass}");
} elsif (/Your nick has been released from custody/i) {
debug("NickServ told me my nick is released, /nick'ing now");
$self->send_srv(NICK => $self->{args}->{nick});
} else {
debug("Ignoring NickServ notice: %s", $_);
}
}
}
1;
|
dgl/TwitFolk
|
150831bb4de3c3b43101f156aa72dfb6896910fa
|
I invented that class name, validation doesn't seem possible
|
diff --git a/TwitFolk/Client/Identica.pm b/TwitFolk/Client/Identica.pm
index 3b3c338..e028142 100644
--- a/TwitFolk/Client/Identica.pm
+++ b/TwitFolk/Client/Identica.pm
@@ -1,126 +1,126 @@
package TwitFolk::Client::Identica;
use AE;
use Moose;
use Try::Tiny;
use TwitFolk::Log;
extends "TwitFolk::Client";
with qw(TwitFolk::Client::Basic);
has max_tweets => (isa => "Int", is => "ro");
-has sync_timer => (isa => "AnyEvent::Timer", is => "rw");
+has sync_timer => (is => "rw");
sub BUILD {
my($self) = @_;
$self->api_args->{identica} = 1;
$self->sync_timer(
# Every 300 seconds
AE::timer 300, 300, sub {
$self->sync;
}
);
}
sub sync {
my($self) = @_;
my $svcname = "identica"; # lame, but works for now
# Ask for 10 times as many tweets as we will ever say, but no more than
# 200
my $max = $self->max_tweets >= 20 ? 200 : $self->max_tweets * 10;
my $count = 0;
my $opts = { count => $max };
# Ask for the timeline of friend's statuses, only since the last tweet
# if we know its id
$opts->{since_id} = $self->last_tweets->get("identica") if $self->last_id;
# Net::Twitter sometimes dies inside JSON::Any :(
my $tweets;
try {
$tweets = $self->api->friends_timeline($opts);
} catch {
debug("%s->friends_timeline() error: %s", $svcname, $@);
}
return unless $tweets;
if ($self->api->http_code != 200) {
debug("%s->friend_timeline() failed: %s", $svcname,
$self->api->http_message);
return;
}
=pod
$tweets should now be a reference to an array of:
{
'source' => 'web',
'favorited' => $VAR1->[0]{'favorited'},
'truncated' => $VAR1->[0]{'favorited'},
'created_at' => 'Tue Oct 28 22:22:14 +0000 2008',
'text' => '@deltafan121 Near Luton, which is just outside London.',
'user' => {
'location' => 'Bedfordshire, United Kingdom',
'followers_count' => 10,
'profile_image_url' => 'http://s3.amazonaws.com/twitter_production/profile_images/62344418/SP_A0089_2_normal.jpg',
'protected' => $VAR1->[0]{'favorited'},
'name' => 'Robert Leverington',
'url' => 'http://robertleverington.com/',
'id' => 14450923,
'description' => '',
'screen_name' => 'roberthl'
},
'in_reply_to_user_id' => 14662919,
'id' => 979630447,
'in_reply_to_status_id' => 979535561
}
=cut
=pod
But I guess we better check, since this happened one time at band camp:
Tue Nov 18 07:58:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Tue Nov 18 08:03:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Tue Nov 18 08:08:50 2008| *** twitter->friend_timelines() failed: read timeout
Tue Nov 18 08:13:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Tue Nov 18 08:18:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Tue Nov 18 08:23:43 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Not an ARRAY reference at ./twitfolk.pl line 494.
=cut
if (ref($tweets) ne "ARRAY") {
debug("%s->friend_timelines() didn't return an arrayref!", $svcname);
return;
}
debug("Got %u new tweets from %s", scalar @$tweets, $svcname);
# Iterate through them all, sorted by id low to high
for my $tweet (sort { $a->{id} <=> $b->{id} } @{ $tweets }) {
if ($count >= $self->max_tweets) {
debug("Already did %u tweets, stopping there", $count);
last;
}
if ($tweet->{id} <= $self->last_tweets->get("identica")) {
# Why does Twitter still return tweets that are <= since_id?
debug("%s/%s: ignored as somehow <= %s !?", $svcname,
$tweet->{id}, $self->last_tweets->get("identica"));
next;
}
$self->on_update($tweet);
$self->last_tweets->update(identica => $tweet->{id});
$count++;
}
}
1;
diff --git a/TwitFolk/Client/Twitter.pm b/TwitFolk/Client/Twitter.pm
index 632f83d..d55a7d5 100644
--- a/TwitFolk/Client/Twitter.pm
+++ b/TwitFolk/Client/Twitter.pm
@@ -1,110 +1,110 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::Client::Twitter;
use Moose;
use AnyEvent::IRC::Util qw(prefix_nick);
use AnyEvent::Twitter::Stream;
use Try::Tiny;
use TwitFolk::Log;
extends "TwitFolk::Client";
with qw(TwitFolk::Client::OAuth);
# Who to contact when we need OAuth fixing
has owner => (isa => "Str", is => "rw");
# Our listener for tweets
has listener => (isa => "Maybe[AnyEvent::Twitter::Stream]", is => "rw");
# Timer for reconnections
-has reconnect_timer => (isa => "Maybe[AnyEvent::Timer]", is => "rw");
+has reconnect_timer => (is => "rw");
sub BUILD {
my($self) = @_;
$self->irc->reg_cb(privatemsg => sub { $self->on_privmsg(@_) });
}
sub sync {
my($self) = @_;
try {
if($self->authorize) {
$self->start_stream;
}
} catch {
warn "Can't sync: $_";
};
}
sub need_authorization {
my($self, $url) = @_;
$self->irc->msg($self->owner,
"Please could you be so kind as to login as me on Twitter, go to $url and then msg me with the pin, thank you!");
}
sub on_privmsg {
my($self, $irc, $nick, $msg) = @_;
if(lc prefix_nick($msg) eq $self->owner
&& $msg->{params}->[-1] =~ /^(\d+)\s*$/) {
try {
$self->authorization_response($1);
$self->irc->msg($self->owner, "Most excellent, sir!");
$self->start_stream;
} catch {
$self->irc->msg($self->owner, "Sorry, that didn't seem to work: $_");
}
}
}
sub reconnect {
my($self) = @_;
$self->listener(undef);
$self->reconnect_timer(
AE::timer 10, 0, sub {
$self->reconnect_timer(undef);
debug "Reconnecting to twitter...";
$self->sync;
}
);
}
sub start_stream {
my($self) = @_;
return if $self->listener;
debug "Starting stream";
$self->listener(
AnyEvent::Twitter::Stream->new(
consumer_key => $self->consumer_key,
consumer_secret => $self->consumer_secret,
token => $self->access_token,
token_secret => $self->access_token_secret,
method => "userstream",
on_tweet => sub {
my($tweet) = @_;
debug "on_tweet: " . JSON::to_json($tweet);
return unless $tweet->{user};
$self->on_update($tweet);
$self->last_tweets->update(twitter => $tweet->{id}); # This is totally pointless with streaming API, but doesn't hurt
},
on_error => sub {
debug "Error from twitter stream: @_";
$self->reconnect;
},
on_eof => sub {
debug "EOF from twitter stream";
$self->reconnect;
},
)
);
}
1;
|
dgl/TwitFolk
|
aeb51bf7c1fa5f44d20488e6ba14664b1fb88c02
|
Fix friends + other cleanups
|
diff --git a/TwitFolk.pm b/TwitFolk.pm
index 3ced278..a56625b 100644
--- a/TwitFolk.pm
+++ b/TwitFolk.pm
@@ -1,175 +1,177 @@
=pod
TwitFolk
Gate tweets from your Twitter/identi.ca friends into an IRC channel.
http://dev.bitfolk.com/twitfolk/
Copyright ©2008 Andy Smith <andy+twitfolk.pl@bitfolk.com>
Copyright ©2010 David Leadbeater <dgl@dgl.cx>
Artistic license same as Perl.
$Id: twitfolk.pl 1580 2010-06-10 12:45:21Z andy $
=cut
package TwitFolk;
our $VERSION = "0.2";
use Config::Tiny;
use Moose;
use Try::Tiny;
use TwitFolk::Client::Identica;
use TwitFolk::Client::Twitter;
use TwitFolk::Friends;
use TwitFolk::IRC;
use TwitFolk::Last;
with qw(MooseX::Daemonize);
has config_file => (
isa => "Str",
is => "ro",
default => sub { "twitfolk.conf" }
);
has ircname => (
isa => "Str",
is => "ro",
default => sub { "twitfolk $VERSION" }
);
has _config => (
isa => "HashRef",
is => "ro",
);
has _irc => (
isa => "TwitFolk::IRC",
is => "ro",
default => sub { TwitFolk::IRC->new }
);
has _friends => (
isa => "TwitFolk::Friends",
is => "rw"
);
has _twitter => (
isa => "TwitFolk::Client",
is => "rw"
);
has _identica => (
isa => "TwitFolk::Client",
is => "rw"
);
sub BUILD {
my($self) = @_;
my $config = Config::Tiny->read($self->config_file)
or die Config::Tiny->errstr;
# Only care about the root section for now.
$self->{_config} = $config->{_};
$self->_friends(
TwitFolk::Friends->new(friends_file => $self->_config->{friends_file})
);
$self->pidfile($self->_config->{pidfile});
}
# The "main"
after start => sub {
my($self) = @_;
$SIG{HUP} = sub {
$self->_friends->update;
$self->_twitter->sync if $self->_twitter;
$self->_identica->sync if $self->_identica;
};
try {
$self->connect;
AnyEvent->condvar->recv;
} catch {
# Just the first line, Moose can spew rather long errors
$self->_irc->disconnect("Died: " . (/^(.*)$/m)[0]);
warn $_;
};
};
before shutdown => sub {
my($self) = @_;
$self->_irc->disconnect("Shutdown");
};
sub connect {
my($self) = @_;
my $c = $self->_config;
$self->_irc->connect($self,
$c->{target_server}, $c->{target_port},
{
nick => $c->{nick},
nick_pass => $c->{nick_pass},
user => $c->{username},
real => $self->ircname,
password => $self->{target_pass},
channel => $c->{channel},
away => $c->{away}
}
);
}
# Bot is primed
sub on_join {
my($self) = @_;
my $last_tweets = TwitFolk::Last->new(
tweet_id_file => $self->_config->{tweet_id_file}
);
# Probably should use traits rather than hardcoded classes like this, too
# lazy though.
if($self->_config->{use_twitter}) {
$self->_twitter(
TwitFolk::Client::Twitter->new(
irc => $self->_irc,
target => "#" . $self->_config->{channel},
consumer_key => $self->_config->{twitter_consumer_key},
consumer_secret => $self->_config->{twitter_consumer_secret},
owner => $self->_config->{owner},
last_tweets => $last_tweets,
friends => $self->_friends,
)
);
$self->_friends->twitter($self->_twitter);
$self->_twitter->sync;
}
if($self->_config->{use_identica}) {
$self->_identica(
TwitFolk::Client::Identica->new(
irc => $self->_irc,
target => "#" . $self->_config->{channel},
username => $self->_config->{identica_user},
password => $self->_config->{identica_pass},
max_tweets => $self->_config->{max_tweets},
last_tweets => $last_tweets,
friends => $self->_friends,
)
);
$self->_friends->identica($self->_identica);
$self->_identica->sync;
}
+
+ $self->_friends->update;
}
1;
diff --git a/TwitFolk/Client.pm b/TwitFolk/Client.pm
index e1e18f5..9f4559e 100644
--- a/TwitFolk/Client.pm
+++ b/TwitFolk/Client.pm
@@ -1,42 +1,42 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::Client;
use Moose;
use TwitFolk::Log;
use HTML::Entities;
use Encode qw(encode_utf8);
has irc => (isa => "TwitFolk::IRC", is => "ro");
has target => (isa => "Str", is => "ro");
has friends => (isa => "TwitFolk::Friends", is => "ro");
has last_tweets => (isa => "TwitFolk::Last", is => "ro");
sub on_update {
my($self, $update) = @_;
my $screen_name = $update->{user}->{screen_name};
my $nick = $self->friends->lookup_nick($screen_name);
my $text = decode_entities $update->{text};
# Skip tweets directed at others who aren't friends
if ($text =~ /^@([[:alnum:]_]+)/) {
my $other_sn = lc($1);
unless (grep { lc($_) eq $other_sn } keys %{$self->friends->friends}) {
debug("Ignoring reply tweet %s from [%s] to [%s]",
$update->{id}, $screen_name, $other_sn);
return;
}
}
debug("%s/%s: [%s/\@%s] %s", ref $self, $update->{id}, $nick, $screen_name, $text);
if ($text =~ /[\n\r]/) {
- irc_debug("%s/%s contains dangerous characters; removing!",
+ debug("%s/%s contains dangerous characters; removing!",
ref $self, $update->{id});
$text =~ s/[\n\r]/ /g;
}
$self->irc->notice($self->target, encode_utf8 sprintf("[%s/\@%s] %s",
$nick, $screen_name, $text));
}
1;
diff --git a/TwitFolk/Client/Identica.pm b/TwitFolk/Client/Identica.pm
index bd0e2e5..3b3c338 100644
--- a/TwitFolk/Client/Identica.pm
+++ b/TwitFolk/Client/Identica.pm
@@ -1,120 +1,126 @@
package TwitFolk::Client::Identica;
use AE;
use Moose;
use Try::Tiny;
use TwitFolk::Log;
extends "TwitFolk::Client";
with qw(TwitFolk::Client::Basic);
-has max_tweets => (isa => "Int", is => "ro");
+has max_tweets => (isa => "Int", is => "ro");
+has sync_timer => (isa => "AnyEvent::Timer", is => "rw");
sub BUILD {
my($self) = @_;
$self->api_args->{identica} = 1;
- AE::timer 300, 300, sub { $self->sync };
+ $self->sync_timer(
+ # Every 300 seconds
+ AE::timer 300, 300, sub {
+ $self->sync;
+ }
+ );
}
sub sync {
my($self) = @_;
my $svcname = "identica"; # lame, but works for now
# Ask for 10 times as many tweets as we will ever say, but no more than
# 200
my $max = $self->max_tweets >= 20 ? 200 : $self->max_tweets * 10;
my $count = 0;
my $opts = { count => $max };
# Ask for the timeline of friend's statuses, only since the last tweet
# if we know its id
$opts->{since_id} = $self->last_tweets->get("identica") if $self->last_id;
# Net::Twitter sometimes dies inside JSON::Any :(
my $tweets;
try {
$tweets = $self->api->friends_timeline($opts);
} catch {
debug("%s->friends_timeline() error: %s", $svcname, $@);
}
return unless $tweets;
if ($self->api->http_code != 200) {
debug("%s->friend_timeline() failed: %s", $svcname,
$self->api->http_message);
return;
}
=pod
$tweets should now be a reference to an array of:
{
'source' => 'web',
'favorited' => $VAR1->[0]{'favorited'},
'truncated' => $VAR1->[0]{'favorited'},
'created_at' => 'Tue Oct 28 22:22:14 +0000 2008',
'text' => '@deltafan121 Near Luton, which is just outside London.',
'user' => {
'location' => 'Bedfordshire, United Kingdom',
'followers_count' => 10,
'profile_image_url' => 'http://s3.amazonaws.com/twitter_production/profile_images/62344418/SP_A0089_2_normal.jpg',
'protected' => $VAR1->[0]{'favorited'},
'name' => 'Robert Leverington',
'url' => 'http://robertleverington.com/',
'id' => 14450923,
'description' => '',
'screen_name' => 'roberthl'
},
'in_reply_to_user_id' => 14662919,
'id' => 979630447,
'in_reply_to_status_id' => 979535561
}
=cut
=pod
But I guess we better check, since this happened one time at band camp:
Tue Nov 18 07:58:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Tue Nov 18 08:03:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Tue Nov 18 08:08:50 2008| *** twitter->friend_timelines() failed: read timeout
Tue Nov 18 08:13:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Tue Nov 18 08:18:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Tue Nov 18 08:23:43 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Not an ARRAY reference at ./twitfolk.pl line 494.
=cut
if (ref($tweets) ne "ARRAY") {
debug("%s->friend_timelines() didn't return an arrayref!", $svcname);
return;
}
debug("Got %u new tweets from %s", scalar @$tweets, $svcname);
# Iterate through them all, sorted by id low to high
for my $tweet (sort { $a->{id} <=> $b->{id} } @{ $tweets }) {
if ($count >= $self->max_tweets) {
debug("Already did %u tweets, stopping there", $count);
last;
}
if ($tweet->{id} <= $self->last_tweets->get("identica")) {
# Why does Twitter still return tweets that are <= since_id?
debug("%s/%s: ignored as somehow <= %s !?", $svcname,
$tweet->{id}, $self->last_tweets->get("identica"));
next;
}
$self->on_update($tweet);
$self->last_tweets->update(identica => $tweet->{id});
$count++;
}
}
1;
diff --git a/TwitFolk/Client/Twitter.pm b/TwitFolk/Client/Twitter.pm
index 8b1628b..632f83d 100644
--- a/TwitFolk/Client/Twitter.pm
+++ b/TwitFolk/Client/Twitter.pm
@@ -1,104 +1,110 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::Client::Twitter;
use Moose;
use AnyEvent::IRC::Util qw(prefix_nick);
use AnyEvent::Twitter::Stream;
use Try::Tiny;
use TwitFolk::Log;
extends "TwitFolk::Client";
with qw(TwitFolk::Client::OAuth);
# Who to contact when we need OAuth fixing
has owner => (isa => "Str", is => "rw");
# Our listener for tweets
has listener => (isa => "Maybe[AnyEvent::Twitter::Stream]", is => "rw");
+# Timer for reconnections
+has reconnect_timer => (isa => "Maybe[AnyEvent::Timer]", is => "rw");
+
sub BUILD {
my($self) = @_;
$self->irc->reg_cb(privatemsg => sub { $self->on_privmsg(@_) });
}
sub sync {
my($self) = @_;
try {
if($self->authorize) {
$self->start_stream;
}
} catch {
warn "Can't sync: $_";
};
}
sub need_authorization {
my($self, $url) = @_;
$self->irc->msg($self->owner,
"Please could you be so kind as to login as me on Twitter, go to $url and then msg me with the pin, thank you!");
}
sub on_privmsg {
my($self, $irc, $nick, $msg) = @_;
if(lc prefix_nick($msg) eq $self->owner
&& $msg->{params}->[-1] =~ /^(\d+)\s*$/) {
try {
$self->authorization_response($1);
$self->irc->msg($self->owner, "Most excellent, sir!");
$self->start_stream;
} catch {
$self->irc->msg($self->owner, "Sorry, that didn't seem to work: $_");
}
}
}
sub reconnect {
my($self) = @_;
$self->listener(undef);
- AE::timer 10, 0, sub {
- debug "Reconnecting to twitter...";
- $self->sync;
- }
+ $self->reconnect_timer(
+ AE::timer 10, 0, sub {
+ $self->reconnect_timer(undef);
+ debug "Reconnecting to twitter...";
+ $self->sync;
+ }
+ );
}
sub start_stream {
my($self) = @_;
return if $self->listener;
debug "Starting stream";
$self->listener(
AnyEvent::Twitter::Stream->new(
consumer_key => $self->consumer_key,
consumer_secret => $self->consumer_secret,
token => $self->access_token,
token_secret => $self->access_token_secret,
method => "userstream",
on_tweet => sub {
my($tweet) = @_;
debug "on_tweet: " . JSON::to_json($tweet);
return unless $tweet->{user};
$self->on_update($tweet);
$self->last_tweets->update(twitter => $tweet->{id}); # This is totally pointless with streaming API, but doesn't hurt
},
on_error => sub {
debug "Error from twitter stream: @_";
$self->reconnect;
},
on_eof => sub {
debug "EOF from twitter stream";
$self->reconnect;
},
)
);
}
1;
diff --git a/TwitFolk/Friends.pm b/TwitFolk/Friends.pm
index 2419789..47cb79c 100644
--- a/TwitFolk/Friends.pm
+++ b/TwitFolk/Friends.pm
@@ -1,155 +1,133 @@
package TwitFolk::Friends;
use Moose;
use Try::Tiny;
use TwitFolk::Log;
has friends_file => (isa => "Str", is => "ro");
has twitter => (isa => "TwitFolk::Client", is => "rw");
has identica => (isa => "TwitFolk::Client", is => "rw");
has friends => (isa => "HashRef", is => "rw", default => sub { {} });
=head2 lookup_nick
Return the nick associated with the screen name, or the screen name if nick is
not known.
=cut
sub lookup_nick {
my($self, $screen_name) = @_;
if(exists $self->friends->{lc $screen_name}) {
return $self->friends->{lc $screen_name}->{nick};
}
return $screen_name;
}
=head2 update
Read a list of friends from the friends_file. These will be friended in
Twitter if they aren't already. Format is:
screen_name IRC_nick service
Start a line with # for a comment. Any kind of white space is okay.
Service column may be 'twitter' or 'identica', defaulting to twitter if
none is specified.
=cut
sub update
{
my $self = shift;
open my $ff, "<", $self->friends_file or die "Couldn't open friends_file: $!";
while (<$ff>) {
next if (/^#/);
if (/^(\S+)\s+(\S+)(?:\s+(\S+))?/) {
my $f = lc($1);
my $nick = $2;
my $svcname = $3 || 'twitter';
if (!exists $self->friends->{$f}) {
my $u;
my $svc;
# Friend may be on identi.ca OR twitter
$svc = ($svcname =~ /dent/i) ? $self->identica->api : $self->twitter->api;
- # Net::Twitter sometimes dies inside JSON::Any :(
try {
$u = $svc->show_user($f);
} catch {
debug("%s->show_user(%s) error: %s", $svcname, $f, $_);
- next;
};
- if ($svc->http_code != 200) {
- debug("%s->show_user(%s) failed: %s", $svcname, $f,
- $svc->http_message);
- next;
- }
-
my $id = $u->{id};
$self->friends->{$f}->{id} = $id;
debug("%s: Adding new friend '%s' (%lu)", $svcname,
$f, $id);
- # Net::Twitter sometimes dies inside JSON::Any :(
try {
$svc->create_friend($id);
} catch {
debug("%s->create_friend(%lu) error: %s",
$svcname, $id, $_);
- next;
};
- if ($svc->http_code != 200) {
- debug("%s->create_friend($id) failed: %s",
- $svcname, $svc->http_message);
- }
+ $self->friends->{$f}->{nick} = $nick;
}
-
- $self->friends->{$f}->{nick} = $nick;
}
}
-
close $ff or warn "Something weird when closing friends_file: $!";
}
=head1 sync
Learn friends from those already added in Twitter, just in case they got added
from outside as well. Might make this update the friends file at some point.
=cut
sub sync
{
my $self = shift;
my $svc = shift;
my $svcname = shift;
my $twitter_friends;
- # Net::Twitter sometimes dies inside JSON::Any :(
try {
$twitter_friends = $svc->friends;
} catch {
debug("%s->friends() error: %s", $svcname, $_);
};
return unless $twitter_friends;
- if ($svc->http_code != 200) {
- debug("%s->friends() failed: %s", $svcname, $svc->http_message);
- return;
- }
-
if (ref($twitter_friends) ne "ARRAY") {
debug("%s->friends() didn't return an arrayref!", $svcname);
return;
}
for my $f (@{$twitter_friends}) {
my $screen_name = lc($f->{screen_name});
my $id = $f->{id};
$self->friends->{$screen_name}->{id} = $id;
if (! defined $self->friends->{$screen_name}->{nick}) {
$self->friends->{$screen_name}->{nick} = $screen_name;
}
debug("%s: Already following '%s' (%lu)", $svcname, $screen_name,
$self->friends->{$screen_name}->{id});
}
}
1;
diff --git a/TwitFolk/IRC.pm b/TwitFolk/IRC.pm
index 3148d92..86e0be6 100644
--- a/TwitFolk/IRC.pm
+++ b/TwitFolk/IRC.pm
@@ -1,101 +1,105 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::IRC;
use EV;
use strict;
=head1 NAME
TwitFolk::IRC - Lame wrapper around AnyEvent::IRC::Client for TwitFolk
=cut
use base "AnyEvent::IRC::Client";
use AnyEvent::IRC::Util qw(prefix_nick);
use TwitFolk::Log;
sub connect {
my($self, $parent, $addr, $port, $args) = @_;
($self->{twitfolk_connect_cb} = sub {
$self->SUPER::connect($addr, $port, $args);
$self->{parent} = $parent;
$self->{args} = $args;
my $channel = $args->{channel};
$self->send_srv(JOIN => $channel =~ /^#/ ? $channel : "#$channel");
if($args->{away}) {
$self->send_srv(AWAY => $args->{away});
}
for(qw(registered disconnect join irc_433 irc_notice)) {
my $callback = "on_$_";
$self->reg_cb($_ => sub {
debug "IRC: $callback: " . (ref($_[1]) eq 'HASH' ? JSON::to_json($_[1]) : "");
$self->$callback(@_)
});
}
})->();
}
sub msg {
my($self, $who, $text) = @_;
$self->send_srv(PRIVMSG => $who, $text);
}
sub notice {
my($self, $who, $text) = @_;
$self->send_srv(NOTICE => $who, $text);
}
sub on_registered {
my($self) = @_;
$self->enable_ping(90);
}
sub on_disconnect {
my($self) = @_;
- AE::timer 10, 0, sub { $self->{twitfolk_connect_cb}->() };
+
+ $self->{reconnect_timer} = AE::timer 10, 0, sub {
+ undef $self->{reconnect_timer};
+ $self->{twitfolk_connect_cb}->();
+ };
}
sub on_join {
my($self, $nick, $channel, $myself) = @_;
$self->{parent}->on_join if $myself;
}
# Nick in use
sub on_irc_433 {
my($self) = @_;
$self->send_srv(NICK => $self->{nick} . $$);
$self->msg("NickServ", "RECOVER $self->{args}->{nick} $self->{args}->{nick_pass}");
}
sub on_irc_notice {
my($self, $irc, $msg) = @_;
if(lc prefix_nick($msg) eq 'nickserv') {
local $_ = $msg->{params}->[-1];
if (/This nick is owned by someone else/ ||
/This nickname is registered and protected/i) {
debug("ID to NickServ at request of NickServ");
$self->msg("NickServ", "IDENTIFY $self->{args}->{nick_pass}");
} elsif (/Your nick has been recovered/i) {
debug("NickServ told me I recovered my nick, RELEASE'ing now");
$self->msg("NickServ", "RELEASE $self->{args}->{nick} $self->{args}->{nick_pass}");
} elsif (/Your nick has been released from custody/i) {
debug("NickServ told me my nick is released, /nick'ing now");
$self->send_srv(NICK => $self->{args}->{nick});
} else {
debug("Ignoring NickServ notice: %s", $_);
}
}
}
1;
|
dgl/TwitFolk
|
cd3ab80a7c361fcf11e447cd3e4424650ea2a15b
|
Timeout seems to not work
|
diff --git a/TwitFolk/Client/Twitter.pm b/TwitFolk/Client/Twitter.pm
index 79f38ef..8b1628b 100644
--- a/TwitFolk/Client/Twitter.pm
+++ b/TwitFolk/Client/Twitter.pm
@@ -1,105 +1,104 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::Client::Twitter;
use Moose;
use AnyEvent::IRC::Util qw(prefix_nick);
use AnyEvent::Twitter::Stream;
use Try::Tiny;
use TwitFolk::Log;
extends "TwitFolk::Client";
with qw(TwitFolk::Client::OAuth);
# Who to contact when we need OAuth fixing
has owner => (isa => "Str", is => "rw");
# Our listener for tweets
has listener => (isa => "Maybe[AnyEvent::Twitter::Stream]", is => "rw");
sub BUILD {
my($self) = @_;
$self->irc->reg_cb(privatemsg => sub { $self->on_privmsg(@_) });
}
sub sync {
my($self) = @_;
try {
if($self->authorize) {
$self->start_stream;
}
} catch {
warn "Can't sync: $_";
};
}
sub need_authorization {
my($self, $url) = @_;
$self->irc->msg($self->owner,
"Please could you be so kind as to login as me on Twitter, go to $url and then msg me with the pin, thank you!");
}
sub on_privmsg {
my($self, $irc, $nick, $msg) = @_;
if(lc prefix_nick($msg) eq $self->owner
&& $msg->{params}->[-1] =~ /^(\d+)\s*$/) {
try {
$self->authorization_response($1);
$self->irc->msg($self->owner, "Most excellent, sir!");
$self->start_stream;
} catch {
$self->irc->msg($self->owner, "Sorry, that didn't seem to work: $_");
}
}
}
sub reconnect {
my($self) = @_;
$self->listener(undef);
AE::timer 10, 0, sub {
debug "Reconnecting to twitter...";
$self->sync;
}
}
sub start_stream {
my($self) = @_;
return if $self->listener;
debug "Starting stream";
$self->listener(
AnyEvent::Twitter::Stream->new(
consumer_key => $self->consumer_key,
consumer_secret => $self->consumer_secret,
token => $self->access_token,
token_secret => $self->access_token_secret,
method => "userstream",
- timeout => 180,
on_tweet => sub {
my($tweet) = @_;
debug "on_tweet: " . JSON::to_json($tweet);
return unless $tweet->{user};
$self->on_update($tweet);
$self->last_tweets->update(twitter => $tweet->{id}); # This is totally pointless with streaming API, but doesn't hurt
},
on_error => sub {
debug "Error from twitter stream: @_";
$self->reconnect;
},
on_eof => sub {
debug "EOF from twitter stream";
$self->reconnect;
},
)
);
}
1;
|
dgl/TwitFolk
|
1b16baf276ce8bc67b1dc43e6394e2b05241b0fc
|
Helps if you can set the attribute to undef
|
diff --git a/TwitFolk/Client/Twitter.pm b/TwitFolk/Client/Twitter.pm
index 73219f1..79f38ef 100644
--- a/TwitFolk/Client/Twitter.pm
+++ b/TwitFolk/Client/Twitter.pm
@@ -1,105 +1,105 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::Client::Twitter;
use Moose;
use AnyEvent::IRC::Util qw(prefix_nick);
use AnyEvent::Twitter::Stream;
use Try::Tiny;
use TwitFolk::Log;
extends "TwitFolk::Client";
with qw(TwitFolk::Client::OAuth);
# Who to contact when we need OAuth fixing
has owner => (isa => "Str", is => "rw");
# Our listener for tweets
-has listener => (isa => "AnyEvent::Twitter::Stream", is => "rw");
+has listener => (isa => "Maybe[AnyEvent::Twitter::Stream]", is => "rw");
sub BUILD {
my($self) = @_;
$self->irc->reg_cb(privatemsg => sub { $self->on_privmsg(@_) });
}
sub sync {
my($self) = @_;
try {
if($self->authorize) {
$self->start_stream;
}
} catch {
warn "Can't sync: $_";
};
}
sub need_authorization {
my($self, $url) = @_;
$self->irc->msg($self->owner,
"Please could you be so kind as to login as me on Twitter, go to $url and then msg me with the pin, thank you!");
}
sub on_privmsg {
my($self, $irc, $nick, $msg) = @_;
if(lc prefix_nick($msg) eq $self->owner
&& $msg->{params}->[-1] =~ /^(\d+)\s*$/) {
try {
$self->authorization_response($1);
$self->irc->msg($self->owner, "Most excellent, sir!");
$self->start_stream;
} catch {
$self->irc->msg($self->owner, "Sorry, that didn't seem to work: $_");
}
}
}
sub reconnect {
my($self) = @_;
$self->listener(undef);
AE::timer 10, 0, sub {
debug "Reconnecting to twitter...";
$self->sync;
}
}
sub start_stream {
my($self) = @_;
return if $self->listener;
debug "Starting stream";
$self->listener(
AnyEvent::Twitter::Stream->new(
consumer_key => $self->consumer_key,
consumer_secret => $self->consumer_secret,
token => $self->access_token,
token_secret => $self->access_token_secret,
method => "userstream",
timeout => 180,
on_tweet => sub {
my($tweet) = @_;
debug "on_tweet: " . JSON::to_json($tweet);
return unless $tweet->{user};
$self->on_update($tweet);
$self->last_tweets->update(twitter => $tweet->{id}); # This is totally pointless with streaming API, but doesn't hurt
},
on_error => sub {
debug "Error from twitter stream: @_";
$self->reconnect;
},
on_eof => sub {
debug "EOF from twitter stream";
$self->reconnect;
},
)
);
}
1;
|
dgl/TwitFolk
|
40197f3651ccacfa9eee888e9664ca6a25a5f6d2
|
Attempt to stop multiple connections
|
diff --git a/TwitFolk/Client/Twitter.pm b/TwitFolk/Client/Twitter.pm
index b36fb98..73219f1 100644
--- a/TwitFolk/Client/Twitter.pm
+++ b/TwitFolk/Client/Twitter.pm
@@ -1,101 +1,105 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::Client::Twitter;
use Moose;
use AnyEvent::IRC::Util qw(prefix_nick);
use AnyEvent::Twitter::Stream;
use Try::Tiny;
use TwitFolk::Log;
extends "TwitFolk::Client";
with qw(TwitFolk::Client::OAuth);
# Who to contact when we need OAuth fixing
has owner => (isa => "Str", is => "rw");
# Our listener for tweets
has listener => (isa => "AnyEvent::Twitter::Stream", is => "rw");
sub BUILD {
my($self) = @_;
$self->irc->reg_cb(privatemsg => sub { $self->on_privmsg(@_) });
}
sub sync {
my($self) = @_;
try {
if($self->authorize) {
$self->start_stream;
}
} catch {
warn "Can't sync: $_";
};
}
sub need_authorization {
my($self, $url) = @_;
$self->irc->msg($self->owner,
"Please could you be so kind as to login as me on Twitter, go to $url and then msg me with the pin, thank you!");
}
sub on_privmsg {
my($self, $irc, $nick, $msg) = @_;
if(lc prefix_nick($msg) eq $self->owner
&& $msg->{params}->[-1] =~ /^(\d+)\s*$/) {
try {
$self->authorization_response($1);
$self->irc->msg($self->owner, "Most excellent, sir!");
$self->start_stream;
} catch {
$self->irc->msg($self->owner, "Sorry, that didn't seem to work: $_");
}
}
}
sub reconnect {
my($self) = @_;
+ $self->listener(undef);
+
AE::timer 10, 0, sub {
debug "Reconnecting to twitter...";
$self->sync;
}
}
sub start_stream {
my($self) = @_;
+ return if $self->listener;
debug "Starting stream";
$self->listener(
AnyEvent::Twitter::Stream->new(
consumer_key => $self->consumer_key,
consumer_secret => $self->consumer_secret,
token => $self->access_token,
token_secret => $self->access_token_secret,
method => "userstream",
+ timeout => 180,
on_tweet => sub {
my($tweet) = @_;
debug "on_tweet: " . JSON::to_json($tweet);
return unless $tweet->{user};
$self->on_update($tweet);
$self->last_tweets->update(twitter => $tweet->{id}); # This is totally pointless with streaming API, but doesn't hurt
},
on_error => sub {
debug "Error from twitter stream: @_";
$self->reconnect;
},
on_eof => sub {
debug "EOF from twitter stream";
$self->reconnect;
},
)
);
}
1;
|
dgl/TwitFolk
|
cf2d43796bb1b1f5bf1f789391818c7ef9f2ab05
|
Correctly set api param for identica
|
diff --git a/TwitFolk/Client/Identica.pm b/TwitFolk/Client/Identica.pm
index 90b9198..bd0e2e5 100644
--- a/TwitFolk/Client/Identica.pm
+++ b/TwitFolk/Client/Identica.pm
@@ -1,120 +1,120 @@
package TwitFolk::Client::Identica;
use AE;
use Moose;
use Try::Tiny;
use TwitFolk::Log;
extends "TwitFolk::Client";
with qw(TwitFolk::Client::Basic);
has max_tweets => (isa => "Int", is => "ro");
sub BUILD {
my($self) = @_;
- $self->api_args({ identica => 1 });
+ $self->api_args->{identica} = 1;
AE::timer 300, 300, sub { $self->sync };
}
sub sync {
my($self) = @_;
my $svcname = "identica"; # lame, but works for now
# Ask for 10 times as many tweets as we will ever say, but no more than
# 200
my $max = $self->max_tweets >= 20 ? 200 : $self->max_tweets * 10;
my $count = 0;
my $opts = { count => $max };
# Ask for the timeline of friend's statuses, only since the last tweet
# if we know its id
$opts->{since_id} = $self->last_tweets->get("identica") if $self->last_id;
# Net::Twitter sometimes dies inside JSON::Any :(
my $tweets;
try {
$tweets = $self->api->friends_timeline($opts);
} catch {
debug("%s->friends_timeline() error: %s", $svcname, $@);
}
return unless $tweets;
if ($self->api->http_code != 200) {
debug("%s->friend_timeline() failed: %s", $svcname,
$self->api->http_message);
return;
}
=pod
$tweets should now be a reference to an array of:
{
'source' => 'web',
'favorited' => $VAR1->[0]{'favorited'},
'truncated' => $VAR1->[0]{'favorited'},
'created_at' => 'Tue Oct 28 22:22:14 +0000 2008',
'text' => '@deltafan121 Near Luton, which is just outside London.',
'user' => {
'location' => 'Bedfordshire, United Kingdom',
'followers_count' => 10,
'profile_image_url' => 'http://s3.amazonaws.com/twitter_production/profile_images/62344418/SP_A0089_2_normal.jpg',
'protected' => $VAR1->[0]{'favorited'},
'name' => 'Robert Leverington',
'url' => 'http://robertleverington.com/',
'id' => 14450923,
'description' => '',
'screen_name' => 'roberthl'
},
'in_reply_to_user_id' => 14662919,
'id' => 979630447,
'in_reply_to_status_id' => 979535561
}
=cut
=pod
But I guess we better check, since this happened one time at band camp:
Tue Nov 18 07:58:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Tue Nov 18 08:03:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Tue Nov 18 08:08:50 2008| *** twitter->friend_timelines() failed: read timeout
Tue Nov 18 08:13:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Tue Nov 18 08:18:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Tue Nov 18 08:23:43 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
Not an ARRAY reference at ./twitfolk.pl line 494.
=cut
if (ref($tweets) ne "ARRAY") {
debug("%s->friend_timelines() didn't return an arrayref!", $svcname);
return;
}
debug("Got %u new tweets from %s", scalar @$tweets, $svcname);
# Iterate through them all, sorted by id low to high
for my $tweet (sort { $a->{id} <=> $b->{id} } @{ $tweets }) {
if ($count >= $self->max_tweets) {
debug("Already did %u tweets, stopping there", $count);
last;
}
if ($tweet->{id} <= $self->last_tweets->get("identica")) {
# Why does Twitter still return tweets that are <= since_id?
debug("%s/%s: ignored as somehow <= %s !?", $svcname,
$tweet->{id}, $self->last_tweets->get("identica"));
next;
}
$self->on_update($tweet);
$self->last_tweets->update(identica => $tweet->{id});
$count++;
}
}
1;
|
dgl/TwitFolk
|
76964aa5c95d5c07cbf46c428ac8feb06ec90dbe
|
Needs some more modules
|
diff --git a/README b/README
index 0c0a83b..7faf65a 100644
--- a/README
+++ b/README
@@ -1,80 +1,81 @@
TwitFolk - an IRC/Twitter gateway bot
=====================================
Overview
--------
Gate the tweets/dents from a Twitter or Identi.ca account's list of friends
into an IRC channel.
History
-------
Some people in an IRC channel started noticing that conversations kept crossing
over between IRC and Twitter, so they talked about gating each other's tweets
into the channel:
http://wiki.blitzed.org/Channel:bitfolk/Twitter_Bot
Eventually someone quickly knocked a bot together:
http://wiki.blitzed.org/Channel:bitfolk/Twitfolk
Then a couple of other channels started using it.
Pre-requisites
--------------
- Perl (>=5.10)
- Some Perl modules:
- - Net::Twitter
- - EV
- AnyEvent::Twitter::Stream
- AnyEvent::IRC
- - MooseX::Daemonize
- Config::Tiny
- - Try::Tiny
+ - Crpyt::SSLeay
+ - EV
- HTML::Entities
+ - MooseX::Daemonize
+ - Net::Twitter
+ - Try::Tiny
It might be easiest to use cpanm with a local::lib to use these modules:
wget -qO ~/bin/cpanm cpanmin.us
chmod 755 ~/bin/cpanm
- cpanm --local-lib=./twitfolk-libs Net::Twitter AnyEvent::Twitter::Stream AnyEvent::IRC MooseX::Daemonize Config::Tiny Try::Tiny
+ cpanm --local-lib=./twitfolk-libs Net::Twitter AnyEvent::Twitter::Stream AnyEvent::IRC MooseX::Daemonize Config::Tiny Try::Tiny EV Crypt::SSLeay
[wait a rather long time]
Then run with:
PERL5LIB=./twitfolk-libs/lib/perl5 ./twitfolk.pl
- A twitter.com or identi.ca account
Source
------
You can get it from our Subversion repository:
https://svn.bitfolk.com/repos/twitfolk/
Support
-------
Limited community support is available from the TwitFolk users mailing list:
https://lists.bitfolk.com/mailman/listinfo/twitfolk
Feature suggestions would be great, too.
You can follow TwitFolk development on Identi.ca:
http://identi.ca/twitfolk
which is also gated to Twitter:
http://twitter.com/therealtwitfolk
(The "twitfolk" username was already taken on Twitter; if you own it and want
to give it up, please let us know!)
$Id:README 977 2009-07-26 02:50:08Z andy $
|
dgl/TwitFolk
|
4bb1e19c3d3c023cb2eb555e6773a769cdffc980
|
Add nick_pass to TwitFolk::IRC
|
diff --git a/TwitFolk.pm b/TwitFolk.pm
index 1909ac5..3ced278 100644
--- a/TwitFolk.pm
+++ b/TwitFolk.pm
@@ -1,174 +1,175 @@
=pod
TwitFolk
Gate tweets from your Twitter/identi.ca friends into an IRC channel.
http://dev.bitfolk.com/twitfolk/
Copyright ©2008 Andy Smith <andy+twitfolk.pl@bitfolk.com>
Copyright ©2010 David Leadbeater <dgl@dgl.cx>
Artistic license same as Perl.
$Id: twitfolk.pl 1580 2010-06-10 12:45:21Z andy $
=cut
package TwitFolk;
our $VERSION = "0.2";
use Config::Tiny;
use Moose;
use Try::Tiny;
use TwitFolk::Client::Identica;
use TwitFolk::Client::Twitter;
use TwitFolk::Friends;
use TwitFolk::IRC;
use TwitFolk::Last;
with qw(MooseX::Daemonize);
has config_file => (
isa => "Str",
is => "ro",
default => sub { "twitfolk.conf" }
);
has ircname => (
isa => "Str",
is => "ro",
default => sub { "twitfolk $VERSION" }
);
has _config => (
isa => "HashRef",
is => "ro",
);
has _irc => (
isa => "TwitFolk::IRC",
is => "ro",
default => sub { TwitFolk::IRC->new }
);
has _friends => (
isa => "TwitFolk::Friends",
is => "rw"
);
has _twitter => (
isa => "TwitFolk::Client",
is => "rw"
);
has _identica => (
isa => "TwitFolk::Client",
is => "rw"
);
sub BUILD {
my($self) = @_;
my $config = Config::Tiny->read($self->config_file)
or die Config::Tiny->errstr;
# Only care about the root section for now.
$self->{_config} = $config->{_};
$self->_friends(
TwitFolk::Friends->new(friends_file => $self->_config->{friends_file})
);
$self->pidfile($self->_config->{pidfile});
}
# The "main"
after start => sub {
my($self) = @_;
$SIG{HUP} = sub {
$self->_friends->update;
$self->_twitter->sync if $self->_twitter;
$self->_identica->sync if $self->_identica;
};
try {
$self->connect;
AnyEvent->condvar->recv;
} catch {
# Just the first line, Moose can spew rather long errors
$self->_irc->disconnect("Died: " . (/^(.*)$/m)[0]);
warn $_;
};
};
before shutdown => sub {
my($self) = @_;
$self->_irc->disconnect("Shutdown");
};
sub connect {
my($self) = @_;
my $c = $self->_config;
$self->_irc->connect($self,
$c->{target_server}, $c->{target_port},
{
- nick => $c->{nick},
- user => $c->{username},
- real => $self->ircname,
- password => $self->{target_pass},
- channel => $c->{channel},
- away => $c->{away}
+ nick => $c->{nick},
+ nick_pass => $c->{nick_pass},
+ user => $c->{username},
+ real => $self->ircname,
+ password => $self->{target_pass},
+ channel => $c->{channel},
+ away => $c->{away}
}
);
}
# Bot is primed
sub on_join {
my($self) = @_;
my $last_tweets = TwitFolk::Last->new(
tweet_id_file => $self->_config->{tweet_id_file}
);
# Probably should use traits rather than hardcoded classes like this, too
# lazy though.
if($self->_config->{use_twitter}) {
$self->_twitter(
TwitFolk::Client::Twitter->new(
irc => $self->_irc,
target => "#" . $self->_config->{channel},
consumer_key => $self->_config->{twitter_consumer_key},
consumer_secret => $self->_config->{twitter_consumer_secret},
owner => $self->_config->{owner},
last_tweets => $last_tweets,
friends => $self->_friends,
)
);
$self->_friends->twitter($self->_twitter);
$self->_twitter->sync;
}
if($self->_config->{use_identica}) {
$self->_identica(
TwitFolk::Client::Identica->new(
irc => $self->_irc,
target => "#" . $self->_config->{channel},
username => $self->_config->{identica_user},
password => $self->_config->{identica_pass},
max_tweets => $self->_config->{max_tweets},
last_tweets => $last_tweets,
friends => $self->_friends,
)
);
$self->_friends->identica($self->_identica);
$self->_identica->sync;
}
}
1;
|
dgl/TwitFolk
|
ec501a3c611044d82d04b5f7431b958ab69dfaae
|
Fix NickServ support
|
diff --git a/TwitFolk/IRC.pm b/TwitFolk/IRC.pm
index da49a4e..3148d92 100644
--- a/TwitFolk/IRC.pm
+++ b/TwitFolk/IRC.pm
@@ -1,101 +1,101 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::IRC;
use EV;
use strict;
=head1 NAME
TwitFolk::IRC - Lame wrapper around AnyEvent::IRC::Client for TwitFolk
=cut
use base "AnyEvent::IRC::Client";
use AnyEvent::IRC::Util qw(prefix_nick);
use TwitFolk::Log;
sub connect {
my($self, $parent, $addr, $port, $args) = @_;
($self->{twitfolk_connect_cb} = sub {
$self->SUPER::connect($addr, $port, $args);
$self->{parent} = $parent;
$self->{args} = $args;
my $channel = $args->{channel};
$self->send_srv(JOIN => $channel =~ /^#/ ? $channel : "#$channel");
if($args->{away}) {
$self->send_srv(AWAY => $args->{away});
}
for(qw(registered disconnect join irc_433 irc_notice)) {
my $callback = "on_$_";
$self->reg_cb($_ => sub {
debug "IRC: $callback: " . (ref($_[1]) eq 'HASH' ? JSON::to_json($_[1]) : "");
$self->$callback(@_)
});
}
})->();
}
sub msg {
my($self, $who, $text) = @_;
$self->send_srv(PRIVMSG => $who, $text);
}
sub notice {
my($self, $who, $text) = @_;
$self->send_srv(NOTICE => $who, $text);
}
sub on_registered {
my($self) = @_;
$self->enable_ping(90);
}
sub on_disconnect {
my($self) = @_;
AE::timer 10, 0, sub { $self->{twitfolk_connect_cb}->() };
}
sub on_join {
my($self, $nick, $channel, $myself) = @_;
$self->{parent}->on_join if $myself;
}
# Nick in use
sub on_irc_433 {
my($self) = @_;
$self->send_srv(NICK => $self->{nick} . $$);
$self->msg("NickServ", "RECOVER $self->{args}->{nick} $self->{args}->{nick_pass}");
}
sub on_irc_notice {
- my($self, $msg) = @_;
+ my($self, $irc, $msg) = @_;
if(lc prefix_nick($msg) eq 'nickserv') {
local $_ = $msg->{params}->[-1];
if (/This nick is owned by someone else/ ||
/This nickname is registered and protected/i) {
debug("ID to NickServ at request of NickServ");
$self->msg("NickServ", "IDENTIFY $self->{args}->{nick_pass}");
} elsif (/Your nick has been recovered/i) {
debug("NickServ told me I recovered my nick, RELEASE'ing now");
$self->msg("NickServ", "RELEASE $self->{args}->{nick} $self->{args}->{nick_pass}");
} elsif (/Your nick has been released from custody/i) {
debug("NickServ told me my nick is released, /nick'ing now");
$self->send_srv(NICK => $self->{args}->{nick});
} else {
debug("Ignoring NickServ notice: %s", $_);
}
}
}
1;
|
dgl/TwitFolk
|
ebb69bc4c249892e3790c6b65ba63a7fa06a343b
|
Fix HTML decoding and UTF-8
|
diff --git a/TwitFolk/Client.pm b/TwitFolk/Client.pm
index e06259d..e1e18f5 100644
--- a/TwitFolk/Client.pm
+++ b/TwitFolk/Client.pm
@@ -1,40 +1,42 @@
# © 2010 David Leadbeater; https://dgl.cx/licence
package TwitFolk::Client;
use Moose;
use TwitFolk::Log;
+use HTML::Entities;
+use Encode qw(encode_utf8);
has irc => (isa => "TwitFolk::IRC", is => "ro");
has target => (isa => "Str", is => "ro");
has friends => (isa => "TwitFolk::Friends", is => "ro");
has last_tweets => (isa => "TwitFolk::Last", is => "ro");
sub on_update {
my($self, $update) = @_;
my $screen_name = $update->{user}->{screen_name};
my $nick = $self->friends->lookup_nick($screen_name);
- my $text = $update->{text};
+ my $text = decode_entities $update->{text};
# Skip tweets directed at others who aren't friends
if ($text =~ /^@([[:alnum:]_]+)/) {
my $other_sn = lc($1);
unless (grep { lc($_) eq $other_sn } keys %{$self->friends->friends}) {
debug("Ignoring reply tweet %s from [%s] to [%s]",
$update->{id}, $screen_name, $other_sn);
return;
}
}
debug("%s/%s: [%s/\@%s] %s", ref $self, $update->{id}, $nick, $screen_name, $text);
if ($text =~ /[\n\r]/) {
irc_debug("%s/%s contains dangerous characters; removing!",
ref $self, $update->{id});
$text =~ s/[\n\r]/ /g;
}
- $self->irc->notice($self->target, sprintf("[%s/\@%s] %s",
+ $self->irc->notice($self->target, encode_utf8 sprintf("[%s/\@%s] %s",
$nick, $screen_name, $text));
}
1;
|
dgl/TwitFolk
|
7bf365b9214b475eab4e94439b5622203a10bbbe
|
Missed owner config option
|
diff --git a/twitfolk.conf.sample b/twitfolk.conf.sample
index 3faab7c..86728f7 100644
--- a/twitfolk.conf.sample
+++ b/twitfolk.conf.sample
@@ -1,58 +1,61 @@
# Example config file for twitfolk.pl
# $Id: twitfolk.conf.sample 1510 2010-05-19 09:08:45Z andy $
# Server hostname or IP.
target_server = uk.blitzed.org
# Port to connect to.
target_port = 6667
# password to use to connect to server (comment out to use no password)
target_pass = yournickpass
# IRC nick to use.
nick = Twitfolk
# If the nick is registered, identify to NickServ with this password.
nick_pass = yournickpass
# If there is no identd installed then use this ident.
username = twitfolk
# File to write PID to whilst running.
pidfile = twitfolk.pid
# Away message to immediately set.
away = If you have a Twitter or Identi.ca account, ask grifferz to add you to me!
+# Nickname of owner (the bot might message you to ask you to authorize it, so you should set this)
+owner = dg
+
# Channel, without leading #
channel = bitfolk
# Use twitter.com, defaults to 1.
use_twitter = 1
# Register your "app" at: http://dev.twitter.com/apps
# Consumer key
twitter_consumer_key = noejmNfxtxZEaATRc1nJoA
# Consumer secret
twitter_consumer_secret = N05k9nZ3yxP9ywgkOy2XHsUTJIBuosrgVGa6DNimII
# Use identi.ca (instead or as well as twitter.com). Requires Net::Twitter version >= 2.0.
use_identica = 0
# Your screen name on identi.ca
identica_user = identiuser
# Your password on identi.ca
identica_pass = identipass
# File containing list of people to follow and their IRC nicknames
friends_file = twitfolk.friends
# Where to store the most recent tweet id
tweet_id_file = last_tweet
# How many tweets to relay at a time
max_tweets = 4
|
dgl/TwitFolk
|
4981745d182ac5c37c50ca450edef3f59b77b08a
|
Fix local-lib stuff
|
diff --git a/README b/README
index 03b52b3..0c0a83b 100644
--- a/README
+++ b/README
@@ -1,80 +1,80 @@
TwitFolk - an IRC/Twitter gateway bot
=====================================
Overview
--------
Gate the tweets/dents from a Twitter or Identi.ca account's list of friends
into an IRC channel.
History
-------
Some people in an IRC channel started noticing that conversations kept crossing
over between IRC and Twitter, so they talked about gating each other's tweets
into the channel:
http://wiki.blitzed.org/Channel:bitfolk/Twitter_Bot
Eventually someone quickly knocked a bot together:
http://wiki.blitzed.org/Channel:bitfolk/Twitfolk
Then a couple of other channels started using it.
Pre-requisites
--------------
- Perl (>=5.10)
- Some Perl modules:
- Net::Twitter
- EV
- AnyEvent::Twitter::Stream
- AnyEvent::IRC
- MooseX::Daemonize
- Config::Tiny
- Try::Tiny
- HTML::Entities
It might be easiest to use cpanm with a local::lib to use these modules:
wget -qO ~/bin/cpanm cpanmin.us
chmod 755 ~/bin/cpanm
cpanm --local-lib=./twitfolk-libs Net::Twitter AnyEvent::Twitter::Stream AnyEvent::IRC MooseX::Daemonize Config::Tiny Try::Tiny
[wait a rather long time]
Then run with:
- PERL5LIB=./twitfolk-libs ./twitfolk.pl
+ PERL5LIB=./twitfolk-libs/lib/perl5 ./twitfolk.pl
- A twitter.com or identi.ca account
Source
------
You can get it from our Subversion repository:
https://svn.bitfolk.com/repos/twitfolk/
Support
-------
Limited community support is available from the TwitFolk users mailing list:
https://lists.bitfolk.com/mailman/listinfo/twitfolk
Feature suggestions would be great, too.
You can follow TwitFolk development on Identi.ca:
http://identi.ca/twitfolk
which is also gated to Twitter:
http://twitter.com/therealtwitfolk
(The "twitfolk" username was already taken on Twitter; if you own it and want
to give it up, please let us know!)
$Id:README 977 2009-07-26 02:50:08Z andy $
|
dgl/TwitFolk
|
7d22b52c19785cf3784246242e659bffd4cabaf2
|
Near total rewrite using AnyEvent::Twitter::Stream and stuff
|
diff --git a/README b/README
new file mode 100644
index 0000000..03b52b3
--- /dev/null
+++ b/README
@@ -0,0 +1,80 @@
+TwitFolk - an IRC/Twitter gateway bot
+=====================================
+
+Overview
+--------
+
+Gate the tweets/dents from a Twitter or Identi.ca account's list of friends
+into an IRC channel.
+
+History
+-------
+
+Some people in an IRC channel started noticing that conversations kept crossing
+over between IRC and Twitter, so they talked about gating each other's tweets
+into the channel:
+
+ http://wiki.blitzed.org/Channel:bitfolk/Twitter_Bot
+
+Eventually someone quickly knocked a bot together:
+
+ http://wiki.blitzed.org/Channel:bitfolk/Twitfolk
+
+Then a couple of other channels started using it.
+
+Pre-requisites
+--------------
+
+- Perl (>=5.10)
+
+- Some Perl modules:
+ - Net::Twitter
+ - EV
+ - AnyEvent::Twitter::Stream
+ - AnyEvent::IRC
+ - MooseX::Daemonize
+ - Config::Tiny
+ - Try::Tiny
+ - HTML::Entities
+
+ It might be easiest to use cpanm with a local::lib to use these modules:
+
+ wget -qO ~/bin/cpanm cpanmin.us
+ chmod 755 ~/bin/cpanm
+ cpanm --local-lib=./twitfolk-libs Net::Twitter AnyEvent::Twitter::Stream AnyEvent::IRC MooseX::Daemonize Config::Tiny Try::Tiny
+ [wait a rather long time]
+
+ Then run with:
+
+ PERL5LIB=./twitfolk-libs ./twitfolk.pl
+
+- A twitter.com or identi.ca account
+
+Source
+------
+
+You can get it from our Subversion repository:
+
+ https://svn.bitfolk.com/repos/twitfolk/
+
+Support
+-------
+
+Limited community support is available from the TwitFolk users mailing list:
+
+ https://lists.bitfolk.com/mailman/listinfo/twitfolk
+
+Feature suggestions would be great, too.
+
+You can follow TwitFolk development on Identi.ca:
+
+ http://identi.ca/twitfolk
+
+which is also gated to Twitter:
+
+ http://twitter.com/therealtwitfolk
+
+(The "twitfolk" username was already taken on Twitter; if you own it and want
+to give it up, please let us know!)
+
+$Id:README 977 2009-07-26 02:50:08Z andy $
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..28e617c
--- /dev/null
+++ b/TODO
@@ -0,0 +1,12 @@
+- Ignore features
+
+Would be nice if people / hashtags could be (temporarily?) ignored in some
+fashion, for example when an otherwise-interesting person is tweeting about a
+conference that's not of interest.
+
+- Self service features
+
+There should be some way for users in the channel to indicate that they want to
+be added or removed.
+
+Similarly, they should be able to indicate that their IRC nick has changed.
diff --git a/TwitFolk.pm b/TwitFolk.pm
new file mode 100644
index 0000000..1909ac5
--- /dev/null
+++ b/TwitFolk.pm
@@ -0,0 +1,174 @@
+=pod
+
+TwitFolk
+
+Gate tweets from your Twitter/identi.ca friends into an IRC channel.
+
+http://dev.bitfolk.com/twitfolk/
+
+Copyright ©2008 Andy Smith <andy+twitfolk.pl@bitfolk.com>
+
+Copyright ©2010 David Leadbeater <dgl@dgl.cx>
+
+Artistic license same as Perl.
+
+$Id: twitfolk.pl 1580 2010-06-10 12:45:21Z andy $
+=cut
+
+package TwitFolk;
+our $VERSION = "0.2";
+
+use Config::Tiny;
+use Moose;
+use Try::Tiny;
+
+use TwitFolk::Client::Identica;
+use TwitFolk::Client::Twitter;
+use TwitFolk::Friends;
+use TwitFolk::IRC;
+use TwitFolk::Last;
+
+with qw(MooseX::Daemonize);
+
+has config_file => (
+ isa => "Str",
+ is => "ro",
+ default => sub { "twitfolk.conf" }
+);
+
+has ircname => (
+ isa => "Str",
+ is => "ro",
+ default => sub { "twitfolk $VERSION" }
+);
+
+has _config => (
+ isa => "HashRef",
+ is => "ro",
+);
+
+has _irc => (
+ isa => "TwitFolk::IRC",
+ is => "ro",
+ default => sub { TwitFolk::IRC->new }
+);
+
+has _friends => (
+ isa => "TwitFolk::Friends",
+ is => "rw"
+);
+
+has _twitter => (
+ isa => "TwitFolk::Client",
+ is => "rw"
+);
+
+has _identica => (
+ isa => "TwitFolk::Client",
+ is => "rw"
+);
+
+sub BUILD {
+ my($self) = @_;
+
+ my $config = Config::Tiny->read($self->config_file)
+ or die Config::Tiny->errstr;
+ # Only care about the root section for now.
+ $self->{_config} = $config->{_};
+
+ $self->_friends(
+ TwitFolk::Friends->new(friends_file => $self->_config->{friends_file})
+ );
+
+ $self->pidfile($self->_config->{pidfile});
+}
+
+
+# The "main"
+after start => sub {
+ my($self) = @_;
+
+ $SIG{HUP} = sub {
+ $self->_friends->update;
+ $self->_twitter->sync if $self->_twitter;
+ $self->_identica->sync if $self->_identica;
+ };
+
+ try {
+ $self->connect;
+ AnyEvent->condvar->recv;
+ } catch {
+ # Just the first line, Moose can spew rather long errors
+ $self->_irc->disconnect("Died: " . (/^(.*)$/m)[0]);
+ warn $_;
+ };
+};
+
+before shutdown => sub {
+ my($self) = @_;
+
+ $self->_irc->disconnect("Shutdown");
+};
+
+sub connect {
+ my($self) = @_;
+ my $c = $self->_config;
+
+ $self->_irc->connect($self,
+ $c->{target_server}, $c->{target_port},
+ {
+ nick => $c->{nick},
+ user => $c->{username},
+ real => $self->ircname,
+ password => $self->{target_pass},
+ channel => $c->{channel},
+ away => $c->{away}
+ }
+ );
+}
+
+# Bot is primed
+sub on_join {
+ my($self) = @_;
+
+ my $last_tweets = TwitFolk::Last->new(
+ tweet_id_file => $self->_config->{tweet_id_file}
+ );
+
+ # Probably should use traits rather than hardcoded classes like this, too
+ # lazy though.
+
+ if($self->_config->{use_twitter}) {
+ $self->_twitter(
+ TwitFolk::Client::Twitter->new(
+ irc => $self->_irc,
+ target => "#" . $self->_config->{channel},
+ consumer_key => $self->_config->{twitter_consumer_key},
+ consumer_secret => $self->_config->{twitter_consumer_secret},
+ owner => $self->_config->{owner},
+ last_tweets => $last_tweets,
+ friends => $self->_friends,
+ )
+ );
+ $self->_friends->twitter($self->_twitter);
+ $self->_twitter->sync;
+ }
+
+ if($self->_config->{use_identica}) {
+ $self->_identica(
+ TwitFolk::Client::Identica->new(
+ irc => $self->_irc,
+ target => "#" . $self->_config->{channel},
+ username => $self->_config->{identica_user},
+ password => $self->_config->{identica_pass},
+ max_tweets => $self->_config->{max_tweets},
+ last_tweets => $last_tweets,
+ friends => $self->_friends,
+ )
+ );
+ $self->_friends->identica($self->_identica);
+ $self->_identica->sync;
+ }
+}
+
+1;
diff --git a/TwitFolk/Client.pm b/TwitFolk/Client.pm
new file mode 100644
index 0000000..e06259d
--- /dev/null
+++ b/TwitFolk/Client.pm
@@ -0,0 +1,40 @@
+# © 2010 David Leadbeater; https://dgl.cx/licence
+package TwitFolk::Client;
+use Moose;
+use TwitFolk::Log;
+
+has irc => (isa => "TwitFolk::IRC", is => "ro");
+has target => (isa => "Str", is => "ro");
+has friends => (isa => "TwitFolk::Friends", is => "ro");
+has last_tweets => (isa => "TwitFolk::Last", is => "ro");
+
+sub on_update {
+ my($self, $update) = @_;
+
+ my $screen_name = $update->{user}->{screen_name};
+ my $nick = $self->friends->lookup_nick($screen_name);
+ my $text = $update->{text};
+
+ # Skip tweets directed at others who aren't friends
+ if ($text =~ /^@([[:alnum:]_]+)/) {
+ my $other_sn = lc($1);
+ unless (grep { lc($_) eq $other_sn } keys %{$self->friends->friends}) {
+ debug("Ignoring reply tweet %s from [%s] to [%s]",
+ $update->{id}, $screen_name, $other_sn);
+ return;
+ }
+ }
+
+ debug("%s/%s: [%s/\@%s] %s", ref $self, $update->{id}, $nick, $screen_name, $text);
+
+ if ($text =~ /[\n\r]/) {
+ irc_debug("%s/%s contains dangerous characters; removing!",
+ ref $self, $update->{id});
+ $text =~ s/[\n\r]/ /g;
+ }
+
+ $self->irc->notice($self->target, sprintf("[%s/\@%s] %s",
+ $nick, $screen_name, $text));
+}
+
+1;
diff --git a/TwitFolk/Client/Basic.pm b/TwitFolk/Client/Basic.pm
new file mode 100644
index 0000000..ea7cbf3
--- /dev/null
+++ b/TwitFolk/Client/Basic.pm
@@ -0,0 +1,36 @@
+# © 2010 David Leadbeater; https://dgl.cx/licence
+package TwitFolk::Client::Basic;
+
+=head1 NAME
+
+TwitFolk::Client::Basic - Basic auth
+
+=cut
+
+use Moose::Role;
+use Net::Twitter;
+
+has username => (isa => "Str", is => "ro");
+has password => (isa => "Str", is => "ro");
+has api_args => (isa => "HashRef", is => "ro", default => sub { {} });
+
+has api => (
+ isa => "Net::Twitter",
+ is => "rw"
+);
+
+sub BUILD { }
+
+after BUILD => sub {
+ my($self) = @_;
+
+ $self->api(
+ Net::Twitter->new(
+ username => $self->username,
+ password => $self->password,
+ %{$self->api_args}
+ )
+ );
+};
+
+1;
diff --git a/TwitFolk/Client/Identica.pm b/TwitFolk/Client/Identica.pm
new file mode 100644
index 0000000..90b9198
--- /dev/null
+++ b/TwitFolk/Client/Identica.pm
@@ -0,0 +1,120 @@
+package TwitFolk::Client::Identica;
+use AE;
+use Moose;
+use Try::Tiny;
+use TwitFolk::Log;
+
+extends "TwitFolk::Client";
+
+with qw(TwitFolk::Client::Basic);
+
+has max_tweets => (isa => "Int", is => "ro");
+
+sub BUILD {
+ my($self) = @_;
+
+ $self->api_args({ identica => 1 });
+
+ AE::timer 300, 300, sub { $self->sync };
+}
+
+sub sync {
+ my($self) = @_;
+
+ my $svcname = "identica"; # lame, but works for now
+
+ # Ask for 10 times as many tweets as we will ever say, but no more than
+ # 200
+ my $max = $self->max_tweets >= 20 ? 200 : $self->max_tweets * 10;
+ my $count = 0;
+ my $opts = { count => $max };
+
+ # Ask for the timeline of friend's statuses, only since the last tweet
+ # if we know its id
+ $opts->{since_id} = $self->last_tweets->get("identica") if $self->last_id;
+
+ # Net::Twitter sometimes dies inside JSON::Any :(
+ my $tweets;
+ try {
+ $tweets = $self->api->friends_timeline($opts);
+ } catch {
+ debug("%s->friends_timeline() error: %s", $svcname, $@);
+ }
+ return unless $tweets;
+
+ if ($self->api->http_code != 200) {
+ debug("%s->friend_timeline() failed: %s", $svcname,
+ $self->api->http_message);
+ return;
+ }
+
+=pod
+
+$tweets should now be a reference to an array of:
+
+ {
+ 'source' => 'web',
+ 'favorited' => $VAR1->[0]{'favorited'},
+ 'truncated' => $VAR1->[0]{'favorited'},
+ 'created_at' => 'Tue Oct 28 22:22:14 +0000 2008',
+ 'text' => '@deltafan121 Near Luton, which is just outside London.',
+ 'user' => {
+ 'location' => 'Bedfordshire, United Kingdom',
+ 'followers_count' => 10,
+ 'profile_image_url' => 'http://s3.amazonaws.com/twitter_production/profile_images/62344418/SP_A0089_2_normal.jpg',
+ 'protected' => $VAR1->[0]{'favorited'},
+ 'name' => 'Robert Leverington',
+ 'url' => 'http://robertleverington.com/',
+ 'id' => 14450923,
+ 'description' => '',
+ 'screen_name' => 'roberthl'
+ },
+ 'in_reply_to_user_id' => 14662919,
+ 'id' => 979630447,
+ 'in_reply_to_status_id' => 979535561
+ }
+=cut
+
+=pod
+But I guess we better check, since this happened one time at band camp:
+
+Tue Nov 18 07:58:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
+Tue Nov 18 08:03:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
+Tue Nov 18 08:08:50 2008| *** twitter->friend_timelines() failed: read timeout
+Tue Nov 18 08:13:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
+Tue Nov 18 08:18:41 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
+Tue Nov 18 08:23:43 2008| *** twitter->friend_timelines() failed: Can't connect to twitter.com:80 (connect: timeout)
+Not an ARRAY reference at ./twitfolk.pl line 494.
+=cut
+
+ if (ref($tweets) ne "ARRAY") {
+ debug("%s->friend_timelines() didn't return an arrayref!", $svcname);
+ return;
+ }
+
+ debug("Got %u new tweets from %s", scalar @$tweets, $svcname);
+
+ # Iterate through them all, sorted by id low to high
+ for my $tweet (sort { $a->{id} <=> $b->{id} } @{ $tweets }) {
+
+ if ($count >= $self->max_tweets) {
+ debug("Already did %u tweets, stopping there", $count);
+ last;
+ }
+
+ if ($tweet->{id} <= $self->last_tweets->get("identica")) {
+ # Why does Twitter still return tweets that are <= since_id?
+ debug("%s/%s: ignored as somehow <= %s !?", $svcname,
+ $tweet->{id}, $self->last_tweets->get("identica"));
+ next;
+ }
+
+ $self->on_update($tweet);
+
+ $self->last_tweets->update(identica => $tweet->{id});
+
+ $count++;
+ }
+}
+
+1;
diff --git a/TwitFolk/Client/OAuth.pm b/TwitFolk/Client/OAuth.pm
new file mode 100644
index 0000000..519703d
--- /dev/null
+++ b/TwitFolk/Client/OAuth.pm
@@ -0,0 +1,104 @@
+# © 2010 David Leadbeater; https://dgl.cx/licence
+package TwitFolk::Client::OAuth;
+
+=head1 NAME
+
+TwitFolk::Client::OAuth - Handle OAuth stuffs
+
+=head1 DESCRIPTION
+
+Twitter wants an OAuth login thesedays, this provides the handling for it, you
+need to implement need_authorization in the class that does this role; it will
+be given the URL Twitter wants you to go to, this will give the user a pin,
+that should be passed back to authorization_response.
+
+Probably should be two roles to separate out the state saving, but I'm lazy.
+
+=cut
+
+use Moose::Role;
+use Net::Twitter;
+use JSON qw(from_json to_json); # For serialisation
+
+requires "need_authorization";
+
+has state_file => (isa => "Str", is => "ro", default => sub { "oauth.state" });
+has consumer_key => (isa => "Str", is => "ro");
+has consumer_secret => (isa => "Str", is => "ro");
+has access_token => (isa => "Str", is => "rw");
+has access_token_secret => (isa => "Str", is => "rw");
+has api => (isa => "Net::Twitter", is => "rw");
+has api_args => (isa => "HashRef", is => "ro", default => sub { {} });
+
+sub BUILD { }
+
+# I'm bad, but this is easier.
+after BUILD => sub {
+ my($self) = @_;
+
+ $self->api(Net::Twitter->new(
+ traits => [qw(API::REST OAuth)],
+ consumer_key => $self->consumer_key,
+ consumer_secret => $self->consumer_secret,
+ %{$self->api_args}
+ ));
+
+ unless(open my $fh, "<", $self->state_file) {
+ warn "Unable to open '" . $self->state_file . "': $!" unless $!{ENOENT};
+
+ } else {
+ my $state = from_json(join "", <$fh>);
+
+ $self->access_token($state->{access_token});
+ $self->access_token_secret($state->{access_token_secret});
+
+ if($self->access_token) {
+ $self->api->access_token($self->access_token);
+ $self->api->access_token_secret($self->access_token_secret);
+ }
+ }
+};
+
+sub authorize {
+ my($self) = @_;
+
+ my $authorized = $self->api->authorized;
+
+ unless($authorized) {
+ $self->need_authorization($self->api->get_authorization_url);
+ }
+
+ return $authorized;
+}
+
+sub authorization_response {
+ my($self, $pin) = @_;
+
+ my($access_token, $access_token_secret, $user_id, $screen_name) =
+ $self->api->request_access_token(verifier => $pin);
+
+ $self->access_token($access_token);
+ $self->access_token_secret($access_token_secret);
+
+ $self->save_state;
+ return 1;
+}
+
+sub save_state {
+ my($self) = @_;
+ my $new = $self->state_file . ".new";
+
+ open my $fh, ">", $new or do {
+ warn "Unable to write to '$new': $!";
+ return;
+ };
+
+ print $fh to_json {
+ access_token => $self->access_token,
+ access_token_secret => $self->access_token_secret
+ };
+
+ rename $new => $self->state_file;
+}
+
+1;
diff --git a/TwitFolk/Client/Twitter.pm b/TwitFolk/Client/Twitter.pm
new file mode 100644
index 0000000..b36fb98
--- /dev/null
+++ b/TwitFolk/Client/Twitter.pm
@@ -0,0 +1,101 @@
+# © 2010 David Leadbeater; https://dgl.cx/licence
+package TwitFolk::Client::Twitter;
+use Moose;
+use AnyEvent::IRC::Util qw(prefix_nick);
+use AnyEvent::Twitter::Stream;
+use Try::Tiny;
+use TwitFolk::Log;
+
+extends "TwitFolk::Client";
+
+with qw(TwitFolk::Client::OAuth);
+
+# Who to contact when we need OAuth fixing
+has owner => (isa => "Str", is => "rw");
+
+# Our listener for tweets
+has listener => (isa => "AnyEvent::Twitter::Stream", is => "rw");
+
+sub BUILD {
+ my($self) = @_;
+
+ $self->irc->reg_cb(privatemsg => sub { $self->on_privmsg(@_) });
+}
+
+sub sync {
+ my($self) = @_;
+
+ try {
+ if($self->authorize) {
+ $self->start_stream;
+ }
+ } catch {
+ warn "Can't sync: $_";
+ };
+}
+
+sub need_authorization {
+ my($self, $url) = @_;
+
+ $self->irc->msg($self->owner,
+ "Please could you be so kind as to login as me on Twitter, go to $url and then msg me with the pin, thank you!");
+}
+
+sub on_privmsg {
+ my($self, $irc, $nick, $msg) = @_;
+
+ if(lc prefix_nick($msg) eq $self->owner
+ && $msg->{params}->[-1] =~ /^(\d+)\s*$/) {
+
+ try {
+ $self->authorization_response($1);
+ $self->irc->msg($self->owner, "Most excellent, sir!");
+ $self->start_stream;
+ } catch {
+ $self->irc->msg($self->owner, "Sorry, that didn't seem to work: $_");
+ }
+ }
+}
+
+sub reconnect {
+ my($self) = @_;
+
+ AE::timer 10, 0, sub {
+ debug "Reconnecting to twitter...";
+ $self->sync;
+ }
+}
+
+sub start_stream {
+ my($self) = @_;
+
+ debug "Starting stream";
+
+ $self->listener(
+ AnyEvent::Twitter::Stream->new(
+ consumer_key => $self->consumer_key,
+ consumer_secret => $self->consumer_secret,
+ token => $self->access_token,
+ token_secret => $self->access_token_secret,
+ method => "userstream",
+ on_tweet => sub {
+ my($tweet) = @_;
+ debug "on_tweet: " . JSON::to_json($tweet);
+
+ return unless $tweet->{user};
+ $self->on_update($tweet);
+ $self->last_tweets->update(twitter => $tweet->{id}); # This is totally pointless with streaming API, but doesn't hurt
+ },
+ on_error => sub {
+ debug "Error from twitter stream: @_";
+ $self->reconnect;
+ },
+ on_eof => sub {
+ debug "EOF from twitter stream";
+ $self->reconnect;
+ },
+ )
+ );
+}
+
+1;
diff --git a/TwitFolk/Friends.pm b/TwitFolk/Friends.pm
new file mode 100644
index 0000000..2419789
--- /dev/null
+++ b/TwitFolk/Friends.pm
@@ -0,0 +1,155 @@
+package TwitFolk::Friends;
+use Moose;
+use Try::Tiny;
+use TwitFolk::Log;
+
+has friends_file => (isa => "Str", is => "ro");
+
+has twitter => (isa => "TwitFolk::Client", is => "rw");
+has identica => (isa => "TwitFolk::Client", is => "rw");
+
+has friends => (isa => "HashRef", is => "rw", default => sub { {} });
+
+=head2 lookup_nick
+
+Return the nick associated with the screen name, or the screen name if nick is
+not known.
+
+=cut
+
+sub lookup_nick {
+ my($self, $screen_name) = @_;
+
+ if(exists $self->friends->{lc $screen_name}) {
+ return $self->friends->{lc $screen_name}->{nick};
+ }
+
+ return $screen_name;
+}
+
+=head2 update
+
+Read a list of friends from the friends_file. These will be friended in
+Twitter if they aren't already. Format is:
+
+screen_name IRC_nick service
+
+Start a line with # for a comment. Any kind of white space is okay.
+
+Service column may be 'twitter' or 'identica', defaulting to twitter if
+none is specified.
+
+=cut
+
+sub update
+{
+ my $self = shift;
+
+ open my $ff, "<", $self->friends_file or die "Couldn't open friends_file: $!";
+
+ while (<$ff>) {
+ next if (/^#/);
+
+ if (/^(\S+)\s+(\S+)(?:\s+(\S+))?/) {
+ my $f = lc($1);
+ my $nick = $2;
+ my $svcname = $3 || 'twitter';
+
+ if (!exists $self->friends->{$f}) {
+ my $u;
+ my $svc;
+
+ # Friend may be on identi.ca OR twitter
+ $svc = ($svcname =~ /dent/i) ? $self->identica->api : $self->twitter->api;
+
+ # Net::Twitter sometimes dies inside JSON::Any :(
+ try {
+ $u = $svc->show_user($f);
+ } catch {
+ debug("%s->show_user(%s) error: %s", $svcname, $f, $_);
+ next;
+ };
+
+ if ($svc->http_code != 200) {
+ debug("%s->show_user(%s) failed: %s", $svcname, $f,
+ $svc->http_message);
+ next;
+ }
+
+ my $id = $u->{id};
+ $self->friends->{$f}->{id} = $id;
+
+ debug("%s: Adding new friend '%s' (%lu)", $svcname,
+ $f, $id);
+
+ # Net::Twitter sometimes dies inside JSON::Any :(
+ try {
+ $svc->create_friend($id);
+ } catch {
+ debug("%s->create_friend(%lu) error: %s",
+ $svcname, $id, $_);
+ next;
+ };
+
+ if ($svc->http_code != 200) {
+ debug("%s->create_friend($id) failed: %s",
+ $svcname, $svc->http_message);
+ }
+ }
+
+ $self->friends->{$f}->{nick} = $nick;
+ }
+ }
+
+ close $ff or warn "Something weird when closing friends_file: $!";
+}
+
+=head1 sync
+
+Learn friends from those already added in Twitter, just in case they got added
+from outside as well. Might make this update the friends file at some point.
+
+=cut
+
+sub sync
+{
+ my $self = shift;
+ my $svc = shift;
+ my $svcname = shift;
+
+ my $twitter_friends;
+
+ # Net::Twitter sometimes dies inside JSON::Any :(
+ try {
+ $twitter_friends = $svc->friends;
+ } catch {
+ debug("%s->friends() error: %s", $svcname, $_);
+ };
+ return unless $twitter_friends;
+
+ if ($svc->http_code != 200) {
+ debug("%s->friends() failed: %s", $svcname, $svc->http_message);
+ return;
+ }
+
+ if (ref($twitter_friends) ne "ARRAY") {
+ debug("%s->friends() didn't return an arrayref!", $svcname);
+ return;
+ }
+
+ for my $f (@{$twitter_friends}) {
+ my $screen_name = lc($f->{screen_name});
+ my $id = $f->{id};
+
+ $self->friends->{$screen_name}->{id} = $id;
+
+ if (! defined $self->friends->{$screen_name}->{nick}) {
+ $self->friends->{$screen_name}->{nick} = $screen_name;
+ }
+
+ debug("%s: Already following '%s' (%lu)", $svcname, $screen_name,
+ $self->friends->{$screen_name}->{id});
+ }
+}
+
+1;
diff --git a/TwitFolk/IRC.pm b/TwitFolk/IRC.pm
new file mode 100644
index 0000000..da49a4e
--- /dev/null
+++ b/TwitFolk/IRC.pm
@@ -0,0 +1,101 @@
+# © 2010 David Leadbeater; https://dgl.cx/licence
+package TwitFolk::IRC;
+use EV;
+use strict;
+
+=head1 NAME
+
+TwitFolk::IRC - Lame wrapper around AnyEvent::IRC::Client for TwitFolk
+
+=cut
+
+use base "AnyEvent::IRC::Client";
+use AnyEvent::IRC::Util qw(prefix_nick);
+use TwitFolk::Log;
+
+sub connect {
+ my($self, $parent, $addr, $port, $args) = @_;
+
+ ($self->{twitfolk_connect_cb} = sub {
+ $self->SUPER::connect($addr, $port, $args);
+
+ $self->{parent} = $parent;
+ $self->{args} = $args;
+
+ my $channel = $args->{channel};
+ $self->send_srv(JOIN => $channel =~ /^#/ ? $channel : "#$channel");
+
+ if($args->{away}) {
+ $self->send_srv(AWAY => $args->{away});
+ }
+
+ for(qw(registered disconnect join irc_433 irc_notice)) {
+ my $callback = "on_$_";
+ $self->reg_cb($_ => sub {
+ debug "IRC: $callback: " . (ref($_[1]) eq 'HASH' ? JSON::to_json($_[1]) : "");
+ $self->$callback(@_)
+ });
+ }
+ })->();
+}
+
+sub msg {
+ my($self, $who, $text) = @_;
+ $self->send_srv(PRIVMSG => $who, $text);
+}
+
+sub notice {
+ my($self, $who, $text) = @_;
+ $self->send_srv(NOTICE => $who, $text);
+}
+
+sub on_registered {
+ my($self) = @_;
+
+ $self->enable_ping(90);
+}
+
+sub on_disconnect {
+ my($self) = @_;
+ AE::timer 10, 0, sub { $self->{twitfolk_connect_cb}->() };
+}
+
+sub on_join {
+ my($self, $nick, $channel, $myself) = @_;
+
+ $self->{parent}->on_join if $myself;
+}
+
+# Nick in use
+sub on_irc_433 {
+ my($self) = @_;
+
+ $self->send_srv(NICK => $self->{nick} . $$);
+ $self->msg("NickServ", "RECOVER $self->{args}->{nick} $self->{args}->{nick_pass}");
+}
+
+sub on_irc_notice {
+ my($self, $msg) = @_;
+
+ if(lc prefix_nick($msg) eq 'nickserv') {
+ local $_ = $msg->{params}->[-1];
+
+ if (/This nick is owned by someone else/ ||
+ /This nickname is registered and protected/i) {
+ debug("ID to NickServ at request of NickServ");
+ $self->msg("NickServ", "IDENTIFY $self->{args}->{nick_pass}");
+
+ } elsif (/Your nick has been recovered/i) {
+ debug("NickServ told me I recovered my nick, RELEASE'ing now");
+ $self->msg("NickServ", "RELEASE $self->{args}->{nick} $self->{args}->{nick_pass}");
+
+ } elsif (/Your nick has been released from custody/i) {
+ debug("NickServ told me my nick is released, /nick'ing now");
+ $self->send_srv(NICK => $self->{args}->{nick});
+ } else {
+ debug("Ignoring NickServ notice: %s", $_);
+ }
+ }
+}
+
+1;
diff --git a/TwitFolk/Last.pm b/TwitFolk/Last.pm
new file mode 100644
index 0000000..7eee764
--- /dev/null
+++ b/TwitFolk/Last.pm
@@ -0,0 +1,90 @@
+package TwitFolk::Last;
+use Moose;
+use TwitFolk::Log;
+
+has tweet_id_file => (
+ isa => "Str",
+ is => "ro"
+);
+
+has last_tweets => (
+ isa => "ArrayRef[Int]",
+ is => "rw",
+ default => sub {
+ my($self) = @_;
+ [$self->init]
+ }
+);
+
+my %service_map = (
+ twitter => 0,
+ identica => 1
+);
+
+=head2 init
+
+Read the last tweet ids from a file so that no tweets should be repeated.
+Supports storing two tweet ids, one per service: twitter then identi.ca.
+
+=cut
+
+sub init
+{
+ my($self) = @_;
+
+ return 0, 0 unless -f $self->tweet_id_file;
+
+ open my $lt, "<", $self->tweet_id_file or die "Couldn't open tweet_id_file: $!";
+
+ my @ids = ();
+
+ while (<$lt>) {
+ die "Weird format $_ in tweet_id_file" unless (/^(\d+)/);
+ push @ids, $1;
+ }
+
+ close $lt or warn "Something weird when closing tweet_id_file: $!";
+
+ push @ids, 0 while (scalar @ids < 2);
+ debug("Last tweet id = %s", $_) foreach (@ids);
+
+ return @ids;
+}
+
+sub update
+{
+ my($self, $service, $id) = @_;
+
+ my $pos = $service_map{$service};
+
+ if($self->last_tweets->[$pos] < $id) {
+ $self->last_tweets->[$pos] = $id;
+ $self->save;
+ }
+}
+
+sub get {
+ my($self, $service, $id) = @_;
+
+ my $pos = $service_map{$service};
+
+ return $self->last_tweets->[$pos];
+}
+
+=head2 save
+
+Save the ids of the most recent tweet/dent so that it won't be repeated should
+the bot crash or whatever
+
+=cut
+
+sub save
+{
+ my($self) = @_;
+
+ open my $lt, ">", $self->tweet_id_file or die "Couldn't open tweet_id_file: $!";
+ print $lt "$_\n" for @{$self->last_tweets};
+ close $lt or warn "Something weird when closing tweet_id_file: $!";
+}
+
+1;
diff --git a/TwitFolk/Log.pm b/TwitFolk/Log.pm
new file mode 100644
index 0000000..2cdb2f8
--- /dev/null
+++ b/TwitFolk/Log.pm
@@ -0,0 +1,11 @@
+package TwitFolk::Log;
+use constant DEBUG => $ENV{IRC_DEBUG};
+
+use parent "Exporter";
+our @EXPORT = qw(debug);
+
+sub debug {
+ warn sprintf "$_[0]\n", @_[1 .. $#_] if DEBUG;
+}
+
+1;
diff --git a/twitfolk.conf.sample b/twitfolk.conf.sample
new file mode 100644
index 0000000..3faab7c
--- /dev/null
+++ b/twitfolk.conf.sample
@@ -0,0 +1,58 @@
+# Example config file for twitfolk.pl
+# $Id: twitfolk.conf.sample 1510 2010-05-19 09:08:45Z andy $
+
+# Server hostname or IP.
+target_server = uk.blitzed.org
+
+# Port to connect to.
+target_port = 6667
+
+# password to use to connect to server (comment out to use no password)
+target_pass = yournickpass
+
+# IRC nick to use.
+nick = Twitfolk
+
+# If the nick is registered, identify to NickServ with this password.
+nick_pass = yournickpass
+
+# If there is no identd installed then use this ident.
+username = twitfolk
+
+# File to write PID to whilst running.
+pidfile = twitfolk.pid
+
+# Away message to immediately set.
+away = If you have a Twitter or Identi.ca account, ask grifferz to add you to me!
+
+# Channel, without leading #
+channel = bitfolk
+
+# Use twitter.com, defaults to 1.
+use_twitter = 1
+
+# Register your "app" at: http://dev.twitter.com/apps
+
+# Consumer key
+twitter_consumer_key = noejmNfxtxZEaATRc1nJoA
+
+# Consumer secret
+twitter_consumer_secret = N05k9nZ3yxP9ywgkOy2XHsUTJIBuosrgVGa6DNimII
+
+# Use identi.ca (instead or as well as twitter.com). Requires Net::Twitter version >= 2.0.
+use_identica = 0
+
+# Your screen name on identi.ca
+identica_user = identiuser
+
+# Your password on identi.ca
+identica_pass = identipass
+
+# File containing list of people to follow and their IRC nicknames
+friends_file = twitfolk.friends
+
+# Where to store the most recent tweet id
+tweet_id_file = last_tweet
+
+# How many tweets to relay at a time
+max_tweets = 4
diff --git a/twitfolk.friends.sample b/twitfolk.friends.sample
new file mode 100644
index 0000000..5e51d0a
--- /dev/null
+++ b/twitfolk.friends.sample
@@ -0,0 +1,7 @@
+# Install this as your friends file
+
+# screen_name IRC service
+# (default: twitter)
+
+grifferz grifferz twitter
+someguy someircguy identica
diff --git a/twitfolk.pl b/twitfolk.pl
new file mode 100755
index 0000000..bb40732
--- /dev/null
+++ b/twitfolk.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+# vim:set sw=4 cindent:
+
+=pod
+
+TwitFolk
+
+Gate tweets from your Twitter/identi.ca friends into an IRC channel.
+
+http://dev.bitfolk.com/twitfolk/
+
+Copyright ©2008 Andy Smith <andy+twitfolk.pl@bitfolk.com>
+
+Artistic license same as Perl.
+
+$Id: twitfolk.pl 1580 2010-06-10 12:45:21Z andy $
+=cut
+
+use Cwd;
+use TwitFolk;
+
+my $twitfolk = TwitFolk->new_with_options(basedir => cwd);
+my $command = $twitfolk->extra_argv->[0] || "start";
+$twitfolk->$command;
+
+warn $twitfolk->status_message if $twitfolk->status_message;
+exit $twitfolk->exit_code;
|
fajran/dev.boi
|
7f70f7ba44325a9b9583aa25d918a965785c9bc5
|
Tambahkan panduan menambah paket modul
|
diff --git a/README.md b/README.md
index b19c387..3ff7fb3 100644
--- a/README.md
+++ b/README.md
@@ -1,49 +1,80 @@
dev.blankonlinux.or.id
======================
Panduan
-------
1. Siapkan [buildout](http://pypi.python.org/pypi/zc.buildout)
$ python bootstrap.py
2. Jalankan buildout
$ ./bin/buildout
3. Buat proyek
$ ./bin/trac-admin /path/ke/proyek/
4. Konfigurasi. Cek bagian konfigurasi di bawah untuk informasi lebih lanjut.
$ vi /path/ke/proyek/conf/trac.ini
5. Jalankan Trac
$ ./bin/tracd -s -p 8080 /path/ke/proyek/
Konfigurasi
-----------
Konfigurasi tambahan
[wiki]
repository_dir = /path/ke/repository/bzr/
repository_type = bzr
[components]
tracbzr.* = enabled
trac.web.auth.* = disabled
authopenid.* = enabled
includemacro.* = enabled
tractoc.* = enabled
redirect.* = enabled
irclogs.irclogsplugin = enabled
[irclogs]
indexer = builtin:///var/www/trac/indexer/irclogs.idx?cache=true
path = /home/irgsh/irc/log/ChannelLogger
prefix = #blankon
+Menambah Modul Baru
+-------------------
+
+1. Cek apakah modul ada di [toko keju](http://pypi.python.org/pypi)
+2. Kalau ada, sunting `buildout.cfg` dan tambahkan nama paket modul dalam daftar `eggs`
+3. Kalau tidak ada, baca panduan dibawah.
+4. Jalankan buildout lagi sebelum menjalankan Trac.
+
+ $ ./bin/buildout
+
+### Jika paket modul tidak ada di PyPI
+
+1. Unduh kode sumber
+
+ $ svn co http://trac-hacks.org/svn/irclogsplugin/0.11 irclogs
+
+2. Buat paket distribusi
+
+ $ cd irclogs
+ $ python setup.py sdist
+
+3. Letakkan berkas distribusi ke sebuah server yang bisa diakses via http
+
+ $ scp dist/irclogs-0.2.tar.gz server:/path/ke/pypi/
+
+4. Tambahkan repositori paket dalam `buildout.cfg`
+
+ find-links = http://repo.paket/pypi/
+
+5. Tambahkan nama paket ke dalam daftar `eggs`
+
|
fajran/dev.boi
|
4f960ca1dda8d639abf35eed2bc06186ef92f78f
|
Tambahkan README.md
|
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b19c387
--- /dev/null
+++ b/README.md
@@ -0,0 +1,49 @@
+dev.blankonlinux.or.id
+======================
+
+Panduan
+-------
+
+1. Siapkan [buildout](http://pypi.python.org/pypi/zc.buildout)
+
+ $ python bootstrap.py
+
+2. Jalankan buildout
+
+ $ ./bin/buildout
+
+3. Buat proyek
+
+ $ ./bin/trac-admin /path/ke/proyek/
+
+4. Konfigurasi. Cek bagian konfigurasi di bawah untuk informasi lebih lanjut.
+
+ $ vi /path/ke/proyek/conf/trac.ini
+
+5. Jalankan Trac
+
+ $ ./bin/tracd -s -p 8080 /path/ke/proyek/
+
+Konfigurasi
+-----------
+
+Konfigurasi tambahan
+
+ [wiki]
+ repository_dir = /path/ke/repository/bzr/
+ repository_type = bzr
+
+ [components]
+ tracbzr.* = enabled
+ trac.web.auth.* = disabled
+ authopenid.* = enabled
+ includemacro.* = enabled
+ tractoc.* = enabled
+ redirect.* = enabled
+ irclogs.irclogsplugin = enabled
+
+ [irclogs]
+ indexer = builtin:///var/www/trac/indexer/irclogs.idx?cache=true
+ path = /home/irgsh/irc/log/ChannelLogger
+ prefix = #blankon
+
|
fajran/dev.boi
|
605dfa63aee6864a60ae47676fe3eadd7d0bb5f2
|
Tambah beberapa modul lagi
|
diff --git a/buildout.cfg b/buildout.cfg
index 7efcd2b..d526135 100644
--- a/buildout.cfg
+++ b/buildout.cfg
@@ -1,7 +1,18 @@
[buildout]
parts = trac
+find-links =
+ http://arsip.fajran.web.id/blankon/pypi/
+ http://pypi.python.org/simple/
[trac]
recipe = zc.recipe.egg
-eggs = Trac
+eggs =
+ Trac ==0.11.6
+ TracBzr
+ TracAuthOpenId
+ TracIncludeMacro
+ TracTocMacro
+ TracWikiRename
+ TracRedirect
+ irclogs
|
honzasterba/minis
|
a394c6fc99f4075e234ca1394b9f5ca43478744f
|
toptal interview
|
diff --git a/toptal_2016/src/com/jansterba/Domino.java b/toptal_2016/src/com/jansterba/Domino.java
new file mode 100644
index 0000000..3eb5eba
--- /dev/null
+++ b/toptal_2016/src/com/jansterba/Domino.java
@@ -0,0 +1,44 @@
+package com.jansterba;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Domino {
+
+ public static void main(String[] args) throws IOException {
+ List<Integer> result = new Domino().domino();
+ for (Integer i : result) {
+ System.out.println(i);
+ }
+
+ }
+
+ public List<Integer> domino() throws IOException {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("s.txt")));
+ String line;
+ List<Integer> results = new ArrayList<>();
+ while ((line = reader.readLine()) != null) {
+ int longestStreak = 1;
+ int currentStreak = 1;
+ String lastRight = line.substring(2, 3);
+ for (int tileIndex = 1; tileIndex*4 < line.length(); tileIndex++) {
+ int tileStart = tileIndex*4;
+ String left = line.substring(tileStart, tileStart+1);
+ String right = line.substring(tileStart+2, tileStart+3);
+ if (left.equals(lastRight)) {
+ currentStreak++;
+ } else if (currentStreak > longestStreak) {
+ longestStreak = currentStreak;
+ currentStreak = 1;
+ }
+ lastRight = right;
+ }
+ if (currentStreak > longestStreak) {
+ longestStreak = currentStreak;
+ }
+ results.add(longestStreak);
+ }
+ return results;
+ }
+}
diff --git a/toptal_2016/src/com/jansterba/Polish.java b/toptal_2016/src/com/jansterba/Polish.java
new file mode 100644
index 0000000..0fbdef8
--- /dev/null
+++ b/toptal_2016/src/com/jansterba/Polish.java
@@ -0,0 +1,42 @@
+package com.jansterba;
+
+public class Polish {
+
+ /*
+ 2 1 + => 3
+ 5 5 + 3 * => 10 3 * => 30
+
+ "5 2 + 3 *" => 21
+ "5 2 * 2 * 4 +" => 24
+ "5" => 5
+ "0 1 *" => 0
+ */
+
+ public static void main(String[] args) {
+ Polish p = new Polish();
+ System.out.println(p.solve("2 1 +"));
+ System.out.println(p.solve("5 5 + 3 *"));
+ System.out.println(p.solve("5 2 + 3 *"));
+ System.out.println(p.solve("5 2 * 2 * 4 +"));
+ System.out.println(p.solve("5"));
+ System.out.println(p.solve("0 1 *"));
+ }
+
+ public int solve(String expression) {
+ String[] ops = expression.split(" ");
+ int stack = Integer.parseInt(ops[0]);
+ int i = 1;
+ while (i < ops.length-1) {
+ int number = Integer.parseInt(ops[i]);
+ String operator = ops[i+1];
+ if (operator.equals("+")) {
+ stack += number;
+ } else {
+ stack *= number;
+ }
+ i += 2;
+ }
+ return stack;
+ }
+
+}
diff --git a/toptal_2016/src/com/jansterba/Solution.java b/toptal_2016/src/com/jansterba/Solution.java
new file mode 100644
index 0000000..e7b12fa
--- /dev/null
+++ b/toptal_2016/src/com/jansterba/Solution.java
@@ -0,0 +1,36 @@
+package com.jansterba;
+
+class Solution {
+
+ public static void main(String[] args) {
+ Solution s = new Solution();
+ int[] A = new int[] { 5, 5, 1, 7, 2, 3, 5 };
+ System.out.println(s.solution(5, A));
+ System.out.println(s.solution(1, new int[] { 1 }));
+ System.out.println(s.solution(2, new int[] { 1 }));
+ System.out.println(s.solution(10, new int[] { 1, 2, 3, 4 }));
+ System.out.println(s.solution(10, new int[] { 11, 12, 13, 14, 15, 16 }));
+ System.out.println(s.solution(10, new int[] { 10, 10, 13, 14, 15, 10 }));
+ }
+
+ public int solution(int X, int[] A) {
+ int nonEqualCount = 0;
+ for (int a : A) {
+ if (a != X) {
+ nonEqualCount++;
+ }
+ }
+ int i = 0;
+ int equalCount = 0;
+ while (equalCount != nonEqualCount) {
+ if (A[i] == X) {
+ equalCount++;
+ } else {
+ nonEqualCount--;
+ }
+ i++;
+ }
+ return i;
+ }
+
+}
\ No newline at end of file
diff --git a/toptal_2016/src/com/jansterba/s.txt b/toptal_2016/src/com/jansterba/s.txt
new file mode 100644
index 0000000..e98c3c8
--- /dev/null
+++ b/toptal_2016/src/com/jansterba/s.txt
@@ -0,0 +1,6 @@
+6-3
+4-3,5-1,2-2,1-3,4-4
+1-1,3-5,5-2,2-3,2-4
+1-2,1-2
+3-2,2-1,1-4,4-4,5-4,4-2,2-1
+5-5,5-5,4-4,5-5,5-5,5-5,5-5,5-5,5-5,5-5
diff --git a/toptal_2016/src/com/jansterba/s2.txt b/toptal_2016/src/com/jansterba/s2.txt
new file mode 100644
index 0000000..75697e7
--- /dev/null
+++ b/toptal_2016/src/com/jansterba/s2.txt
@@ -0,0 +1,6 @@
+6-3
+4-3,5-1,2-2,1-3,4-4
+1-1,3-5,5-2,2-3,2-4
+1-2,1-2
+3-2,2-1,1-4,4-4,5-4,4-2,2-1
+
diff --git a/toptal_2016/src/com/jansterba/task2/Solution.java b/toptal_2016/src/com/jansterba/task2/Solution.java
new file mode 100644
index 0000000..8359f6f
--- /dev/null
+++ b/toptal_2016/src/com/jansterba/task2/Solution.java
@@ -0,0 +1,16 @@
+package com.jansterba.task2;
+
+class Solution {
+
+ // 0, 0 + x moves
+ // vertical: x* = x +- 2 y* = y +- 1 (4 moves)
+ // horizontal: x* = x +- 1 y* = y +- 2 (4 moves)
+
+ // A,B = x*veritcal + y*horizontal
+
+ public int solution(int A, int B) {
+ // write your code in Java SE 8)
+ return 0;
+ }
+
+}
\ No newline at end of file
diff --git a/toptal_2016/src/com/jansterba/task3/Solution.java b/toptal_2016/src/com/jansterba/task3/Solution.java
new file mode 100644
index 0000000..c6b2511
--- /dev/null
+++ b/toptal_2016/src/com/jansterba/task3/Solution.java
@@ -0,0 +1,64 @@
+package com.jansterba.task3;
+
+import java.util.Arrays;
+
+class Solution {
+
+ static Solution s = new Solution();
+
+ public static void main(String [] a) {
+ test(new int[] {1});
+ test(new int[] {0});
+ test(new int[] {1,1});
+ test(new int[] {1,0,0,1,1});
+ test(new int[] {1,0,0,1,1,1});
+ test(new int[] {1,1,1,1,1,1,1,1,1,1,1});
+ test(new int[] {0,1,0,1,0,1,0,1,0,1,0});
+ test(new int[] {1,0,1,0,1,0,1,0,1,0,1});
+ }
+
+ public static void test(int[] a) {
+ System.out.print(s.toDecimal(a) + " ");
+ print(s.solution(a));
+ System.out.println(" " + s.toDecimal(s.solution(a)));
+ }
+
+ public static void print(int[] a) {
+ for (int x : a ) {
+ System.out.print(x);
+ }
+ }
+
+ public int[] solution(int[] A) {
+ int M = toDecimal(A);
+ M = -M;
+ int[] result = new int[A.length];
+ int i = 0;
+ while (M != 0) {
+ int mod = M % -2;
+ if (mod < 0) {
+ result[i] = 1;
+ M -= 1;
+ } else {
+ result[i] = mod;
+ }
+ M /= -2;
+ i++;
+ if (i == result.length) {
+ result = Arrays.copyOf(result, result.length*2);
+ }
+ }
+ return result;
+ }
+
+ public int toDecimal(int[] A) {
+ int M = 0;
+ int base = 1;
+ for (int bit : A) {
+ M += bit * base;
+ base *= -2;
+ }
+ return M;
+ }
+
+}
\ No newline at end of file
|
honzasterba/minis
|
4cf930093077d6d9fda22daa0b29656bbb6a73e7
|
hackerrrank things
|
diff --git a/foto_reorg/main.rb b/foto_reorg/main.rb
new file mode 100644
index 0000000..54b2079
--- /dev/null
+++ b/foto_reorg/main.rb
@@ -0,0 +1,54 @@
+def is_event(month)
+ month.match /\s/
+end
+
+def has_files(month)
+ `ls -1 '#{month}'`.split(/\n/).collect do |subdir|
+ subdir_path = "#{month}/#{subdir}"
+ if File.file?(subdir_path)
+ return true
+ end
+ end
+ false
+end
+
+def subdir_target(month, subdir)
+ if subdir.match /^#{month}.*/
+ subdir
+ else
+ "#{month} #{subdir}"
+ end
+end
+
+def move_subdirs(month)
+ `ls -1 '#{month}'`.split(/\n/).collect do |subdir|
+ subdir_path = "#{month}/#{subdir}"
+ if File.directory?(subdir_path)
+ "mv '#{subdir_path}' '#{subdir_target(month, subdir)}'"
+ else
+ nil
+ end
+ end
+end
+
+def remove_month_if_no_files(month)
+ if has_files(month)
+ []
+ else
+ ["rmdir '#{month}'"]
+ end
+end
+
+months = `ls -1`.split(/\n/)
+
+commands = months.collect do |month|
+ if is_event(month)
+ # do nothing
+ else
+ move_subdirs(month) + remove_month_if_no_files(month)
+ end
+end
+
+commands.flatten.reject { |a| a.nil? || a == "" }.each do |c|
+ puts c
+end
\ No newline at end of file
diff --git a/hackerrank/01_robots/robots.rb b/hackerrank/01_robots/robots.rb
new file mode 100644
index 0000000..86d797c
--- /dev/null
+++ b/hackerrank/01_robots/robots.rb
@@ -0,0 +1,77 @@
+def read_tests(input)
+ num_tests = input.gets.to_i
+ tests = []
+ num_tests.times do
+ tests << read_test(input)
+ end
+ tests
+end
+
+def read_test(input)
+ num_containers, num_queries = read_two_ints(input)
+ queries = []
+ num_queries.times do
+ queries << read_two_ints(input)
+ end
+ { containers: num_containers, queries: queries }
+end
+
+def read_two_ints(input)
+ input.gets.split(" ").collect { |n| n.to_i }
+end
+
+def compute_distances(inputs)
+ inputs.collect do |input|
+ find_minimum_distance input
+ end
+end
+
+def find_minimum_distance(input)
+ queries = input[:queries]
+ max_distance = 2 * (1..input[:containers]).inject(0) { |sum,e| sum + e }
+ minimum_distance(nil, nil, queries.dup, 0, 0, max_distance)
+end
+
+def minimum_distance(r1, r2, queries, i, total, max_distance)
+ if i == queries.length || total > max_distance
+ return total
+ end
+
+ query = queries[i]
+ if r1.nil?
+ dr1 = minimum_distance(query[1], r2, queries, i+1, total+travel(r1, query),
+ max_distance)
+ dr2 = dr1
+ elsif !r2.nil? && (r1 - query[0]).abs < (r2 - query[0]).abs
+ dr1 = minimum_distance(query[1], r2, queries, i+1, total+travel(r1, query),
+ max_distance)
+ dr2 = minimum_distance(r1, query[1], queries, i+1, total+travel(r2, query),
+ [max_distance, dr1].min)
+ else
+ dr2 = minimum_distance(r1, query[1], queries, i+1, total+travel(r2, query),
+ max_distance)
+ dr1 = minimum_distance(query[1], r2, queries, i+1, total+travel(r1, query),
+ [max_distance, dr2].min)
+ end
+ [dr1, dr2].min
+end
+
+def travel(robot_pos, query)
+ if robot_pos
+ distance(robot_pos, query[0]) + distance(*query)
+ else
+ distance(*query)
+ end
+end
+
+def distance(a, b)
+ (a - b).abs
+end
+
+def main
+ tests = read_tests(STDIN)
+ distances = compute_distances(tests)
+ distances.each do |distance|
+ puts distance
+ end
+end
\ No newline at end of file
diff --git a/hackerrank/01_robots/robots_dp.rb b/hackerrank/01_robots/robots_dp.rb
new file mode 100644
index 0000000..e712117
--- /dev/null
+++ b/hackerrank/01_robots/robots_dp.rb
@@ -0,0 +1,72 @@
+def read_tests(input)
+ num_tests = input.gets.to_i
+ tests = []
+ num_tests.times do
+ tests << read_test(input)
+ end
+ tests
+end
+
+def read_test(input)
+ num_containers, num_queries = read_two_ints(input)
+ queries = []
+ num_queries.times do
+ queries << read_two_ints(input)
+ end
+ { containers: num_containers, queries: queries }
+end
+
+def read_two_ints(input)
+ input.gets.split(" ").collect { |n| n.to_i }
+end
+
+
+def compute_distances(inputs)
+ inputs.collect do |input|
+ find_minimum_distance input
+ end
+end
+
+def find_minimum_distance(input)
+ queries = input[:queries]
+ m = input[:containers]
+ dp = Array.new(queries.length+1) do
+ Array.new(m) do
+ Array.new(m) do
+ 0
+ end
+ end
+ end
+ (1..queries.length).each do |i|
+ options_a = []
+ options_b = []
+ query = queries[i-1]
+ m.times do |j|
+ m.times do |k|
+ options_a << dp[i-1][j][k] + (j - query[0]-1).abs
+ options_b << dp[i-1][j][k] + (k - query[0]-1).abs
+ end
+ end
+ m.times do |jk|
+ dp[i][query[1]-1][jk] = options_a.min + query_distance(query)
+ dp[i][jk][query[1]-1] = options_b.min + query_distance(query)
+ end
+ end
+ min = 10e10
+ m.times do |j|
+ min = [min, dp[queries.length][j].min].min
+ end
+ min
+end
+
+def query_distance(query)
+ (query[0] - query[1]).abs
+end
+
+def main
+ tests = read_tests(STDIN)
+ distances = compute_distances(tests)
+ distances.each do |distance|
+ puts distance
+ end
+end
\ No newline at end of file
diff --git a/hackerrank/01_robots/robots_test.rb b/hackerrank/01_robots/robots_test.rb
new file mode 100644
index 0000000..5408224
--- /dev/null
+++ b/hackerrank/01_robots/robots_test.rb
@@ -0,0 +1,38 @@
+require 'test/unit'
+require 'benchmark'
+
+require './hackerrank/01_robots/robots_dp'
+
+class TestThis < Test::Unit::TestCase
+
+ def read_results(num, path)
+ results = []
+ File.open(path, 'r') do |f|
+ num.times do
+ results << f.gets.to_i
+ end
+ end
+ results
+ end
+
+ def run_test_name(test_name)
+ inputs = nil
+ File.open("./hackerrank/01_robots/tests/input#{test_name}.txt", 'r') do |f|
+ inputs = read_tests(f)
+ end
+ results = read_results inputs.length, "./hackerrank/01_robots/tests/output#{test_name}.txt"
+ results.size.times do |i|
+ actual = nil
+ time = Benchmark.measure {
+ actual = find_minimum_distance(inputs[i])
+ }
+ puts "test #{i}: #{time.real}"
+ assert_equal results[i], actual
+ end
+ end
+
+ def test_stuff
+ run_test_name('01')
+ end
+
+end
diff --git a/hackerrank/01_robots/tests/input01.txt b/hackerrank/01_robots/tests/input01.txt
new file mode 100644
index 0000000..f44da31
--- /dev/null
+++ b/hackerrank/01_robots/tests/input01.txt
@@ -0,0 +1,316 @@
+50
+10 8
+5 10
+10 2
+9 10
+3 6
+6 9
+2 9
+2 8
+6 5
+8 7
+8 3
+7 6
+5 4
+6 4
+7 1
+8 6
+4 7
+8 3
+4 5
+4 8
+8 5
+7 4
+6 2
+1 3
+2 7
+5 1
+9 8
+4 8
+3 9
+8 2
+5 9
+6 9
+1 4
+5 3
+5 6
+7 6
+1 5
+4 7
+6 3
+6 2
+2 1
+5 3
+5 1
+2 3
+10 9
+5 9
+7 9
+8 10
+9 3
+10 9
+4 7
+10 4
+5 9
+8 1
+10 7
+2 1
+5 7
+1 8
+8 2
+8 5
+7 4
+2 9
+10 8
+6 1
+2 4
+1 9
+2 10
+7 9
+8 4
+8 5
+8 1
+8 4
+2 8
+2 3
+6 2
+7 5
+7 1
+6 2
+5 2
+3 2
+1 5
+5 8
+4 3
+1 3
+3 1
+2 3
+5 1
+2 4
+4 3
+4 5
+6 5
+6 5
+1 5
+1 5
+2 5
+3 1
+5 4
+3 5
+1 3
+4 2
+5 1
+10 2
+1 4
+10 3
+9 4
+6 7
+4 6
+5 3
+1 7
+8 4
+4 2
+3 8
+1 2
+3 7
+5 7
+4 1
+5 3
+5 2
+3 1
+4 5
+4 3
+1 3
+7 2
+6 4
+5 2
+7 5
+4 1
+1 4
+1 4
+4 3
+1 2
+5 7
+2 5
+3 2
+2 1
+3 4
+3 5
+1 2
+1 4
+8 10
+6 1
+2 6
+8 2
+3 5
+7 2
+1 5
+2 1
+1 8
+2 8
+2 7
+7 10
+3 4
+6 1
+5 7
+1 4
+4 5
+5 2
+5 2
+5 3
+7 2
+3 5
+5 10
+4 3
+3 4
+2 4
+4 2
+1 4
+5 2
+2 1
+2 1
+4 3
+1 3
+5 9
+3 5
+4 5
+2 5
+2 5
+2 3
+2 5
+5 2
+1 4
+4 2
+7 10
+1 5
+6 2
+3 6
+7 4
+6 3
+2 5
+6 2
+7 6
+4 3
+4 6
+10 5
+5 9
+5 4
+3 2
+4 3
+8 10
+5 8
+4 2
+4 5
+3 5
+3 4
+4 3
+3 2
+3 5
+4 5
+6 3
+6 2
+2 5
+4 2
+8 2
+5 8
+7 3
+7 1
+1 4
+8 5
+7 1
+4 2
+8 1
+1 7
+6 5
+7 5
+1 2
+6 1
+5 3
+7 5
+5 1
+9 4
+2 7
+2 3
+6 7
+2 1
+9 7
+2 8
+5 9
+1 5
+2 9
+1 7
+8 6
+1 9
+8 5
+2 3
+6 8
+8 3
+7 3
+4 2
+10 2
+6 5
+5 3
+9 7
+9 7
+5 9
+4 8
+4 5
+1 6
+3 7
+9 4
+7 10
+3 5
+3 1
+1 7
+5 6
+5 7
+1 6
+3 6
+3 6
+2 4
+6 2
+5 9
+4 5
+1 2
+2 3
+1 2
+3 1
+4 1
+2 3
+2 4
+2 4
+8 2
+6 2
+1 4
+6 3
+4 6
+6 2
+4 3
+6 6
+2 5
+1 2
+6 3
+3 2
+1 4
+2 1
+7 4
+4 3
+2 4
+2 3
+7 3
+8 3
+3 5
+6 8
+4 8
+10 1
+7 10
+6 4
+1 5
+2 4
+2 1
+6 5
+5 4
+2 4
+3 4
+2 3
+4 1
\ No newline at end of file
diff --git a/hackerrank/01_robots/tests/input03.txt b/hackerrank/01_robots/tests/input03.txt
new file mode 100644
index 0000000..dee0192
--- /dev/null
+++ b/hackerrank/01_robots/tests/input03.txt
@@ -0,0 +1,5112 @@
+50
+100 177
+21 47
+83 80
+91 7
+25 77
+78 9
+44 55
+78 75
+69 83
+97 59
+29 35
+27 59
+98 88
+4 43
+9 11
+9 67
+39 21
+44 73
+2 42
+29 62
+51 85
+93 62
+70 58
+66 38
+14 7
+35 65
+73 34
+2 32
+78 96
+71 81
+65 60
+91 4
+38 43
+80 43
+70 21
+43 70
+83 53
+27 10
+71 28
+52 33
+14 74
+84 86
+43 40
+73 74
+35 36
+19 58
+68 85
+39 40
+58 38
+15 1
+59 47
+64 51
+8 91
+90 22
+66 65
+87 88
+34 79
+31 43
+29 19
+34 15
+67 20
+11 28
+38 52
+83 86
+53 37
+45 60
+9 55
+48 57
+36 17
+65 98
+44 73
+16 29
+90 53
+13 71
+24 76
+75 98
+92 67
+55 46
+98 67
+81 88
+32 5
+41 65
+100 53
+84 78
+93 49
+53 17
+61 55
+41 57
+86 3
+41 36
+92 20
+11 97
+79 31
+72 43
+74 71
+21 36
+27 19
+91 40
+79 51
+19 76
+60 44
+25 89
+81 62
+68 80
+78 68
+71 8
+97 93
+23 62
+20 72
+57 78
+64 16
+17 51
+53 22
+55 37
+63 65
+61 85
+5 31
+37 65
+99 5
+88 2
+41 94
+7 65
+42 15
+50 9
+59 87
+22 90
+97 14
+79 60
+80 92
+78 57
+8 77
+82 8
+79 5
+54 65
+85 8
+94 40
+73 30
+30 20
+69 76
+92 26
+23 40
+52 49
+45 58
+78 63
+30 49
+75 26
+70 14
+47 51
+92 7
+50 79
+41 57
+37 75
+88 30
+63 90
+84 63
+81 41
+66 5
+14 69
+79 70
+79 62
+12 82
+46 18
+76 2
+51 63
+34 40
+15 72
+8 18
+97 30
+23 55
+11 31
+32 42
+6 51
+22 27
+52 96
+9 53
+77 97
+90 20
+67 39
+121 29
+91 31
+93 111
+10 34
+93 84
+43 18
+41 68
+41 22
+115 117
+7 103
+97 102
+48 64
+3 98
+94 12
+96 110
+26 102
+71 39
+47 80
+29 30
+83 81
+38 80
+36 76
+44 7
+30 44
+102 67
+61 15
+99 92
+93 60
+38 28
+10 76
+101 130
+84 97
+44 25
+67 57
+7 13
+53 86
+51 72
+37 69
+64 57
+37 15
+82 89
+3 70
+64 61
+14 8
+77 65
+12 97
+52 30
+4 20
+63 47
+79 86
+73 70
+41 31
+50 35
+44 43
+99 9
+92 5
+45 30
+16 97
+19 87
+5 50
+58 66
+18 46
+98 29
+83 54
+68 61
+90 27
+2 7
+53 60
+93 15
+22 23
+38 76
+42 30
+84 73
+35 16
+65 49
+80 41
+92 9
+8 91
+57 22
+48 53
+36 31
+93 14
+26 7
+25 32
+21 65
+71 51
+22 91
+101 14
+62 13
+48 27
+85 25
+20 54
+45 8
+39 93
+61 56
+25 100
+45 81
+27 3
+74 100
+32 41
+26 83
+48 81
+28 69
+3 66
+60 22
+73 9
+92 95
+5 86
+89 65
+70 63
+65 11
+73 46
+9 90
+5 78
+70 78
+29 96
+1 90
+59 27
+36 32
+66 76
+96 32
+43 5
+97 39
+22 45
+71 19
+62 30
+84 99
+77 67
+3 63
+39 34
+52 93
+63 62
+18 9
+78 59
+17 71
+97 26
+30 73
+95 78
+8 23
+96 40
+57 87
+49 13
+23 94
+58 5
+80 67
+87 63
+13 54
+4 95
+67 78
+83 28
+33 3
+85 74
+19 98
+35 42
+32 68
+56 52
+47 35
+8 88
+36 26
+16 82
+94 100
+191 168
+187 91
+11 139
+11 137
+37 5
+53 78
+115 129
+19 24
+152 55
+121 126
+87 185
+120 62
+99 133
+79 22
+82 37
+41 117
+84 9
+125 138
+107 189
+96 172
+147 145
+191 123
+81 5
+3 31
+180 189
+145 15
+16 181
+157 30
+70 8
+142 13
+39 133
+147 31
+99 136
+22 17
+88 155
+21 181
+26 140
+59 127
+122 92
+114 123
+189 153
+24 37
+171 36
+50 112
+115 172
+163 18
+115 175
+57 90
+46 96
+56 100
+40 97
+60 48
+132 110
+32 90
+42 74
+120 115
+17 69
+8 21
+36 57
+169 187
+175 129
+125 126
+40 62
+105 74
+56 40
+153 134
+157 175
+167 177
+187 10
+65 107
+119 145
+111 161
+168 37
+190 128
+74 154
+102 174
+7 64
+61 150
+190 41
+143 1
+50 124
+13 148
+110 49
+29 187
+66 128
+183 169
+39 167
+78 79
+88 48
+175 181
+95 126
+14 187
+94 114
+157 162
+181 3
+108 64
+126 84
+62 84
+169 136
+147 34
+11 104
+76 154
+134 111
+123 66
+37 81
+62 23
+43 130
+100 37
+53 149
+72 14
+80 75
+52 174
+172 46
+32 46
+142 57
+2 162
+161 112
+161 34
+57 190
+77 138
+1 110
+148 125
+122 65
+177 20
+167 110
+27 169
+130 120
+161 142
+148 5
+61 29
+98 131
+23 13
+71 59
+30 15
+24 173
+138 161
+39 179
+78 117
+32 40
+67 14
+21 27
+179 172
+67 128
+7 123
+19 164
+104 128
+26 76
+189 108
+38 2
+50 171
+144 159
+62 121
+191 144
+71 155
+135 36
+63 165
+140 98
+185 68
+40 70
+168 101
+7 126
+36 30
+110 32
+174 45
+134 85
+122 19
+113 160
+79 170
+100 28
+133 180
+115 76
+91 37
+17 32
+3 106
+4 38
+40 55
+28 118
+64 109
+133 48
+46 112
+16 85
+84 61
+9 100
+128 15
+93 13
+11 44
+48 120
+60 12
+23 34
+11 53
+83 108
+76 128
+83 129
+39 41
+21 100
+93 100
+18 56
+45 39
+97 107
+30 106
+113 66
+124 51
+114 113
+121 76
+25 84
+67 97
+51 128
+53 99
+19 98
+104 77
+43 133
+55 26
+32 48
+3 35
+11 20
+132 85
+16 90
+93 45
+121 128
+35 100
+100 99
+108 98
+17 31
+2 24
+33 11
+90 36
+64 104
+47 51
+3 80
+60 49
+70 96
+62 88
+109 64
+20 77
+9 58
+101 98
+80 23
+100 63
+129 113
+43 17
+59 128
+23 55
+111 22
+5 125
+63 36
+34 82
+41 32
+3 74
+119 65
+76 19
+44 86
+80 115
+98 46
+28 101
+70 33
+74 71
+99 22
+131 117
+108 91
+9 49
+116 51
+108 119
+34 125
+13 83
+10 51
+95 87
+21 48
+86 81
+9 22
+58 89
+47 99
+47 70
+96 85
+75 95
+72 99
+129 71
+101 131
+66 93
+72 46
+91 93
+16 57
+30 71
+130 31
+95 22
+55 69
+6 36
+31 45
+24 37
+27 117
+131 58
+66 71
+109 123
+78 16
+123 57
+8 24
+28 7
+93 83
+97 71
+8 101
+4 119
+64 99
+122 102
+122 53
+41 4
+41 133
+42 28
+82 88
+70 110
+95 112
+11 94
+20 66
+87 106
+32 10
+83 14
+3 57
+52 1
+35 70
+87 100
+81 68
+125 102
+39 10
+82 9
+75 52
+37 79
+2 33
+95 111
+20 12
+109 113
+29 62
+19 51
+24 87
+39 19
+38 25
+66 7
+114 34
+28 80
+93 70
+44 7
+60 56
+62 102
+36 24
+40 126
+126 34
+41 92
+132 28
+39 89
+10 133
+68 66
+45 114
+73 35
+155 86
+106 30
+89 95
+113 16
+33 41
+138 62
+85 92
+70 27
+2 70
+145 79
+83 63
+77 63
+122 54
+123 93
+75 22
+129 120
+94 137
+12 29
+114 86
+125 121
+121 13
+65 3
+79 92
+89 108
+148 150
+20 93
+133 69
+129 24
+59 150
+93 90
+35 122
+82 112
+74 72
+77 143
+72 93
+36 14
+88 101
+152 48
+4 35
+103 62
+44 15
+45 133
+37 77
+58 134
+25 107
+139 111
+85 48
+103 132
+102 104
+75 86
+97 39
+119 39
+131 93
+119 122
+138 12
+59 40
+67 153
+86 54
+68 49
+45 55
+25 39
+148 135
+129 31
+96 63
+98 97
+20 132
+76 132
+3 7
+88 109
+21 103
+12 31
+33 152
+109 86
+25 15
+63 98
+128 52
+10 41
+153 44
+101 98
+61 48
+20 151
+68 78
+43 24
+36 73
+59 102
+55 29
+54 95
+153 32
+7 147
+73 43
+141 45
+49 40
+99 148
+84 14
+91 50
+98 37
+24 79
+52 144
+12 95
+103 44
+111 59
+96 137
+91 94
+48 150
+65 129
+149 49
+140 91
+79 74
+81 22
+118 23
+64 129
+113 57
+33 61
+123 150
+21 114
+71 134
+75 3
+97 35
+68 74
+74 86
+131 192
+34 118
+43 4
+22 53
+72 21
+131 81
+32 100
+91 116
+24 36
+42 70
+86 79
+7 71
+35 99
+108 34
+50 68
+15 78
+122 119
+124 91
+58 105
+20 62
+72 118
+15 13
+31 129
+47 90
+64 92
+96 19
+98 8
+78 119
+52 63
+115 102
+126 72
+121 60
+113 87
+5 96
+117 127
+51 129
+69 109
+127 93
+13 90
+86 105
+2 26
+22 102
+52 14
+92 36
+3 77
+16 86
+123 21
+80 92
+78 16
+123 66
+93 23
+47 69
+67 65
+75 7
+19 7
+59 6
+28 67
+60 33
+118 33
+62 106
+17 4
+91 96
+90 25
+76 69
+28 11
+92 33
+63 108
+100 74
+24 11
+120 85
+72 34
+71 28
+21 115
+14 15
+33 72
+46 103
+43 33
+61 30
+95 58
+5 18
+67 115
+84 18
+60 84
+69 2
+13 48
+4 10
+78 29
+92 102
+1 60
+32 54
+95 40
+80 23
+76 119
+63 81
+107 108
+56 77
+105 33
+124 28
+63 114
+68 43
+1 25
+107 44
+127 48
+99 23
+26 60
+19 21
+88 97
+95 25
+76 47
+101 13
+75 16
+17 112
+94 20
+15 94
+99 4
+90 2
+58 20
+78 15
+99 26
+101 17
+128 118
+66 88
+63 113
+15 80
+106 51
+89 29
+93 120
+80 122
+105 38
+49 50
+46 34
+123 56
+53 12
+41 35
+99 119
+99 116
+82 100
+66 89
+60 83
+21 34
+105 8
+19 108
+30 7
+55 84
+120 73
+68 70
+59 120
+70 26
+65 60
+77 46
+57 30
+104 129
+4 40
+95 18
+29 19
+96 40
+128 103
+87 38
+86 93
+43 126
+75 56
+124 99
+45 16
+53 40
+91 110
+69 34
+90 23
+123 64
+20 115
+103 127
+7 129
+48 36
+50 107
+83 97
+32 100
+101 65
+116 99
+44 8
+61 3
+91 8
+129 95
+68 17
+105 12
+57 97
+16 113
+59 123
+9 70
+92 118
+53 69
+57 22
+116 62
+73 125
+75 124
+112 114
+24 26
+91 11
+29 44
+31 47
+7 78
+51 87
+41 76
+39 24
+87 78
+66 64
+54 68
+89 18
+35 72
+50 35
+6 26
+25 84
+72 56
+51 53
+84 71
+49 42
+74 107
+103 79
+41 65
+30 84
+94 106
+102 81
+24 47
+112 41
+46 99
+43 24
+51 78
+13 11
+104 37
+53 77
+67 5
+46 66
+47 81
+7 96
+36 3
+81 16
+56 78
+56 18
+6 101
+70 38
+78 13
+36 30
+77 4
+82 80
+79 80
+89 110
+98 77
+63 16
+77 23
+106 13
+1 83
+9 35
+46 78
+96 56
+105 81
+82 34
+76 65
+100 81
+46 85
+111 55
+37 72
+22 75
+42 109
+89 58
+92 46
+74 22
+40 71
+110 8
+7 20
+37 95
+72 21
+62 95
+79 71
+100 5
+94 86
+94 105
+19 102
+102 16
+98 59
+7 50
+37 63
+13 77
+17 53
+72 24
+27 96
+49 32
+27 78
+16 3
+95 19
+28 47
+3 92
+69 112
+32 74
+63 90
+82 41
+64 39
+31 93
+92 110
+69 59
+14 49
+19 85
+90 73
+74 89
+1 112
+21 74
+68 69
+23 102
+93 25
+20 8
+58 49
+157 176
+151 123
+86 82
+19 44
+27 77
+137 77
+66 3
+4 67
+137 29
+25 2
+127 112
+122 124
+1 134
+123 23
+99 88
+64 60
+100 101
+115 150
+29 112
+97 107
+136 48
+105 97
+157 116
+147 23
+58 71
+90 64
+10 80
+47 38
+127 114
+28 133
+132 53
+109 142
+128 5
+121 69
+38 156
+124 10
+26 152
+125 55
+153 108
+113 18
+83 22
+23 42
+134 2
+123 100
+147 90
+77 31
+156 31
+15 51
+134 126
+74 108
+97 1
+98 107
+157 36
+123 28
+25 67
+116 157
+134 136
+20 14
+146 30
+130 94
+35 19
+1 99
+40 76
+55 92
+105 24
+98 24
+12 28
+94 102
+150 107
+106 100
+79 113
+148 94
+34 117
+21 83
+98 94
+10 35
+68 30
+131 12
+149 130
+146 126
+37 39
+87 53
+126 91
+102 52
+65 111
+31 96
+153 44
+31 58
+44 120
+143 111
+43 148
+26 51
+110 137
+142 141
+128 57
+12 72
+30 152
+89 55
+156 40
+73 54
+151 149
+32 81
+15 95
+108 81
+146 8
+51 103
+13 142
+87 4
+35 78
+86 45
+7 99
+100 40
+81 123
+79 44
+66 150
+12 14
+132 124
+147 136
+66 24
+78 101
+153 137
+98 11
+151 119
+89 140
+156 43
+76 89
+82 18
+145 146
+156 128
+94 54
+91 17
+128 147
+13 68
+140 153
+145 143
+49 108
+70 109
+26 102
+42 79
+87 7
+126 24
+43 34
+71 82
+2 61
+76 70
+99 118
+151 49
+34 9
+36 119
+129 139
+113 17
+25 51
+72 26
+135 140
+77 21
+146 57
+34 156
+136 148
+27 114
+26 70
+120 11
+144 120
+56 82
+133 26
+27 139
+69 28
+57 75
+150 132
+75 61
+24 102
+133 89
+89 79
+27 17
+118 59
+114 87
+37 12
+1 57
+103 183
+64 95
+61 81
+28 34
+29 73
+33 61
+39 48
+26 49
+27 69
+99 68
+13 86
+46 11
+95 54
+23 101
+23 79
+13 50
+24 82
+18 36
+33 100
+63 67
+57 35
+25 13
+27 25
+18 103
+19 57
+34 11
+81 45
+13 38
+95 23
+99 21
+66 41
+8 17
+83 79
+32 70
+73 51
+69 91
+76 49
+18 56
+11 33
+60 66
+102 30
+91 24
+88 2
+6 25
+20 26
+73 77
+30 24
+75 37
+5 76
+80 34
+3 74
+99 102
+20 22
+9 11
+74 64
+35 84
+61 41
+28 18
+97 77
+47 101
+46 31
+53 41
+78 62
+77 7
+18 16
+41 19
+91 102
+12 77
+3 45
+21 22
+65 55
+91 82
+53 80
+62 66
+93 19
+36 14
+20 74
+73 86
+37 23
+76 69
+21 8
+16 11
+59 28
+74 66
+13 63
+86 96
+97 92
+89 2
+97 55
+103 94
+92 10
+2 52
+73 61
+56 102
+87 44
+87 63
+64 6
+47 2
+38 46
+76 50
+3 90
+45 86
+19 90
+65 33
+74 50
+94 4
+79 40
+13 21
+54 37
+72 60
+97 18
+76 82
+74 51
+53 99
+1 73
+41 88
+80 19
+82 43
+1 98
+4 57
+72 49
+58 62
+39 38
+32 59
+47 24
+18 1
+97 66
+7 10
+57 61
+11 42
+4 31
+1 36
+33 16
+88 72
+65 59
+52 62
+14 59
+76 39
+90 31
+59 56
+75 42
+62 93
+89 18
+101 11
+56 71
+92 34
+48 81
+14 61
+25 39
+62 9
+74 57
+82 95
+81 10
+56 12
+39 85
+93 27
+3 33
+63 48
+45 23
+62 65
+19 3
+91 92
+28 39
+33 65
+82 60
+35 15
+94 86
+41 67
+57 32
+88 90
+47 75
+80 58
+12 51
+18 91
+96 48
+18 59
+59 47
+52 26
+89 65
+48 36
+86 100
+71 91
+30 24
+43 30
+153 93
+30 127
+105 133
+81 153
+52 39
+151 31
+64 97
+115 14
+24 152
+54 26
+92 132
+72 86
+108 70
+109 72
+153 116
+27 130
+1 153
+107 113
+115 28
+68 95
+120 138
+64 17
+19 145
+108 35
+152 27
+45 29
+147 104
+65 131
+81 23
+58 147
+30 91
+18 28
+1 96
+132 70
+51 84
+51 12
+100 49
+124 112
+22 10
+116 54
+42 81
+82 66
+108 91
+93 51
+63 91
+2 6
+50 150
+28 131
+148 92
+77 109
+38 29
+30 12
+87 5
+97 148
+23 70
+81 53
+15 65
+90 62
+137 63
+41 118
+16 10
+139 48
+31 97
+77 117
+52 10
+82 144
+70 134
+134 85
+135 132
+48 66
+120 50
+45 42
+65 37
+39 61
+8 34
+129 44
+34 29
+119 132
+67 90
+132 62
+17 25
+44 95
+134 151
+61 11
+52 29
+27 22
+72 122
+53 99
+143 85
+37 143
+99 20
+117 40
+119 149
+112 123
+123 106
+111 56
+116 88
+45 65
+100 85
+98 91
+7 80
+11 81
+103 20
+38 95
+58 42
+107 98
+17 36
+114 51
+63 65
+85 29
+40 56
+51 46
+45 121
+14 70
+88 110
+76 42
+80 57
+33 52
+19 31
+13 1
+116 47
+74 75
+119 106
+91 62
+16 42
+82 61
+19 42
+93 102
+66 78
+108 30
+102 45
+64 28
+109 97
+7 46
+92 72
+23 120
+102 70
+52 119
+64 79
+82 32
+56 46
+94 120
+3 117
+12 92
+111 63
+45 70
+23 108
+101 107
+77 93
+28 77
+66 116
+53 102
+73 33
+119 110
+6 7
+40 60
+96 99
+32 56
+59 106
+101 43
+18 111
+40 86
+55 11
+106 49
+69 62
+119 9
+111 108
+41 97
+17 84
+84 68
+25 27
+47 3
+24 47
+7 61
+12 65
+17 108
+46 61
+39 51
+110 24
+51 29
+48 100
+14 47
+76 49
+27 120
+96 50
+80 6
+39 74
+64 9
+102 10
+111 34
+60 96
+10 9
+113 50
+115 48
+103 85
+57 104
+82 9
+12 45
+90 14
+30 92
+9 81
+183 178
+129 138
+177 7
+133 165
+73 44
+46 133
+29 175
+151 171
+62 32
+153 152
+94 83
+36 99
+14 145
+177 101
+98 58
+167 24
+112 151
+34 172
+17 93
+113 144
+92 134
+131 156
+114 11
+116 157
+80 70
+41 107
+98 53
+57 112
+69 29
+104 155
+56 125
+128 84
+120 3
+152 150
+98 115
+161 77
+171 118
+41 72
+169 34
+30 3
+44 40
+124 152
+6 129
+82 131
+66 24
+83 66
+167 24
+6 80
+144 120
+111 2
+123 68
+80 83
+2 114
+55 173
+1 100
+81 19
+174 66
+6 149
+41 151
+74 40
+180 56
+111 170
+123 111
+30 150
+92 3
+54 100
+126 49
+172 158
+56 28
+62 90
+92 129
+172 142
+6 77
+11 67
+14 31
+96 114
+70 16
+181 1
+119 66
+167 75
+44 179
+127 23
+73 174
+58 102
+90 107
+160 168
+167 135
+141 12
+43 156
+122 33
+56 131
+92 56
+2 156
+98 105
+87 161
+100 32
+160 93
+120 11
+52 71
+47 131
+128 42
+44 72
+44 139
+76 158
+71 169
+94 18
+55 112
+106 178
+66 108
+20 54
+151 67
+131 19
+91 53
+162 47
+142 43
+95 76
+15 6
+139 159
+63 82
+161 68
+143 155
+65 167
+37 88
+95 66
+70 81
+100 40
+126 159
+142 76
+44 150
+23 22
+131 2
+123 181
+2 158
+166 154
+141 131
+78 97
+113 80
+179 170
+172 52
+74 48
+181 17
+132 58
+9 23
+38 23
+124 107
+17 144
+153 166
+114 147
+25 88
+164 85
+149 3
+26 143
+102 122
+169 164
+177 44
+176 103
+90 35
+78 172
+102 22
+58 146
+78 145
+69 155
+120 62
+121 46
+79 99
+6 59
+80 158
+55 75
+74 24
+181 70
+107 164
+52 65
+66 56
+67 174
+105 28
+100 107
+77 88
+118 108
+37 15
+144 147
+79 60
+22 88
+86 115
+50 132
+103 4
+35 89
+94 49
+101 34
+4 7
+15 107
+53 112
+38 31
+70 62
+46 41
+87 37
+114 32
+70 132
+6 37
+132 130
+58 116
+76 95
+50 19
+17 93
+20 54
+39 62
+49 142
+101 8
+104 130
+9 19
+88 13
+76 96
+4 9
+88 40
+108 54
+39 98
+89 5
+46 47
+137 13
+90 112
+108 82
+25 35
+93 133
+93 44
+5 54
+140 17
+61 102
+91 68
+19 80
+61 64
+112 58
+118 30
+23 92
+117 116
+111 69
+33 80
+52 117
+99 136
+91 93
+5 94
+21 85
+73 36
+119 111
+141 64
+103 28
+45 97
+89 45
+90 31
+43 130
+42 107
+45 57
+143 36
+70 29
+140 136
+115 25
+102 18
+112 66
+7 131
+60 131
+57 80
+136 25
+113 117
+129 120
+90 68
+94 134
+100 1
+123 121
+107 29
+88 144
+61 8
+108 134
+119 52
+126 56
+15 7
+133 106
+119 28
+62 43
+64 12
+30 57
+110 92
+24 122
+91 1
+129 12
+46 72
+131 22
+125 14
+95 89
+80 64
+134 34
+56 39
+10 23
+80 98
+128 136
+83 1
+41 141
+62 97
+17 107
+135 83
+135 57
+79 136
+47 77
+20 7
+100 143
+121 41
+66 24
+122 4
+82 17
+43 12
+87 88
+113 80
+42 28
+115 8
+1 91
+81 52
+5 69
+70 125
+19 75
+138 79
+19 6
+27 70
+56 135
+78 124
+39 16
+96 137
+59 15
+18 110
+72 109
+4 82
+164 101
+112 143
+86 160
+163 97
+93 138
+96 104
+23 26
+58 145
+144 42
+70 50
+39 28
+148 60
+96 99
+70 117
+141 79
+145 77
+72 93
+137 99
+163 99
+39 159
+23 8
+53 18
+6 40
+36 126
+68 64
+96 31
+83 154
+77 138
+66 63
+50 102
+111 129
+163 75
+45 61
+43 108
+68 52
+149 37
+26 147
+141 90
+62 159
+139 150
+59 126
+108 130
+135 75
+38 50
+160 105
+89 151
+19 90
+133 57
+15 55
+106 161
+85 103
+149 39
+62 73
+81 120
+136 37
+14 6
+92 74
+109 40
+151 28
+156 86
+3 87
+11 38
+157 7
+31 54
+5 78
+58 117
+142 126
+16 139
+142 70
+28 116
+44 123
+94 109
+164 13
+115 29
+158 118
+161 142
+28 82
+109 113
+129 39
+122 74
+118 107
+68 33
+2 109
+117 59
+4 19
+18 34
+65 161
+81 146
+95 51
+86 63
+54 130
+72 84
+60 72
+162 127
+34 135
+9 118
+17 54
+55 136
+58 148
+156 11
+90 66
+100 117
+170 62
+53 28
+71 156
+27 126
+89 95
+95 45
+66 64
+34 27
+122 19
+78 33
+155 87
+55 82
+22 19
+149 137
+137 66
+91 157
+58 168
+30 72
+35 25
+145 52
+28 95
+153 130
+169 113
+113 69
+99 53
+84 157
+114 4
+47 80
+62 140
+71 155
+43 64
+63 116
+115 78
+138 86
+13 126
+8 75
+21 45
+7 21
+60 8
+124 109
+134 139
+131 161
+118 11
+18 91
+44 163
+44 7
+16 55
+42 152
+12 22
+54 160
+109 20
+125 6
+113 67
+93 162
+158 124
+119 112
+135 105
+50 53
+123 84
+152 144
+66 18
+82 155
+49 26
+186 95
+63 139
+133 174
+94 67
+93 122
+174 114
+164 111
+69 14
+148 112
+141 75
+128 69
+162 100
+104 103
+177 164
+49 38
+66 79
+182 141
+33 71
+76 128
+184 141
+132 15
+104 57
+11 108
+133 154
+47 183
+84 172
+105 71
+90 27
+143 111
+82 170
+62 16
+101 112
+145 58
+158 33
+98 71
+136 75
+138 117
+10 26
+14 88
+153 11
+183 4
+48 60
+166 157
+1 101
+11 106
+153 41
+173 25
+117 58
+178 10
+134 35
+183 142
+68 63
+94 143
+56 57
+70 163
+153 74
+18 52
+140 170
+37 29
+55 85
+184 57
+74 144
+133 119
+10 27
+98 113
+72 147
+169 121
+22 140
+66 133
+67 122
+58 100
+23 9
+67 81
+160 59
+109 81
+180 121
+139 156
+62 50
+105 144
+97 112
+121 131
+116 70
+36 71
+125 173
+150 10
+1 87
+86 128
+46 67
+3 176
+38 178
+101 105
+141 128
+95 186
+153 97
+142 157
+68 69
+139 82
+32 130
+13 5
+71 12
+133 32
+104 46
+95 55
+136 37
+24 22
+4 52
+15 132
+46 42
+96 45
+54 52
+122 15
+76 41
+131 19
+107 127
+58 38
+116 28
+131 47
+15 71
+102 22
+128 73
+9 54
+41 19
+5 70
+27 89
+60 3
+99 137
+91 33
+18 2
+10 123
+46 119
+106 53
+18 16
+108 93
+6 36
+35 57
+95 69
+66 104
+56 29
+20 55
+15 44
+101 64
+80 123
+97 74
+55 41
+109 48
+85 134
+133 74
+85 113
+117 68
+74 47
+3 59
+35 51
+64 49
+43 79
+20 121
+75 11
+37 121
+56 90
+43 127
+132 17
+119 26
+86 30
+114 56
+32 85
+20 47
+89 108
+53 90
+11 19
+67 61
+82 53
+34 121
+20 57
+125 107
+25 64
+10 12
+84 76
+27 128
+31 38
+34 50
+180 152
+51 165
+78 20
+44 141
+101 170
+75 136
+10 103
+86 25
+149 93
+34 21
+77 11
+34 17
+105 43
+132 137
+91 136
+145 177
+55 98
+84 17
+158 3
+126 11
+164 49
+9 168
+50 37
+10 8
+88 101
+171 175
+130 57
+45 38
+173 66
+94 54
+101 16
+163 52
+81 84
+43 47
+10 149
+143 80
+67 128
+65 96
+12 168
+107 101
+26 180
+70 146
+175 176
+42 148
+178 76
+95 63
+153 19
+4 145
+173 20
+100 172
+10 152
+90 60
+76 75
+113 112
+156 108
+40 1
+91 108
+162 140
+64 93
+13 71
+164 1
+104 51
+167 92
+58 83
+40 86
+37 6
+33 3
+136 45
+177 98
+48 144
+62 138
+21 129
+86 36
+139 78
+112 77
+103 51
+63 180
+84 167
+143 117
+157 166
+170 89
+176 117
+77 18
+55 96
+75 103
+83 3
+150 110
+42 146
+105 150
+42 118
+136 113
+86 113
+70 64
+159 55
+160 98
+123 145
+55 40
+96 92
+4 64
+173 63
+105 171
+73 121
+167 171
+112 62
+134 131
+77 139
+65 150
+109 148
+98 19
+97 13
+27 167
+134 122
+171 6
+102 118
+127 119
+61 147
+109 78
+42 94
+146 66
+34 64
+50 36
+99 129
+60 32
+109 147
+135 119
+171 43
+157 11
+170 3
+177 71
+109 87
+126 130
+28 179
+41 146
+2 134
+167 163
+145 123
+1 163
+93 79
+24 126
+4 117
+81 57
+124 19
+140 171
+13 4
+146 126
+37 180
+105 136
+169 159
+99 20
+126 163
+54 81
+44 18
+15 67
+114 2
+16 63
+59 71
+113 34
+22 7
+70 37
+82 27
+99 89
+102 77
+22 70
+111 11
+102 80
+41 23
+13 105
+108 35
+49 83
+41 52
+76 112
+33 77
+47 91
+103 38
+92 68
+76 94
+42 89
+21 29
+103 72
+58 79
+91 94
+100 36
+60 37
+95 84
+62 33
+93 105
+71 102
+62 85
+73 44
+81 31
+103 26
+195 137
+52 145
+192 151
+20 11
+12 148
+135 43
+10 192
+100 82
+68 46
+73 190
+154 100
+138 188
+110 47
+135 194
+177 98
+44 74
+172 100
+82 31
+111 70
+95 180
+195 64
+22 26
+144 149
+109 17
+8 72
+13 85
+145 28
+149 82
+102 96
+105 159
+89 82
+74 49
+22 56
+175 114
+156 180
+41 30
+123 65
+157 2
+52 183
+45 133
+7 101
+58 3
+41 24
+86 64
+22 180
+28 185
+25 63
+46 79
+119 187
+124 65
+78 14
+60 17
+190 181
+35 140
+76 171
+31 130
+75 83
+25 100
+184 130
+159 36
+97 121
+4 17
+171 99
+81 47
+109 93
+169 38
+58 115
+5 15
+36 193
+20 163
+3 133
+16 87
+52 162
+170 191
+2 104
+45 185
+177 170
+42 87
+142 155
+170 30
+62 109
+10 161
+115 92
+163 31
+143 61
+106 11
+83 34
+19 45
+54 183
+35 17
+134 93
+72 37
+189 52
+148 117
+11 20
+146 87
+101 136
+172 186
+151 16
+98 169
+51 18
+165 178
+14 3
+96 137
+32 30
+154 14
+98 195
+5 190
+101 120
+24 167
+91 159
+99 130
+12 65
+66 24
+93 27
+188 68
+152 187
+87 94
+133 128
+157 14
+173 11
+171 130
+59 86
+79 185
+109 11
+182 6
+152 83
+172 70
+13 56
+124 79
+112 58
+112 1
+92 108
+30 27
+54 85
+170 9
+144 155
+149 49
+155 145
+26 40
+89 58
+148 100
+84 112
+154 24
+27 116
+149 56
+99 82
+84 103
+17 138
+135 43
+118 22
+130 42
+143 120
+115 154
+36 50
+81 23
+116 126
+108 31
+144 49
+57 4
+134 128
+119 150
+28 61
+24 115
+148 75
+125 60
+3 78
+79 111
+117 89
+116 92
+27 57
+121 44
+20 23
+64 58
+144 35
+144 31
+151 99
+98 73
+151 16
+106 149
+60 117
+38 107
+141 14
+5 91
+25 85
+138 148
+152 117
+12 60
+66 32
+108 136
+29 131
+26 84
+33 122
+15 99
+136 89
+58 62
+144 96
+22 88
+26 114
+15 75
+118 15
+60 87
+107 20
+27 26
+33 143
+136 67
+17 64
+88 63
+86 124
+101 147
+84 111
+49 139
+2 73
+123 129
+16 9
+155 49
+107 39
+121 153
+85 129
+41 112
+117 5
+124 47
+17 118
+134 71
+39 111
+140 114
+29 109
+155 46
+145 109
+127 7
+125 114
+110 108
+51 14
+149 140
+57 10
+121 112
+155 78
+132 22
+26 27
+2 123
+69 75
+62 45
+65 98
+91 126
+138 146
+26 152
+85 73
+153 99
+26 105
+145 120
+53 24
+151 62
+148 45
+55 65
+39 96
+62 126
+55 38
+64 5
+126 62
+7 129
+83 42
+52 26
+93 37
+5 44
+149 57
+130 74
+99 88
+115 134
+54 80
+119 58
+111 34
+71 61
+136 130
+87 42
+116 85
+29 83
+94 86
+143 49
+91 87
+77 78
+86 44
+54 102
+98 112
+30 5
+184 23
+138 116
+157 101
+52 104
+117 13
+158 75
+108 148
+69 24
+170 77
+67 154
+86 68
+165 176
+121 20
+51 151
+61 161
+47 83
+149 132
+18 175
+158 71
+43 17
+71 96
+65 169
+77 180
+92 23
+190 34
+150 60
+85 135
+60 186
+131 59
+98 11
+146 182
+11 125
+129 94
+30 83
+100 1
+86 76
+98 176
+107 8
+155 68
+14 72
+178 83
+86 157
+15 82
+146 24
+85 174
+129 75
+46 106
+182 23
+68 72
+160 169
+60 26
+102 26
+35 78
+26 163
+41 59
+44 91
+57 116
+19 162
+112 126
+147 21
+37 2
+96 94
+89 50
+82 9
+140 8
+129 138
+141 119
+81 38
+70 90
+75 68
+29 17
+106 70
+53 125
+12 89
+53 98
+74 62
+46 38
+123 31
+129 12
+9 125
+44 30
+102 71
+66 48
+47 49
+38 70
+94 39
+36 52
+80 27
+38 62
+33 51
+28 62
+57 7
+24 73
+59 78
+100 58
+15 1
+96 66
+36 94
+2 75
+102 82
+60 71
+95 11
+8 88
+31 14
+30 34
+12 27
+4 15
+25 40
+82 90
+102 101
+15 12
+69 13
+42 98
+101 22
+100 64
+4 12
+44 55
+35 43
+89 63
+31 38
+93 70
+26 3
+70 91
+92 74
+65 62
+75 7
+59 68
+55 62
+20 4
+98 97
+7 41
+98 56
+3 59
+30 11
+11 90
+100 90
+33 54
+89 7
+76 72
+66 1
+13 89
+70 86
+23 33
+32 85
+102 32
+6 11
+24 54
+85 74
+50 24
+49 71
+81 13
+1 59
+64 37
+119 6
+59 70
+96 88
+82 44
+28 5
+118 103
+100 44
+197 110
+47 160
+5 3
+36 13
+5 147
+174 167
+27 104
+47 125
+138 9
+123 175
+168 44
+152 138
+78 1
+28 76
+66 52
+185 77
+139 67
+40 186
+88 162
+16 59
+76 90
+17 58
+105 103
+153 53
+61 69
+187 145
+29 4
+105 20
+135 56
+100 44
+90 47
+155 142
+44 31
+66 38
+39 130
+97 116
+57 17
+151 81
+194 94
+138 5
+64 197
+92 127
+43 140
+81 17
+116 51
+181 66
+186 122
+144 32
+94 146
+174 191
+69 39
+189 62
+169 47
+165 21
+43 66
+4 48
+126 185
+1 166
+134 1
+91 115
+4 12
+70 137
+176 127
+22 160
+128 130
+116 42
+143 10
+138 157
+23 127
+73 163
+5 150
+144 27
+74 112
+172 164
+173 74
+8 126
+154 136
+126 68
+157 155
+181 51
+160 103
+3 182
+108 14
+46 129
+132 11
+50 141
+121 172
+161 57
+46 168
+110 152
+50 42
+101 98
+53 2
+15 9
+46 125
+92 8
+57 20
+42 158
+24 169
+82 168
+135 41
+173 160
+49 42
+116 45
+162 72
+2 11
+126 141
+44 19
+21 65
+24 22
+36 194
+185 56
+87 163
+156 81
+112 19
+18 105
+35 104
+5 109
+38 98
+165 16
+159 123
+112 20
+174 147
+141 94
+42 70
+24 105
+27 112
+86 149
+86 100
+102 116
+149 98
+171 48
+135 40
+181 44
+108 21
+110 35
+147 118
+89 23
+153 177
+183 136
+5 49
+75 107
+157 77
+18 89
+120 84
+128 19
+17 99
+57 130
+24 166
+154 56
+84 72
+84 64
+21 154
+25 35
+161 56
+58 138
+61 100
+76 5
+71 18
+146 40
+38 55
+171 25
+31 118
+148 96
+48 9
+139 120
+42 149
+167 119
+196 142
+131 22
+172 35
+124 123
+145 32
+124 70
+113 85
+28 25
+72 42
+26 39
+142 17
+120 174
+46 85
+174 154
+6 79
+131 182
+167 3
+82 161
+175 123
+31 70
+73 105
+123 135
+124 188
+196 95
+50 85
+174 24
+37 188
+149 29
+95 167
+136 76
+158 190
+57 107
+152 170
+107 123
+189 1
+168 69
+89 177
+182 111
+60 69
+52 176
+166 43
+164 52
+56 4
+140 10
+100 80
+157 182
+140 8
+144 17
+130 57
+184 75
+147 48
+138 80
+45 10
+115 47
+57 87
+139 65
+13 160
+194 37
+54 113
+92 7
+66 60
+69 91
+112 47
+90 153
+123 69
+93 15
+96 29
+35 20
+98 88
+76 5
+68 61
+10 172
+110 78
+125 194
+24 127
+119 80
+176 155
+112 61
+64 88
+48 78
+171 68
+60 63
+96 164
+133 27
+103 64
+159 11
+125 158
+185 158
+106 181
+45 34
+145 133
+35 44
+170 30
+5 78
+54 62
+194 21
+64 137
+143 12
+3 128
+109 91
+149 75
+137 48
+146 66
+32 159
+131 27
+58 106
+181 19
+37 122
+41 29
+37 167
+5 161
+68 27
+96 89
+187 93
+130 95
+55 73
+146 118
+81 39
+133 22
+154 25
+196 67
+68 38
+48 94
+149 36
+11 1
+101 179
+14 61
+125 98
+186 45
+32 174
+104 7
+123 141
+189 49
+81 154
+25 20
+165 32
+58 177
+190 97
+191 47
+186 136
+7 148
+138 95
+96 163
+140 119
+79 104
+82 23
+93 87
+32 77
+7 55
+3 82
+130 45
+43 16
+3 55
+113 15
+81 112
+90 124
+22 74
+107 92
+11 49
+119 115
+86 43
+9 84
+62 81
+95 117
+26 93
+100 140
+101 6
+105 108
+26 45
+138 135
+10 58
+135 2
+46 126
+59 103
+51 101
+112 138
+31 98
+72 77
+42 32
+17 75
+41 123
+52 58
+9 23
+99 132
+19 49
+126 99
+19 65
+134 8
+14 15
+5 122
+93 58
+125 33
+102 113
+29 36
+41 55
+139 50
+120 16
+47 38
+43 91
+12 36
+135 121
+72 60
+3 49
+55 128
+71 45
+102 13
+52 133
+38 63
+96 93
+138 53
+100 19
+64 97
+63 26
+68 127
+133 20
+38 112
+92 42
+59 104
+138 69
+93 45
+91 140
+22 76
+8 11
+90 3
+108 126
+28 65
+118 13
+7 42
+103 135
+60 30
+90 139
+43 79
+61 40
+106 18
+41 97
+82 100
+80 135
+105 75
+26 102
+50 34
+83 28
+94 123
+11 8
+7 131
+48 130
+28 61
+123 28
+108 79
+55 32
+30 7
+51 57
+96 132
+86 72
+34 6
+77 32
+38 58
+123 15
+10 103
+108 81
+21 73
+136 13
+58 66
+57 116
+112 106
+84 34
+67 20
+60 73
+80 1
+24 64
+35 56
+5 63
+106 57
+31 106
+42 28
+60 52
+65 40
+41 6
+42 80
+25 78
+18 67
+91 79
+89 21
+60 20
+58 104
+110 9
+94 14
+55 47
+93 55
+92 99
+7 38
+79 57
+3 38
+102 40
+102 27
+47 7
+22 41
+1 105
+111 12
+52 37
+86 82
+4 109
+12 107
+2 27
+37 73
+12 1
+41 39
+29 28
+27 87
+56 108
+72 26
+33 112
+2 43
+61 70
+110 91
+27 2
+11 64
+3 31
+69 24
+94 49
+40 102
+101 29
+104 94
+111 63
+32 49
+70 72
+10 83
+105 106
+79 60
+71 90
+95 62
+10 94
+98 79
+82 62
+16 23
+68 57
+63 81
+18 35
+43 112
+44 3
+75 17
+72 29
+98 15
+14 45
+34 56
+71 11
+88 30
+72 49
+68 20
+57 67
+7 8
+75 98
+18 62
+88 96
+92 53
+45 103
+68 98
+70 2
+56 10
+25 17
+102 4
+54 15
+81 29
+77 28
+7 37
+32 106
+48 50
+91 70
+73 64
+1 103
+33 37
+144 92
+67 7
+9 137
+38 117
+33 51
+2 43
+91 48
+52 113
+49 78
+83 131
+144 112
+132 104
+92 124
+75 136
+85 100
+51 35
+120 90
+48 116
+24 139
+99 132
+142 4
+93 140
+126 74
+39 69
+13 83
+18 60
+48 29
+11 36
+119 122
+1 89
+42 35
+58 92
+18 78
+130 105
+107 86
+22 123
+24 75
+112 31
+88 139
+132 41
+120 67
+10 137
+105 51
+124 1
+35 41
+3 2
+10 22
+62 95
+128 29
+67 68
+59 38
+88 105
+24 101
+19 105
+112 77
+129 58
+122 18
+117 102
+130 119
+81 107
+121 35
+137 78
+44 93
+22 4
+121 47
+137 42
+79 105
+33 1
+37 49
+62 100
+110 35
+38 131
+28 2
+105 81
+67 101
+32 117
+143 57
+123 57
+41 106
+123 74
+53 12
+125 55
+143 94
+72 95
+104 115
+137 98
+123 6
+29 107
+21 56
+46 38
+84 67
+50 28
+15 105
+198 194
+75 196
+99 126
+187 54
+68 151
+48 126
+147 61
+159 175
+75 175
+48 54
+179 12
+25 6
+58 43
+122 77
+141 39
+105 123
+70 123
+108 93
+54 26
+140 5
+82 170
+159 16
+38 129
+102 186
+159 10
+53 73
+49 38
+111 27
+129 131
+98 142
+179 158
+19 198
+35 119
+24 67
+166 91
+102 163
+75 104
+50 4
+162 137
+27 150
+138 30
+57 77
+24 5
+4 78
+115 83
+133 48
+60 12
+39 80
+6 120
+18 92
+186 36
+66 165
+9 175
+18 91
+65 159
+56 80
+1 120
+133 144
+114 7
+40 152
+10 64
+51 176
+33 132
+91 152
+157 130
+38 148
+88 102
+16 191
+14 129
+9 178
+9 33
+17 44
+13 115
+101 88
+153 196
+156 62
+83 120
+120 153
+173 123
+195 196
+43 5
+176 153
+60 188
+137 116
+194 13
+116 174
+78 51
+128 194
+107 119
+29 162
+192 190
+85 34
+75 106
+58 30
+80 144
+75 44
+180 38
+177 197
+19 32
+110 59
+131 154
+178 183
+81 74
+9 109
+92 118
+130 90
+11 104
+153 52
+198 157
+125 3
+168 151
+43 143
+164 5
+126 33
+99 83
+15 99
+71 162
+185 119
+147 187
+72 48
+147 76
+165 60
+2 39
+190 88
+40 187
+35 98
+83 162
+111 68
+60 24
+57 153
+159 166
+121 196
+34 23
+68 161
+128 107
+30 124
+24 135
+143 100
+184 94
+19 130
+52 53
+42 86
+180 21
+91 73
+4 30
+50 23
+82 96
+105 72
+110 62
+7 194
+98 76
+188 72
+43 83
+117 11
+102 2
+55 187
+66 121
+50 33
+50 166
+88 4
+102 61
+134 173
+69 182
+31 58
+165 189
+129 176
+149 128
+155 77
+197 180
+187 22
+118 20
+118 26
+80 141
+111 14
+193 70
+7 121
+39 8
+87 141
+42 29
+165 110
+137 60
+109 127
+100 66
+131 147
+60 11
+105 138
+17 195
+23 26
+68 104
+122 68
+43 93
+144 109
+164 35
+125 163
+146 167
+153 78
+97 68
+70 54
+153 89
+115 1
+45 133
+92 55
+48 19
+149 27
+63 148
+74 31
+90 83
+113 65
+41 65
+129 13
+125 152
+127 57
+59 127
+111 119
+114 142
+102 107
+20 61
+71 63
+133 106
+19 65
+98 81
+92 68
+25 14
+20 50
+73 97
+88 11
+148 110
+32 109
+39 146
+60 36
+30 97
+121 83
+48 98
+22 90
+150 11
+20 98
+10 111
+61 48
+115 107
+102 93
+64 148
+91 70
+10 71
+144 141
+42 99
+24 62
+39 20
+135 39
+1 68
+63 146
+44 48
+13 150
+108 137
+12 25
+93 65
+148 120
+74 127
+63 76
+32 104
+138 13
+118 123
+8 141
+60 127
+92 75
+105 30
+31 71
+127 29
+76 72
+82 65
+4 97
+7 126
+89 78
+5 39
+9 33
+164 197
+153 14
+157 92
+58 101
+60 45
+31 153
+116 9
+130 43
+64 66
+61 152
+33 126
+48 62
+37 139
+17 145
+52 25
+133 12
+38 96
+29 160
+92 70
+12 102
+73 53
+11 3
+47 70
+2 126
+106 163
+145 54
+53 3
+8 140
+101 35
+102 126
+118 115
+44 24
+151 95
+139 143
+120 111
+79 8
+57 113
+83 86
+118 140
+89 100
+105 87
+160 103
+148 135
+59 21
+107 93
+164 86
+160 156
+121 74
+109 154
+85 43
+38 9
+26 75
+48 69
+53 26
+89 142
+131 132
+21 51
+139 53
+31 122
+99 17
+1 22
+64 162
+69 27
+52 122
+128 106
+134 50
+74 106
+77 50
+2 57
+97 81
+119 37
+22 79
+65 67
+93 23
+81 38
+152 82
+141 126
+129 70
+139 128
+142 97
+20 83
+75 111
+63 161
+88 134
+154 55
+41 80
+73 117
+84 42
+43 121
+110 151
+153 49
+136 75
+151 38
+143 39
+104 111
+2 66
+73 83
+31 109
+11 58
+76 43
+141 131
+51 117
+20 15
+104 109
+37 27
+58 104
+70 88
+33 81
+37 151
+163 20
+33 88
+156 21
+71 136
+10 61
+152 54
+116 31
+107 96
+42 112
+57 18
+130 123
+24 27
+82 85
+21 90
+146 24
+85 14
+91 47
+126 95
+9 153
+145 9
+28 84
+103 58
+117 48
+20 124
+71 55
+95 22
+39 101
+128 79
+105 158
+34 134
+20 54
+109 92
+10 108
+131 20
+107 7
+20 98
+50 159
+8 157
+77 124
+164 89
+141 147
+13 31
+30 51
+32 57
+32 123
+9 111
+110 94
+7 130
+73 4
+23 95
+141 65
+96 35
+83 81
+46 116
+26 1
+150 53
+36 106
+50 21
+4 17
+34 12
+37 145
+77 132
+16 36
+124 64
+22 40
+15 105
+120 157
+5 51
+112 22
+139 43
+20 117
+40 104
+44 88
+159 5
+51 84
+52 155
+114 129
+80 127
+87 29
+135 6
+68 98
+91 57
+54 122
+55 115
+35 162
+13 157
+10 144
+108 73
+38 94
+199 101
+137 146
+109 75
+184 12
+140 186
+73 143
+143 154
+90 182
+104 28
+184 106
+43 30
+135 65
+22 119
+106 138
+67 196
+126 72
+143 196
+36 123
+175 94
+196 1
+169 79
+10 55
+43 54
+175 52
+84 86
+27 35
+105 192
+134 194
+95 106
+91 44
+70 120
+187 97
+102 29
+166 153
+128 81
+10 24
+134 174
+188 132
+166 36
+135 152
+119 106
+182 3
+14 12
+104 168
+25 48
+48 190
+148 155
+67 167
+55 84
+105 87
+186 199
+30 19
+96 64
+178 75
+149 150
+88 171
+9 79
+50 65
+119 99
+111 38
+113 168
+99 60
+140 20
+141 135
+175 69
+134 146
+108 180
+108 76
+130 42
+59 51
+173 24
+196 55
+32 157
+199 10
+192 120
+62 105
+8 123
+82 109
+36 18
+31 108
+183 119
+119 90
+70 14
+145 49
+192 161
+154 131
+32 33
+73 2
+80 191
+54 131
+147 114
+47 164
+38 134
+76 93
+34 101
+133 76
+6 62
+35 148
+123 96
+20 73
+116 40
+104 65
+118 168
+82 88
+63 106
+26 107
+13 30
+114 106
+16 71
+58 16
+65 43
+101 69
+86 17
+48 12
+117 39
+66 52
+66 48
+38 75
+118 108
+36 13
+43 17
+64 35
+89 8
+96 68
+115 34
+18 30
+24 88
+66 42
+72 111
+101 97
+52 46
+93 91
+83 8
+3 114
+77 5
+46 56
+30 56
+79 78
+56 107
+48 11
+65 12
+35 51
+69 25
+79 85
+55 34
+71 115
+11 97
+65 88
+31 26
+1 110
+13 7
+111 93
+56 50
+60 75
+76 83
+74 117
+82 45
+87 81
+37 8
+112 76
+116 68
+27 15
+14 93
+5 61
+62 115
+23 13
+55 35
+64 33
+94 99
+67 86
+66 32
+69 87
+106 93
+27 94
+18 84
+22 12
+109 100
+10 21
+102 47
+47 115
+62 104
+39 56
+55 46
+96 112
+70 93
+11 50
+82 19
+46 67
+44 57
+70 37
+84 15
+90 10
+78 89
+80 2
+71 52
+43 36
+84 99
+44 12
+7 3
+113 28
+38 44
+14 40
+4 21
+101 7
+12 30
+14 103
+109 21
+47 2
+50 43
+72 54
+52 27
+3 96
+62 43
+117 58
+44 87
+18 22
+25 10
+63 7
+61 106
+113 101
+44 96
+32 19
+20 16
+11 15
+45 60
+36 88
+89 25
+50 71
+57 88
+44 43
+54 87
+25 36
+96 43
+117 41
+73 30
+14 96
+65 88
+30 46
+92 101
+96 57
+99 115
+83 55
+14 79
+104 84
+97 102
+15 90
+25 99
+76 68
+89 96
+36 6
+41 31
+113 57
+12 51
+93 114
+74 59
+59 78
+87 84
+18 40
+116 60
+45 64
+98 39
+45 97
+54 79
+97 48
+42 14
+45 110
+33 49
+51 103
+58 13
+46 88
+93 38
+166 147
+9 161
+63 152
+97 143
+128 36
+139 138
+37 95
+162 68
+123 8
+139 118
+119 123
+157 109
+56 1
+162 108
+47 95
+76 159
+63 72
+114 52
+123 73
+97 123
+38 9
+94 36
+46 151
+68 64
+2 26
+96 22
+11 88
+124 7
+33 71
+145 97
+135 41
+8 123
+23 9
+26 13
+151 165
+67 83
+67 8
+2 23
+123 40
+7 89
+46 116
+142 88
+129 111
+16 127
+7 146
+66 59
+73 118
+66 128
+5 27
+23 106
+89 121
+138 49
+108 49
+35 4
+48 79
+114 9
+30 15
+130 127
+149 100
+25 9
+60 53
+48 39
+23 154
+63 18
+157 107
+60 151
+146 66
+98 34
+33 37
+101 104
+65 11
+46 111
+43 19
+118 140
+46 86
+66 43
+91 114
+22 146
+79 140
+67 59
+43 23
+133 160
+160 108
+59 47
+33 105
+53 75
+87 71
+114 107
+157 82
+38 148
+25 160
+49 151
+79 37
+160 45
+70 57
+70 114
+143 13
+78 139
+140 54
+89 86
+143 9
+149 95
+155 53
+157 7
+95 121
+61 71
+124 41
+102 145
+20 125
+108 155
+154 11
+21 30
+121 134
+70 83
+55 95
+16 44
+53 130
+89 1
+145 9
+137 102
+158 69
+137 48
+116 1
+82 60
+158 139
+118 161
+155 95
+128 53
+85 65
+160 76
+43 56
+21 98
+130 10
+144 82
+66 80
+6 151
+166 56
+18 114
+136 139
+166 90
+56 133
+83 66
+65 3
+21 114
+31 122
+141 104
+139 11
+113 127
+173 114
+104 30
+139 119
+134 158
+38 95
+61 67
+169 18
+50 71
+53 7
+3 90
+43 114
+89 86
+89 170
+54 148
+24 42
+117 107
+2 83
+81 64
+79 115
+170 142
+87 75
+31 97
+67 53
+86 61
+156 89
+80 7
+168 83
+69 14
+4 138
+113 83
+160 145
+166 63
+136 49
+47 71
+172 128
+38 172
+51 112
+133 172
+170 10
+90 131
+69 116
+53 149
+158 73
+12 145
+115 93
+25 34
+150 1
+148 82
+160 153
+77 26
+34 68
+64 17
+70 62
+18 13
+90 29
+119 46
+40 47
+85 78
+97 12
+116 72
+46 162
+97 4
+85 171
+150 130
+137 43
+6 48
+36 130
+147 136
+86 115
+72 33
+51 143
+9 41
+87 135
+24 35
+93 74
+114 129
+22 47
+19 30
+45 55
+134 46
+139 165
+74 7
+21 130
+127 59
+80 165
+82 158
+65 142
+129 93
+164 70
+28 79
+29 16
+25 146
+129 98
+102 19
+105 139
+117 54
+108 160
+47 18
+99 29
+38 102
+76 169
+151 154
+164 154
+1 110
+162 98
+150 114
+67 95
+31 114
+85 60
+99 52
+156 91
+127 132
+60 103
+25 141
+125 24
+120 131
+113 37
+99 52
+73 105
+78 12
+28 66
+18 32
+52 101
+104 58
+83 64
+59 97
+53 58
+58 48
+94 37
+69 88
+92 55
+68 9
+53 87
+13 98
+28 5
+12 69
+64 43
+111 18
+45 109
+75 34
+55 2
+33 4
+76 14
+69 74
+58 85
+49 46
+18 102
+61 117
+3 91
+106 79
+33 54
+55 72
+15 86
+59 78
+106 96
+52 111
+88 73
+120 86
+106 80
+1 57
+78 101
+6 120
+80 45
+17 18
+33 15
+35 43
+80 67
+14 108
+25 47
+68 105
+107 103
+36 57
+95 55
+14 44
+21 108
+79 17
+97 73
+14 37
+86 88
+71 4
+1 33
+40 28
+58 94
+75 27
+62 105
+68 49
+49 38
+75 31
+26 59
+91 66
+55 117
+100 15
+83 17
+95 103
+69 109
+25 31
+75 41
+41 97
+86 106
+84 98
+7 77
+65 24
+11 47
+81 20
+19 116
+105 103
+79 92
+91 50
+84 13
+106 93
+52 114
+61 26
+109 112
+61 44
+4 2
+26 39
+35 18
+11 35
+73 60
+5 69
+113 12
+95 33
+70 106
+107 32
+45 39
+110 99
+59 78
+12 79
+105 36
+78 57
+37 90
+29 57
+11 34
+68 49
+75 93
+49 119
+61 56
+84 56
+99 6
+99 26
+101 88
+13 57
+83 6
+77 38
+22 24
+26 75
+16 82
+181 19
+148 62
+49 69
+97 176
+33 181
+33 166
+132 164
+164 104
+98 140
+2 1
+3 123
+77 149
+179 5
+41 128
+157 57
+157 133
+8 54
+21 78
+30 90
+37 6
+194 29
+76 185
+180 140
+139 151
+138 86
+134 31
+91 160
+7 135
+154 31
+173 194
+6 94
+81 189
+9 120
+137 18
+175 25
+21 27
+118 93
+154 66
+11 121
+171 141
+33 49
+20 169
+157 16
+139 161
+36 147
+56 177
+36 44
+173 141
+121 85
+106 23
+114 75
+6 76
+104 94
+19 15
+57 28
+75 41
+29 14
+27 91
+43 92
+72 97
+17 28
+66 31
+97 64
+13 74
+64 59
+56 79
+92 24
+58 15
+34 36
+81 46
+74 77
+57 4
+89 51
+24 47
+101 74
+18 17
+31 51
+56 29
+84 17
+43 83
+20 5
+76 40
+48 29
+23 109
+14 89
+92 58
+112 54
+4 65
+80 42
+96 43
+14 56
+31 18
+29 69
+69 35
+31 28
+62 37
+57 10
+44 105
+41 21
+53 70
+45 72
+85 29
+58 55
+67 93
+76 55
+87 57
+27 3
+33 69
+17 81
+52 28
+54 80
+69 27
+106 54
+44 8
+108 111
+64 7
+35 58
+33 61
+94 24
+44 13
+45 55
+90 41
+82 57
+95 16
+33 8
+70 61
+103 172
+47 81
+21 17
+75 57
+85 40
+27 2
+24 43
+58 68
+103 41
+8 84
+48 78
+54 43
+40 98
+97 69
+66 33
+77 12
+79 92
+72 77
+100 78
+95 18
+54 19
+25 59
+70 99
+21 4
+7 38
+73 90
+55 39
+10 69
+6 88
+31 68
+49 45
+1 74
+1 15
+37 74
+28 73
+1 53
+51 17
+2 88
+24 1
+37 38
+81 10
+37 33
+71 28
+65 32
+95 42
+48 23
+27 92
+2 39
+66 47
+84 27
+74 92
+95 11
+17 18
+19 33
+80 32
+85 39
+32 28
+100 93
+52 25
+15 8
+76 85
+39 66
+37 56
+59 16
+26 18
+72 43
+30 5
+95 10
+4 53
+15 68
+89 56
+56 41
+9 84
+73 32
+65 2
+87 5
+54 58
+22 88
+50 90
+81 60
+43 81
+89 70
+90 93
+16 67
+37 96
+103 53
+84 21
+83 66
+42 15
+102 19
+21 32
+12 28
+31 18
+27 97
+30 63
+71 43
+14 90
+1 61
+1 62
+51 26
+82 1
+53 42
+46 33
+80 34
+27 80
+21 93
+3 57
+65 74
+70 57
+34 48
+6 16
+1 78
+15 43
+51 12
+76 85
+47 92
+74 19
+88 51
+53 41
+98 11
+24 26
+27 34
+67 23
+29 43
+9 27
+7 2
+73 6
+101 53
+102 64
+51 22
+15 62
+86 69
+38 94
+55 51
+11 85
+26 65
+63 48
+3 103
+29 23
+97 102
+40 98
+35 99
+96 20
+85 23
+84 21
+45 91
+70 12
+95 83
+54 40
+98 78
+40 10
+25 84
+52 34
+51 58
+79 16
+87 52
+32 63
+59 13
+9 18
+14 88
+62 92
+28 59
+47 25
+88 73
+86 83
+99 56
+2 25
+36 31
+63 101
+103 99
+89 83
+52 71
+15 94
+147 7
+69 43
+55 22
+101 23
+69 114
+29 62
+67 55
+71 117
+130 7
+17 76
+40 111
+45 23
+13 130
+5 87
+96 52
+124 13
+164 41
+68 41
+119 67
+163 161
+61 164
+67 77
+118 113
+35 95
+32 26
+14 19
+132 112
+12 50
+118 138
+10 57
+130 160
+88 17
+111 44
+41 84
+140 30
+7 53
+112 140
+24 74
+82 86
+32 137
+65 152
+91 52
+148 126
+153 145
+154 22
+72 90
+103 12
+67 138
+130 30
+97 152
+114 126
+115 104
+162 159
+129 37
+10 7
+38 50
+123 106
+43 21
\ No newline at end of file
diff --git a/hackerrank/01_robots/tests/output01.txt b/hackerrank/01_robots/tests/output01.txt
new file mode 100644
index 0000000..16ea43e
--- /dev/null
+++ b/hackerrank/01_robots/tests/output01.txt
@@ -0,0 +1,50 @@
+50
+31
+8
+17
+40
+21
+1
+40
+32
+49
+17
+4
+5
+19
+23
+11
+10
+14
+14
+21
+5
+13
+16
+59
+34
+20
+30
+38
+13
+16
+9
+7
+3
+26
+21
+10
+57
+18
+3
+38
+46
+21
+7
+7
+14
+11
+9
+3
+11
+8
\ No newline at end of file
diff --git a/hackerrank/01_robots/tests/output03.txt b/hackerrank/01_robots/tests/output03.txt
new file mode 100644
index 0000000..7f2e4c4
--- /dev/null
+++ b/hackerrank/01_robots/tests/output03.txt
@@ -0,0 +1,50 @@
+8615
+1580
+7202
+16936
+11790
+6264
+2661
+13847
+6548
+13791
+9411
+7179
+6908
+17227
+11828
+8714
+5161
+8925
+5893
+15143
+59
+1890
+14970
+12273
+2329
+3502
+1584
+3276
+202
+11847
+5847
+15370
+8546
+6655
+7100
+20590
+6057
+17335
+10288
+9753
+13256
+9882
+7805
+2040
+3115
+4000
+9707
+359
+633
+2976
\ No newline at end of file
diff --git a/hackerrank/01_robots/tmp.txt b/hackerrank/01_robots/tmp.txt
new file mode 100644
index 0000000..b40e57c
--- /dev/null
+++ b/hackerrank/01_robots/tmp.txt
@@ -0,0 +1,9 @@
+5 10 1 5 5
+10 2 1 2 7
+9 10 1 2 9
+3 6 2 3 3
+6 9 2 3 6
+2 9 2 14 20
+2 8 2 13 33
+6 5 2 3 34
+34+9=
\ No newline at end of file
diff --git a/hackerrank/02_coins/coins_test.rb b/hackerrank/02_coins/coins_test.rb
new file mode 100644
index 0000000..0f050f8
--- /dev/null
+++ b/hackerrank/02_coins/coins_test.rb
@@ -0,0 +1,29 @@
+require 'test/unit'
+require 'benchmark'
+
+require './hackerrank/02_coins/main'
+
+class TestThis < Test::Unit::TestCase
+
+ def read_results(num, path)
+ results = []
+ File.open(path, 'r') do |f|
+ num.times do
+ results << f.gets.to_i
+ end
+ end
+ results
+ end
+
+ def run_test_name(test_name)
+ File.open("./hackerrank/02_coins/tests/input#{test_name}.txt", 'r') do |f|
+ n, c = read_input(f)
+ puts cnt(n, c, c.size)
+ end
+ end
+
+ def test_stuff
+ run_test_name('01')
+ end
+
+end
diff --git a/hackerrank/02_coins/main.rb b/hackerrank/02_coins/main.rb
new file mode 100644
index 0000000..2885205
--- /dev/null
+++ b/hackerrank/02_coins/main.rb
@@ -0,0 +1,36 @@
+#!/bin/ruby
+
+def cnt(n, c, m)
+ store = Array.new(n+1) do
+ Array.new(m+1) do
+ -1
+ end
+ end
+ ways(store, n, c, m)
+end
+
+def ways(store, n, c, m)
+ if n == 0
+ return 1
+ elsif n < 0
+ return 0
+ elsif m <= 0
+ return 0
+ elsif store[n][m] == -1
+ store[n][m] = ways(store, n, c, m-1) + ways(store,n - c[m-1], c, m)
+ end
+ store[n][m]
+end
+
+def read_input(stream)
+ n = stream.gets.strip.split(' ')[0].to_i
+ c = stream.gets.strip.split(' ').map(&:to_i)
+# Print the number of ways of making change for 'n' units
+# using coins having the values given by 'c'
+ return n, c
+end
+
+def main
+ n, c = read_input(STDIN)
+ puts cnt(n, c, c.size)
+end
diff --git a/hackerrank/02_coins/tests/input01.txt b/hackerrank/02_coins/tests/input01.txt
new file mode 100644
index 0000000..71a0164
--- /dev/null
+++ b/hackerrank/02_coins/tests/input01.txt
@@ -0,0 +1,2 @@
+4 3
+1 2 3
diff --git a/hackerrank/02_coins/think.txt b/hackerrank/02_coins/think.txt
new file mode 100644
index 0000000..a8ea38e
--- /dev/null
+++ b/hackerrank/02_coins/think.txt
@@ -0,0 +1,27 @@
+n, m-1 + n-C[m-1], m
+
+n m C
+1 1 2
+
+n m C
+1 0 2
+-> 0
+
+n m C
+-1 1 2
+-> 0
+
+--------------
+n m C
+1 1 1
+
+n m C
+1 1 1
+
+n m C
+1 0 1
+-> 0
+
+n m C
+0 1 1
+-> 1
|
honzasterba/minis
|
8bdd12ce447eda2a6f1793eb4e4f75f788320de5
|
amazon interview
|
diff --git a/amzn_test/excercie_2_test.rb b/amzn_test/excercie_2_test.rb
new file mode 100644
index 0000000..c1766d2
--- /dev/null
+++ b/amzn_test/excercie_2_test.rb
@@ -0,0 +1,40 @@
+require "./amzn_test/excercise_2_submited"
+require 'test/unit'
+
+class TestThis < Test::Unit::TestCase
+
+ def test_build
+ assert_equal Node.new(1), build_tree([1])
+ assert_equal Node.new(1, Node.new(2, Node.new(3))),
+ build_tree([1, 2, 3])
+ assert_equal Node.new(3, nil, Node.new(2, nil,Node.new(1))),
+ build_tree([3, 2, 1])
+ assert_equal Node.new(10,
+ nil,
+ Node.new(5,
+ Node.new(7),
+ Node.new(3))
+ ),
+ build_tree([10, 5, 3, 7])
+ end
+
+ def test_distance
+ assert_equal 3, bstDistance([5,6,3,1,2,4], 6,2,4)
+ assert_equal 2, bstDistance([5,6,3,1,2,4], 6,6,3)
+ assert_equal 1, bstDistance([5,6,3,1,2,4], 6,5,3)
+ assert_equal 4, bstDistance([5,6,3,1,2,4], 6,6,2)
+ assert_equal 1, bstDistance([5,6,3,1,2,4], 6,1,2)
+ assert_equal 2, bstDistance([5,6,3,1,2,4], 6,1,4)
+
+ assert_equal 5, bstDistance([1,2,3,4,5,6], 6,1,6)
+ assert_equal 5, bstDistance([1,2,3,4,5,6], 6,6,1)
+ end
+
+ def test_find_in_subtree
+ tree = build_tree([5,6,3,1,2,4])
+ assert_equal 0, find_in_subtree(tree, 5)
+ assert_equal 1, find_in_subtree(tree, 3)
+ assert_equal 3, find_in_subtree(tree, 2)
+ end
+
+end
\ No newline at end of file
diff --git a/amzn_test/excercise_1.rb b/amzn_test/excercise_1.rb
new file mode 100644
index 0000000..c094a43
--- /dev/null
+++ b/amzn_test/excercise_1.rb
@@ -0,0 +1,55 @@
+ANYTHING = "anything"
+
+def checkWinner(codeList, shoppingCart)
+ codeList.inject(shoppingCart) do |cart, current|
+ cart = cart_matches(current, cart)
+ unless cart
+ return 0
+ end
+ cart
+ end
+ return 1
+end
+
+def cart_matches(code_list, cart)
+ return false if cart.length < code_list.length
+ (cart.length - code_list.length + 1).times do |start_index|
+ if lists_match(code_list, cart[start_index..(start_index+code_list.length-1)])
+ return cart[(start_index+code_list.length)..(cart.length-1)]
+ end
+ end
+ return false
+end
+
+def lists_match(code_list, cart)
+ code_list.length.times do |item_index|
+ if code_list[item_index] != ANYTHING && code_list[item_index] != cart[item_index]
+ return false
+ end
+ end
+ return true
+end
+
+require 'test/unit'
+
+class TestThis < Test::Unit::TestCase
+
+ def test_list_match
+ assert lists_match(%w{a b c}, %w{a b c})
+ assert lists_match(%w{a}, %w{a})
+ assert lists_match(%w{anything}, %w{a})
+ assert lists_match(%w{anything anything anything}, %w{a b c})
+ assert lists_match(%w{anything b anything}, %w{a b c})
+ assert !lists_match(%w{anything b anything}, %w{a x c})
+ end
+
+ def test_cart_matches
+ assert_equal %w{b c d}, cart_matches(%w{a}, %w{a b c d})
+ assert_equal %w{c d}, cart_matches(%w{a b}, %w{a b c d})
+ assert_equal %w{d}, cart_matches(%w{a b c}, %w{a b c d})
+ assert_equal %w{}, cart_matches(%w{a b c d}, %w{a b c d})
+ assert_equal %w{}, cart_matches(%w{b c d}, %w{a b c d})
+ assert_equal %w{}, cart_matches(%w{c d}, %w{a b c d})
+ assert_equal %w{}, cart_matches(%w{d}, %w{a b c d})
+ end
+end
\ No newline at end of file
diff --git a/amzn_test/excercise_2.rb b/amzn_test/excercise_2.rb
new file mode 100644
index 0000000..8d848c4
--- /dev/null
+++ b/amzn_test/excercise_2.rb
@@ -0,0 +1,86 @@
+class Node
+ attr_accessor :value, :left, :right
+
+ def initialize(value, left = nil, right = nil)
+ @value = value
+ @left = left
+ @right = right
+ end
+
+ def ==(node)
+ node.is_a?(Node) &&
+ node.value == @value && node.left == @left && node.right == @right
+ end
+
+ def to_s
+ "(#{left.to_s},#{value},#{right.to_s})"
+ end
+
+end
+
+def bstDistance(values, n, node1, node2)
+ root = build_tree(values)
+ find_distance(root, node1, node2)
+end
+
+def find_distance(tree, node1, node2)
+ return nil unless tree
+ if node1 > tree.value && node2 > tree.value
+ find_distance(tree.left, node1, node2)
+ elsif node1 < tree.value && node2 < tree.value
+ find_distance(tree.right, node1, node2)
+ elsif node1 == tree.value
+ find_in_subtree(tree, node2)
+ elsif node2 == tree.value
+ find_in_subtree(tree, node1)
+ else
+ depth1 = find_in_subtree(tree, node1)
+ depth2 = find_in_subtree(tree, node2)
+ if depth1 > 0 && depth2 > 0
+ depth1 + depth2
+ else
+ -1
+ end
+ end
+end
+
+def find_in_subtree(tree, value)
+ return -1 unless tree
+ current = tree
+ depth = 0
+ while current
+ return depth if value == current.value
+ depth += 1
+ if value > current.value
+ current = current.left
+ else
+ current = current.right
+ end
+ end
+ return -1
+end
+
+def build_tree(values)
+ root = Node.new(values[0])
+ return root if values.length == 1
+ values[1..(values.length-1)].each do |value|
+ append_to_tree(root, value)
+ end
+ root
+end
+
+def append_to_tree(root, value)
+ if value > root.value
+ if root.left.nil?
+ root.left = Node.new(value)
+ else
+ append_to_tree(root.left, value)
+ end
+ else
+ if root.right.nil?
+ root.right = Node.new(value)
+ else
+ append_to_tree(root.right, value)
+ end
+ end
+end
diff --git a/amzn_test/excercise_2_submited.rb b/amzn_test/excercise_2_submited.rb
new file mode 100644
index 0000000..9070e05
--- /dev/null
+++ b/amzn_test/excercise_2_submited.rb
@@ -0,0 +1,104 @@
+class Node
+ attr_accessor :value, :left, :right
+
+ def initialize(value, left = nil, right = nil)
+ @value = value
+ @left = left
+ @right = right
+ end
+
+ def ==(node)
+ node.is_a?(Node) &&
+ node.value == @value && node.left == @left && node.right == @right
+ end
+
+ def to_s
+ "(#{left.to_s},#{value},#{right.to_s})"
+ end
+
+end
+
+def bstDistance(values, n, node1, node2)
+ root = build_tree(values)
+ find_distance(root, node1, node2)
+end
+
+def find_distance(tree, node1, node2)
+ return nil unless tree
+ if node1 > tree.value && node2 > tree.value
+ find_distance(tree.left, node1, node2)
+ elsif node1 < tree.value && node2 < tree.value
+ find_distance(tree.right, node1, node2)
+ elsif node1 == tree.value
+ if node2 > tree.value
+ find_in_subtree(tree.left, node2)
+ else
+ find_in_subtree(tree.right, node2)
+ end
+ elsif node2 == tree.value
+ if node1 > tree.value
+ find_in_subtree(tree.left, node1)
+ else
+ find_in_subtree(tree.right, node1)
+ end
+ elsif node1 > tree.value
+ depth1 = find_in_subtree(tree.right, node2)
+ depth2 = find_in_subtree(tree.left, node1)
+ if depth1 && depth2
+ 2 + depth1 + depth2
+ else
+ -1
+ end
+ else
+ depth1 = find_in_subtree(tree.right, node1)
+ depth2 = find_in_subtree(tree.left, node2)
+ if depth1 >= 0 && depth2 >= 0
+ 2 + depth1 + depth2
+ else
+ -1
+ end
+ end
+end
+
+def find_in_subtree(tree, value)
+ return -1 unless tree
+ current = tree
+ depth = 0
+ while current
+ return depth if value == current.value
+ depth += 1
+ if value > current.value
+ current = current.left
+ else
+ current = current.right
+ end
+ end
+ return -1
+end
+
+def build_tree(values)
+ root = Node.new(values[0])
+ return root if values.length == 1
+ rest = values[1..values.length-1]
+ return root unless rest
+ rest.each do |value|
+ append_to_tree(root, value)
+ end
+ root
+end
+
+def append_to_tree(root, value)
+ if value > root.value
+ if root.left.nil?
+ root.left = Node.new(value)
+ else
+ append_to_tree(root.left, value)
+ end
+ else
+ if root.right.nil?
+ root.right = Node.new(value)
+ else
+ append_to_tree(root.right, value)
+ end
+ end
+end
|
honzasterba/minis
|
191ce7d19b82ac9f14ed10d54985802558f0acb3
|
jurka.fr index
|
diff --git a/jurka.fr/index.html b/jurka.fr/index.html
new file mode 100644
index 0000000..6bff128
--- /dev/null
+++ b/jurka.fr/index.html
@@ -0,0 +1,59 @@
+<html>
+
+<head>
+ <title>jurka.fr</title>
+
+ <style>
+ div, body {
+ font-family: "Lucida Grande", "Lucida Sans", Helvetica, Arial, sans-serif;
+ font-weight: bolder;
+ margin: 0;
+ padding: 0;
+ }
+ #helena {
+ float: left;
+ width: 50%;
+ height: 50%;
+ color: #FFEBA9;
+ background-color: #AC5893;
+ }
+ #mira {
+ float: left;
+ width: 50%;
+ height: 50%;
+ color: #C985B4;
+ background-color: #FFEBA9;
+ }
+ #jurka {
+ float: left;
+ width: 100%;
+ height: 50%;
+ color: #135B58;
+ background-color: #A9D0CF;
+ }
+ .inner {
+ font-size: 100px;
+ text-align: center;
+ position: relative;
+ top: 30%;
+ }
+ </style>
+</head>
+
+ <div id="helena">
+ <div class="inner">
+ Helena
+ </div>
+ </div>
+ <div id="mira">
+ <div class="inner">
+ Mira
+ </div>
+ </div>
+ <div id="jurka">
+ <div class="inner">
+ jurka.fr
+ </div>
+ </div>
+
+</html>
\ No newline at end of file
|
honzasterba/minis
|
19a5baed2a99a42e4053f73a618bdbd8903c9e54
|
ignore
|
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..adf2047
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.DS_Store
+.metadata
|
honzasterba/minis
|
dcf102c9e1e748f9d59469499dc91f1d6d980f97
|
archiving ebook filename fixing utility
|
diff --git a/ebook_filename_fix/data.txt b/ebook_filename_fix/data.txt
new file mode 100644
index 0000000..db4c50d
--- /dev/null
+++ b/ebook_filename_fix/data.txt
@@ -0,0 +1,37 @@
+---
+"%FA": u
+"%D5": n
+"%B3": R
+"%83": c
+"%A3": t
+"%F8": S
+"%FB": n
+"%EA": l
+"%DA": A
+"%B5": S
+"%CA": D
+"%EC": y
+"%E9": e
+"%FD": y
+"%BA": z
+"%C8": v
+"%ED": i
+"%FE": s
+"%CC": E
+"%C9": Y
+"%AA": Z
+"%E0": u
+"%DD": Y
+"%CD": I
+"%EF": a
+"%BC": C
+"%E1": a
+"%E2": e
+"%C0": E
+"%F3": o
+"%C1": A
+"%CF": e
+"%A0": a
+"%E4": e
+"%F6": a
+"%B2": r
diff --git a/ebook_filename_fix/fix.rb b/ebook_filename_fix/fix.rb
new file mode 100755
index 0000000..a4f7913
--- /dev/null
+++ b/ebook_filename_fix/fix.rb
@@ -0,0 +1,107 @@
+#!/usr/bin/ruby
+
+require "rubygems"
+require "stringex"
+require "YAML"
+
+TRANS = {}
+RE = /(%[a-f0-9]{2})/i
+
+Translation = Struct.new(:name, :value, :files)
+class Translation
+ def files_translated
+ files.collect { |f| translate(f) }
+ end
+ def print_files(m = "_translated")
+ send("files" + m).each do |f|
+ puts "- #{f}"
+ end
+ end
+end
+
+files = `find . | grep "%"`.split("\n")
+
+def trans(str)
+ return TRANS[str] if TRANS[str]
+ TRANS[str] = Translation.new(str, nil, [])
+ return TRANS[str]
+end
+
+def translate(f)
+ f.gsub(RE) do |m|
+ t = trans(m.to_s)
+ if t.value
+ t.value
+ else
+ m
+ end
+ end
+end
+
+def untranslated
+ have = true
+ while have
+ have = false
+ todo = TRANS.select { |k, t| t.value.nil? }
+ have = todo.any?
+ todo.each { |k,v| yield v }
+ end
+end
+
+def save
+ res = {}
+ TRANS.each do |n, t|
+ if t.value
+ res[n] = t.value
+ end
+ end
+ File.open "data.txt", "w" do |f|
+ YAML::dump(res, f)
+ end
+end
+
+def load
+ data = {}
+ File.open "data.txt", "r" do |f|
+ data = YAML::load(f)
+ end
+ return if !data
+ data.each do |k, v|
+ trans(k).value = v
+ end
+end
+
+files.each do |f|
+ m = f.match RE
+ break if !m
+ i = 0
+ while i < m.size
+ t = trans(m[i])
+ t.files << f
+ i += 1
+ end
+end
+
+load
+untranslated do |t|
+ puts "Translate [#{t.name}] (#{t.files.size} files)"
+ t.print_files
+ a = gets.strip
+ if a == "" || a == "x"
+ puts "Skip for now"
+ else
+ puts "Translated #{t.name} to #{a}"
+ t.value = a
+ t.print_files
+ gets
+ save
+ end
+end
+
+puts "Everything translated!"
+
+files.each do |f|
+ cmd = "mv -v \"#{f}\" \"#{translate(f)}\""
+ puts cmd
+ `#{cmd}`
+end
|
honzasterba/minis
|
9ddef98ac466a0dab29e1292346daf67e715760c
|
archiving restacoef
|
diff --git a/RestaCoef/.DS_Store b/RestaCoef/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/RestaCoef/.DS_Store differ
diff --git a/RestaCoef/build.xml b/RestaCoef/build.xml
new file mode 100644
index 0000000..41a1719
--- /dev/null
+++ b/RestaCoef/build.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
+<!-- (If you delete it and reopen the project it will be recreated.) -->
+<!-- By default, only the Clean and Build commands use this build script. -->
+<!-- Commands such as Run, Debug, and Test only use this build script if -->
+<!-- the Compile on Save feature is turned off for the project. -->
+<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
+<!-- in the project's Project Properties dialog box.-->
+<project name="RestaCoef" default="default" basedir=".">
+ <description>Builds, tests, and runs the project RestaCoef.</description>
+ <import file="nbproject/build-impl.xml"/>
+ <!--
+
+ There exist several targets which are by default empty and which can be
+ used for execution of your tasks. These targets are usually executed
+ before and after some main targets. They are:
+
+ -pre-init: called before initialization of project properties
+ -post-init: called after initialization of project properties
+ -pre-compile: called before javac compilation
+ -post-compile: called after javac compilation
+ -pre-compile-single: called before javac compilation of single file
+ -post-compile-single: called after javac compilation of single file
+ -pre-compile-test: called before javac compilation of JUnit tests
+ -post-compile-test: called after javac compilation of JUnit tests
+ -pre-compile-test-single: called before javac compilation of single JUnit test
+ -post-compile-test-single: called after javac compilation of single JUunit test
+ -pre-jar: called before JAR building
+ -post-jar: called after JAR building
+ -post-clean: called after cleaning build products
+
+ (Targets beginning with '-' are not intended to be called on their own.)
+
+ Example of inserting an obfuscator after compilation could look like this:
+
+ <target name="-post-compile">
+ <obfuscate>
+ <fileset dir="${build.classes.dir}"/>
+ </obfuscate>
+ </target>
+
+ For list of available properties check the imported
+ nbproject/build-impl.xml file.
+
+
+ Another way to customize the build is by overriding existing main targets.
+ The targets of interest are:
+
+ -init-macrodef-javac: defines macro for javac compilation
+ -init-macrodef-junit: defines macro for junit execution
+ -init-macrodef-debug: defines macro for class debugging
+ -init-macrodef-java: defines macro for class execution
+ -do-jar-with-manifest: JAR building (if you are using a manifest)
+ -do-jar-without-manifest: JAR building (if you are not using a manifest)
+ run: execution of project
+ -javadoc-build: Javadoc generation
+ test-report: JUnit report generation
+
+ An example of overriding the target for project execution could look like this:
+
+ <target name="run" depends="RestaCoef-impl.jar">
+ <exec dir="bin" executable="launcher.exe">
+ <arg file="${dist.jar}"/>
+ </exec>
+ </target>
+
+ Notice that the overridden target depends on the jar target and not only on
+ the compile target as the regular run target does. Again, for a list of available
+ properties which you can use, check the target you are overriding in the
+ nbproject/build-impl.xml file.
+
+ -->
+</project>
diff --git a/RestaCoef/dist/.DS_Store b/RestaCoef/dist/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/RestaCoef/dist/.DS_Store differ
diff --git a/RestaCoef/lib/DBF_JDBC30.jar b/RestaCoef/lib/DBF_JDBC30.jar
new file mode 100755
index 0000000..082bc27
Binary files /dev/null and b/RestaCoef/lib/DBF_JDBC30.jar differ
diff --git a/RestaCoef/manifest.mf b/RestaCoef/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/RestaCoef/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/RestaCoef/nbproject/.DS_Store b/RestaCoef/nbproject/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/RestaCoef/nbproject/.DS_Store differ
diff --git a/RestaCoef/nbproject/build-impl.xml b/RestaCoef/nbproject/build-impl.xml
new file mode 100644
index 0000000..f6f66b8
--- /dev/null
+++ b/RestaCoef/nbproject/build-impl.xml
@@ -0,0 +1,805 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT ***
+*** EDIT ../build.xml INSTEAD ***
+
+For the purpose of easier reading the script
+is divided into following sections:
+
+ - initialization
+ - compilation
+ - jar
+ - execution
+ - debugging
+ - javadoc
+ - junit compilation
+ - junit execution
+ - junit debugging
+ - applet
+ - cleanup
+
+ -->
+<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="RestaCoef-impl">
+ <fail message="Please build using Ant 1.7.1 or higher.">
+ <condition>
+ <not>
+ <antversion atleast="1.7.1"/>
+ </not>
+ </condition>
+ </fail>
+ <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
+ <!--
+ ======================
+ INITIALIZATION SECTION
+ ======================
+ -->
+ <target name="-pre-init">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="-pre-init" name="-init-private">
+ <property file="nbproject/private/config.properties"/>
+ <property file="nbproject/private/configs/${config}.properties"/>
+ <property file="nbproject/private/private.properties"/>
+ </target>
+ <target depends="-pre-init,-init-private" name="-init-user">
+ <property file="${user.properties.file}"/>
+ <!-- The two properties below are usually overridden -->
+ <!-- by the active platform. Just a fallback. -->
+ <property name="default.javac.source" value="1.4"/>
+ <property name="default.javac.target" value="1.4"/>
+ </target>
+ <target depends="-pre-init,-init-private,-init-user" name="-init-project">
+ <property file="nbproject/configs/${config}.properties"/>
+ <property file="nbproject/project.properties"/>
+ </target>
+ <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
+ <available file="${manifest.file}" property="manifest.available"/>
+ <condition property="main.class.available">
+ <and>
+ <isset property="main.class"/>
+ <not>
+ <equals arg1="${main.class}" arg2="" trim="true"/>
+ </not>
+ </and>
+ </condition>
+ <condition property="manifest.available+main.class">
+ <and>
+ <isset property="manifest.available"/>
+ <isset property="main.class.available"/>
+ </and>
+ </condition>
+ <condition property="do.mkdist">
+ <and>
+ <isset property="libs.CopyLibs.classpath"/>
+ <not>
+ <istrue value="${mkdist.disabled}"/>
+ </not>
+ </and>
+ </condition>
+ <condition property="manifest.available+main.class+mkdist.available">
+ <and>
+ <istrue value="${manifest.available+main.class}"/>
+ <isset property="do.mkdist"/>
+ </and>
+ </condition>
+ <condition property="manifest.available+mkdist.available">
+ <and>
+ <istrue value="${manifest.available}"/>
+ <isset property="do.mkdist"/>
+ </and>
+ </condition>
+ <condition property="manifest.available-mkdist.available">
+ <or>
+ <istrue value="${manifest.available}"/>
+ <isset property="do.mkdist"/>
+ </or>
+ </condition>
+ <condition property="manifest.available+main.class-mkdist.available">
+ <or>
+ <istrue value="${manifest.available+main.class}"/>
+ <isset property="do.mkdist"/>
+ </or>
+ </condition>
+ <condition property="have.tests">
+ <or>
+ <available file="${test.src.dir}"/>
+ </or>
+ </condition>
+ <condition property="have.sources">
+ <or>
+ <available file="${src.dir}"/>
+ </or>
+ </condition>
+ <condition property="netbeans.home+have.tests">
+ <and>
+ <isset property="netbeans.home"/>
+ <isset property="have.tests"/>
+ </and>
+ </condition>
+ <condition property="no.javadoc.preview">
+ <and>
+ <isset property="javadoc.preview"/>
+ <isfalse value="${javadoc.preview}"/>
+ </and>
+ </condition>
+ <property name="run.jvmargs" value=""/>
+ <property name="javac.compilerargs" value=""/>
+ <property name="work.dir" value="${basedir}"/>
+ <condition property="no.deps">
+ <and>
+ <istrue value="${no.dependencies}"/>
+ </and>
+ </condition>
+ <property name="javac.debug" value="true"/>
+ <property name="javadoc.preview" value="true"/>
+ <property name="application.args" value=""/>
+ <property name="source.encoding" value="${file.encoding}"/>
+ <property name="runtime.encoding" value="${source.encoding}"/>
+ <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
+ <and>
+ <isset property="javadoc.encoding"/>
+ <not>
+ <equals arg1="${javadoc.encoding}" arg2=""/>
+ </not>
+ </and>
+ </condition>
+ <property name="javadoc.encoding.used" value="${source.encoding}"/>
+ <property name="includes" value="**"/>
+ <property name="excludes" value=""/>
+ <property name="do.depend" value="false"/>
+ <condition property="do.depend.true">
+ <istrue value="${do.depend}"/>
+ </condition>
+ <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
+ <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
+ <length length="0" string="${endorsed.classpath}" when="greater"/>
+ </condition>
+ <property name="javac.fork" value="false"/>
+ </target>
+ <target name="-post-init">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
+ <fail unless="src.dir">Must set src.dir</fail>
+ <fail unless="test.src.dir">Must set test.src.dir</fail>
+ <fail unless="build.dir">Must set build.dir</fail>
+ <fail unless="dist.dir">Must set dist.dir</fail>
+ <fail unless="build.classes.dir">Must set build.classes.dir</fail>
+ <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
+ <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
+ <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
+ <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
+ <fail unless="dist.jar">Must set dist.jar</fail>
+ </target>
+ <target name="-init-macrodef-property">
+ <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute name="name"/>
+ <attribute name="value"/>
+ <sequential>
+ <property name="@{name}" value="${@{value}}"/>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-javac">
+ <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
+ <attribute default="${src.dir}" name="srcdir"/>
+ <attribute default="${build.classes.dir}" name="destdir"/>
+ <attribute default="${javac.classpath}" name="classpath"/>
+ <attribute default="${includes}" name="includes"/>
+ <attribute default="${excludes}" name="excludes"/>
+ <attribute default="${javac.debug}" name="debug"/>
+ <attribute default="${empty.dir}" name="sourcepath"/>
+ <attribute default="${empty.dir}" name="gensrcdir"/>
+ <element name="customize" optional="true"/>
+ <sequential>
+ <property location="${build.dir}/empty" name="empty.dir"/>
+ <mkdir dir="${empty.dir}"/>
+ <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
+ <src>
+ <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+ <include name="*"/>
+ </dirset>
+ </src>
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+ <compilerarg line="${javac.compilerargs}"/>
+ <customize/>
+ </javac>
+ </sequential>
+ </macrodef>
+ <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
+ <attribute default="${src.dir}" name="srcdir"/>
+ <attribute default="${build.classes.dir}" name="destdir"/>
+ <attribute default="${javac.classpath}" name="classpath"/>
+ <sequential>
+ <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ </depend>
+ </sequential>
+ </macrodef>
+ <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
+ <attribute default="${build.classes.dir}" name="destdir"/>
+ <sequential>
+ <fail unless="javac.includes">Must set javac.includes</fail>
+ <pathconvert pathsep="," property="javac.includes.binary">
+ <path>
+ <filelist dir="@{destdir}" files="${javac.includes}"/>
+ </path>
+ <globmapper from="*.java" to="*.class"/>
+ </pathconvert>
+ <delete>
+ <files includes="${javac.includes.binary}"/>
+ </delete>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-junit">
+ <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
+ <attribute default="${includes}" name="includes"/>
+ <attribute default="${excludes}" name="excludes"/>
+ <attribute default="**" name="testincludes"/>
+ <sequential>
+ <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
+ <batchtest todir="${build.test.results.dir}">
+ <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+ <filename name="@{testincludes}"/>
+ </fileset>
+ </batchtest>
+ <classpath>
+ <path path="${run.test.classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="test-sys-prop."/>
+ <mapper from="test-sys-prop.*" to="*" type="glob"/>
+ </syspropertyset>
+ <formatter type="brief" usefile="false"/>
+ <formatter type="xml"/>
+ <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+ <jvmarg line="${run.jvmargs}"/>
+ </junit>
+ </sequential>
+ </macrodef>
+ </target>
+ <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
+ <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute default="${main.class}" name="name"/>
+ <attribute default="${debug.classpath}" name="classpath"/>
+ <attribute default="" name="stopclassname"/>
+ <sequential>
+ <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ </nbjpdastart>
+ </sequential>
+ </macrodef>
+ <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute default="${build.classes.dir}" name="dir"/>
+ <sequential>
+ <nbjpdareload>
+ <fileset dir="@{dir}" includes="${fix.classes}">
+ <include name="${fix.includes}*.class"/>
+ </fileset>
+ </nbjpdareload>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-debug-args">
+ <property name="version-output" value="java version "${ant.java.version}"/>
+ <condition property="have-jdk-older-than-1.4">
+ <or>
+ <contains string="${version-output}" substring="java version "1.0"/>
+ <contains string="${version-output}" substring="java version "1.1"/>
+ <contains string="${version-output}" substring="java version "1.2"/>
+ <contains string="${version-output}" substring="java version "1.3"/>
+ </or>
+ </condition>
+ <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
+ <istrue value="${have-jdk-older-than-1.4}"/>
+ </condition>
+ <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
+ <os family="windows"/>
+ </condition>
+ <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
+ <isset property="debug.transport"/>
+ </condition>
+ </target>
+ <target depends="-init-debug-args" name="-init-macrodef-debug">
+ <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+ <attribute default="${main.class}" name="classname"/>
+ <attribute default="${debug.classpath}" name="classpath"/>
+ <element name="customize" optional="true"/>
+ <sequential>
+ <java classname="@{classname}" dir="${work.dir}" fork="true">
+ <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+ <jvmarg line="${debug-args-line}"/>
+ <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+ <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
+ <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
+ <jvmarg line="${run.jvmargs}"/>
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="run-sys-prop."/>
+ <mapper from="run-sys-prop.*" to="*" type="glob"/>
+ </syspropertyset>
+ <customize/>
+ </java>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-java">
+ <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute default="${main.class}" name="classname"/>
+ <attribute default="${run.classpath}" name="classpath"/>
+ <element name="customize" optional="true"/>
+ <sequential>
+ <java classname="@{classname}" dir="${work.dir}" fork="true">
+ <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+ <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
+ <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
+ <jvmarg line="${run.jvmargs}"/>
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="run-sys-prop."/>
+ <mapper from="run-sys-prop.*" to="*" type="glob"/>
+ </syspropertyset>
+ <customize/>
+ </java>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-presetdef-jar">
+ <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <jar compress="${jar.compress}" jarfile="${dist.jar}">
+ <j2seproject1:fileset dir="${build.classes.dir}"/>
+ </jar>
+ </presetdef>
+ </target>
+ <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
+ <!--
+ ===================
+ COMPILATION SECTION
+ ===================
+ -->
+ <target name="-deps-jar-init" unless="built-jar.properties">
+ <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
+ <delete file="${built-jar.properties}" quiet="true"/>
+ </target>
+ <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
+ <echo level="warn" message="Cycle detected: RestaCoef was already built"/>
+ </target>
+ <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
+ <mkdir dir="${build.dir}"/>
+ <touch file="${built-jar.properties}" verbose="false"/>
+ <property file="${built-jar.properties}" prefix="already.built.jar."/>
+ <antcall target="-warn-already-built-jar"/>
+ <propertyfile file="${built-jar.properties}">
+ <entry key="${basedir}" value=""/>
+ </propertyfile>
+ </target>
+ <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
+ <target depends="init" name="-check-automatic-build">
+ <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
+ </target>
+ <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
+ <antcall target="clean"/>
+ </target>
+ <target depends="init,deps-jar" name="-pre-pre-compile">
+ <mkdir dir="${build.classes.dir}"/>
+ </target>
+ <target name="-pre-compile">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target if="do.depend.true" name="-compile-depend">
+ <pathconvert property="build.generated.subdirs">
+ <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+ <include name="*"/>
+ </dirset>
+ </pathconvert>
+ <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
+ </target>
+ <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
+ <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
+ <copy todir="${build.classes.dir}">
+ <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+ </copy>
+ </target>
+ <target name="-post-compile">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
+ <target name="-pre-compile-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
+ <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+ <j2seproject3:force-recompile/>
+ <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
+ </target>
+ <target name="-post-compile-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
+ <!--
+ ====================
+ JAR BUILDING SECTION
+ ====================
+ -->
+ <target depends="init" name="-pre-pre-jar">
+ <dirname file="${dist.jar}" property="dist.jar.dir"/>
+ <mkdir dir="${dist.jar.dir}"/>
+ </target>
+ <target name="-pre-jar">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available">
+ <j2seproject1:jar/>
+ </target>
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available">
+ <j2seproject1:jar manifest="${manifest.file}"/>
+ </target>
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
+ <j2seproject1:jar manifest="${manifest.file}">
+ <j2seproject1:manifest>
+ <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
+ </j2seproject1:manifest>
+ </j2seproject1:jar>
+ <echo>To run this application from the command line without Ant, try:</echo>
+ <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+ <property location="${dist.jar}" name="dist.jar.resolved"/>
+ <pathconvert property="run.classpath.with.dist.jar">
+ <path path="${run.classpath}"/>
+ <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
+ </pathconvert>
+ <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
+ </target>
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
+ <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+ <pathconvert property="run.classpath.without.build.classes.dir">
+ <path path="${run.classpath}"/>
+ <map from="${build.classes.dir.resolved}" to=""/>
+ </pathconvert>
+ <pathconvert pathsep=" " property="jar.classpath">
+ <path path="${run.classpath.without.build.classes.dir}"/>
+ <chainedmapper>
+ <flattenmapper/>
+ <globmapper from="*" to="lib/*"/>
+ </chainedmapper>
+ </pathconvert>
+ <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
+ <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
+ <fileset dir="${build.classes.dir}"/>
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}"/>
+ <attribute name="Class-Path" value="${jar.classpath}"/>
+ </manifest>
+ </copylibs>
+ <echo>To run this application from the command line without Ant, try:</echo>
+ <property location="${dist.jar}" name="dist.jar.resolved"/>
+ <echo>java -jar "${dist.jar.resolved}"</echo>
+ </target>
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+mkdist.available" name="-do-jar-with-libraries-without-mainclass" unless="main.class.available">
+ <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+ <pathconvert property="run.classpath.without.build.classes.dir">
+ <path path="${run.classpath}"/>
+ <map from="${build.classes.dir.resolved}" to=""/>
+ </pathconvert>
+ <pathconvert pathsep=" " property="jar.classpath">
+ <path path="${run.classpath.without.build.classes.dir}"/>
+ <chainedmapper>
+ <flattenmapper/>
+ <globmapper from="*" to="lib/*"/>
+ </chainedmapper>
+ </pathconvert>
+ <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
+ <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
+ <fileset dir="${build.classes.dir}"/>
+ <manifest>
+ <attribute name="Class-Path" value="${jar.classpath}"/>
+ </manifest>
+ </copylibs>
+ </target>
+ <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.mkdist" name="-do-jar-with-libraries-without-manifest" unless="manifest.available">
+ <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+ <pathconvert property="run.classpath.without.build.classes.dir">
+ <path path="${run.classpath}"/>
+ <map from="${build.classes.dir.resolved}" to=""/>
+ </pathconvert>
+ <pathconvert pathsep=" " property="jar.classpath">
+ <path path="${run.classpath.without.build.classes.dir}"/>
+ <chainedmapper>
+ <flattenmapper/>
+ <globmapper from="*" to="lib/*"/>
+ </chainedmapper>
+ </pathconvert>
+ <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
+ <copylibs compress="${jar.compress}" jarfile="${dist.jar}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
+ <fileset dir="${build.classes.dir}"/>
+ <manifest>
+ <attribute name="Class-Path" value="${jar.classpath}"/>
+ </manifest>
+ </copylibs>
+ </target>
+ <target name="-post-jar">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-do-jar-with-libraries-without-mainclass,-do-jar-with-libraries-without-manifest,-post-jar" description="Build JAR." name="jar"/>
+ <!--
+ =================
+ EXECUTION SECTION
+ =================
+ -->
+ <target depends="init,compile" description="Run a main class." name="run">
+ <j2seproject1:java>
+ <customize>
+ <arg line="${application.args}"/>
+ </customize>
+ </j2seproject1:java>
+ </target>
+ <target name="-do-not-recompile">
+ <property name="javac.includes.binary" value=""/>
+ </target>
+ <target depends="init,compile-single" name="run-single">
+ <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+ <j2seproject1:java classname="${run.class}"/>
+ </target>
+ <target depends="init,compile-test-single" name="run-test-with-main">
+ <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+ <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
+ </target>
+ <!--
+ =================
+ DEBUGGING SECTION
+ =================
+ -->
+ <target depends="init" if="netbeans.home" name="-debug-start-debugger">
+ <j2seproject1:nbjpdastart name="${debug.class}"/>
+ </target>
+ <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
+ <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
+ </target>
+ <target depends="init,compile" name="-debug-start-debuggee">
+ <j2seproject3:debug>
+ <customize>
+ <arg line="${application.args}"/>
+ </customize>
+ </j2seproject3:debug>
+ </target>
+ <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
+ <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
+ <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
+ </target>
+ <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
+ <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
+ <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+ <j2seproject3:debug classname="${debug.class}"/>
+ </target>
+ <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
+ <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
+ <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+ <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
+ </target>
+ <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
+ <target depends="init" name="-pre-debug-fix">
+ <fail unless="fix.includes">Must set fix.includes</fail>
+ <property name="javac.includes" value="${fix.includes}.java"/>
+ </target>
+ <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
+ <j2seproject1:nbjpdareload/>
+ </target>
+ <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
+ <!--
+ ===============
+ JAVADOC SECTION
+ ===============
+ -->
+ <target depends="init" name="-javadoc-build">
+ <mkdir dir="${dist.javadoc.dir}"/>
+ <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
+ <classpath>
+ <path path="${javac.classpath}"/>
+ </classpath>
+ <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+ <filename name="**/*.java"/>
+ </fileset>
+ <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+ <include name="**/*.java"/>
+ </fileset>
+ </javadoc>
+ </target>
+ <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
+ <nbbrowse file="${dist.javadoc.dir}/index.html"/>
+ </target>
+ <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
+ <!--
+ =========================
+ JUNIT COMPILATION SECTION
+ =========================
+ -->
+ <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
+ <mkdir dir="${build.test.classes.dir}"/>
+ </target>
+ <target name="-pre-compile-test">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target if="do.depend.true" name="-compile-test-depend">
+ <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
+ </target>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
+ <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
+ <copy todir="${build.test.classes.dir}">
+ <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+ </copy>
+ </target>
+ <target name="-post-compile-test">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
+ <target name="-pre-compile-test-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
+ <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+ <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
+ <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
+ <copy todir="${build.test.classes.dir}">
+ <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+ </copy>
+ </target>
+ <target name="-post-compile-test-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
+ <!--
+ =======================
+ JUNIT EXECUTION SECTION
+ =======================
+ -->
+ <target depends="init" if="have.tests" name="-pre-test-run">
+ <mkdir dir="${build.test.results.dir}"/>
+ </target>
+ <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
+ <j2seproject3:junit testincludes="**/*Test.java"/>
+ </target>
+ <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
+ <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+ </target>
+ <target depends="init" if="have.tests" name="test-report"/>
+ <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
+ <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
+ <target depends="init" if="have.tests" name="-pre-test-run-single">
+ <mkdir dir="${build.test.results.dir}"/>
+ </target>
+ <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
+ <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
+ <j2seproject3:junit excludes="" includes="${test.includes}"/>
+ </target>
+ <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
+ <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+ </target>
+ <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
+ <!--
+ =======================
+ JUNIT DEBUGGING SECTION
+ =======================
+ -->
+ <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
+ <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
+ <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
+ <delete file="${test.report.file}"/>
+ <mkdir dir="${build.test.results.dir}"/>
+ <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
+ <customize>
+ <syspropertyset>
+ <propertyref prefix="test-sys-prop."/>
+ <mapper from="test-sys-prop.*" to="*" type="glob"/>
+ </syspropertyset>
+ <arg value="${test.class}"/>
+ <arg value="showoutput=true"/>
+ <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
+ <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
+ </customize>
+ </j2seproject3:debug>
+ </target>
+ <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
+ <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
+ </target>
+ <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
+ <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
+ <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
+ </target>
+ <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
+ <!--
+ =========================
+ APPLET EXECUTION SECTION
+ =========================
+ -->
+ <target depends="init,compile-single" name="run-applet">
+ <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+ <j2seproject1:java classname="sun.applet.AppletViewer">
+ <customize>
+ <arg value="${applet.url}"/>
+ </customize>
+ </j2seproject1:java>
+ </target>
+ <!--
+ =========================
+ APPLET DEBUGGING SECTION
+ =========================
+ -->
+ <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
+ <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+ <j2seproject3:debug classname="sun.applet.AppletViewer">
+ <customize>
+ <arg value="${applet.url}"/>
+ </customize>
+ </j2seproject3:debug>
+ </target>
+ <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
+ <!--
+ ===============
+ CLEANUP SECTION
+ ===============
+ -->
+ <target name="-deps-clean-init" unless="built-clean.properties">
+ <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
+ <delete file="${built-clean.properties}" quiet="true"/>
+ </target>
+ <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
+ <echo level="warn" message="Cycle detected: RestaCoef was already built"/>
+ </target>
+ <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
+ <mkdir dir="${build.dir}"/>
+ <touch file="${built-clean.properties}" verbose="false"/>
+ <property file="${built-clean.properties}" prefix="already.built.clean."/>
+ <antcall target="-warn-already-built-clean"/>
+ <propertyfile file="${built-clean.properties}">
+ <entry key="${basedir}" value=""/>
+ </propertyfile>
+ </target>
+ <target depends="init" name="-do-clean">
+ <delete dir="${build.dir}"/>
+ <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
+ </target>
+ <target name="-post-clean">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
+ <target name="-check-call-dep">
+ <property file="${call.built.properties}" prefix="already.built."/>
+ <condition property="should.call.dep">
+ <not>
+ <isset property="already.built.${call.subproject}"/>
+ </not>
+ </condition>
+ </target>
+ <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
+ <ant antfile="${call.script}" inheritall="false" target="${call.target}">
+ <propertyset>
+ <propertyref prefix="transfer."/>
+ <mapper from="transfer.*" to="*" type="glob"/>
+ </propertyset>
+ </ant>
+ </target>
+</project>
diff --git a/RestaCoef/nbproject/genfiles.properties b/RestaCoef/nbproject/genfiles.properties
new file mode 100644
index 0000000..dfa26fc
--- /dev/null
+++ b/RestaCoef/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=2232345e
+build.xml.script.CRC32=c6be2d14
+build.xml.stylesheet.CRC32=958a1d3e@1.32.1.45
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=2232345e
+nbproject/build-impl.xml.script.CRC32=9ad60638
+nbproject/build-impl.xml.stylesheet.CRC32=576378a2@1.32.1.45
diff --git a/RestaCoef/nbproject/private/config.properties b/RestaCoef/nbproject/private/config.properties
new file mode 100644
index 0000000..e69de29
diff --git a/RestaCoef/nbproject/private/private.properties b/RestaCoef/nbproject/private/private.properties
new file mode 100644
index 0000000..66e0895
--- /dev/null
+++ b/RestaCoef/nbproject/private/private.properties
@@ -0,0 +1,7 @@
+compile.on.save=true
+do.depend=false
+do.jar=true
+javac.debug=true
+javadoc.preview=true
+jaxbwiz.endorsed.dirs=/Applications/NetBeans/NetBeans 6.8.app/Contents/Resources/NetBeans/ide12/modules/ext/jaxb/api
+user.properties.file=/Users/honza/.netbeans/6.8/build.properties
diff --git a/RestaCoef/nbproject/private/private.xml b/RestaCoef/nbproject/private/private.xml
new file mode 100644
index 0000000..9578046
--- /dev/null
+++ b/RestaCoef/nbproject/private/private.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+ <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
+ <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
+ <file>file:/Users/honza/Code/minis/RestaCoef/src/restacoef/Main.java</file>
+ <file>file:/Users/honza/Code/minis/RestaCoef/src/com/honzasterba/dbfcoef/DbCoef.java</file>
+ </open-files>
+</project-private>
diff --git a/RestaCoef/nbproject/project.properties b/RestaCoef/nbproject/project.properties
new file mode 100644
index 0000000..e428fad
--- /dev/null
+++ b/RestaCoef/nbproject/project.properties
@@ -0,0 +1,69 @@
+application.title=RestaCoef
+application.vendor=honza
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/RestaCoef.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
+excludes=
+file.reference.DBF_JDBC30.jar=lib/DBF_JDBC30.jar
+includes=**
+jar.compress=false
+javac.classpath=\
+ ${file.reference.DBF_JDBC30.jar}:\
+ ${libs.swing-layout.classpath}
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.source=1.5
+javac.target=1.5
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${libs.junit.classpath}:\
+ ${libs.junit_4.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"
+main.class=restacoef.Main
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project
+# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
+# or test-sys-prop.name=value to set system properties for unit tests):
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=US-ASCII
+src.dir=src
+test.src.dir=test
diff --git a/RestaCoef/nbproject/project.xml b/RestaCoef/nbproject/project.xml
new file mode 100644
index 0000000..a9687b0
--- /dev/null
+++ b/RestaCoef/nbproject/project.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.java.j2seproject</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
+ <name>RestaCoef</name>
+ <source-roots>
+ <root id="src.dir"/>
+ </source-roots>
+ <test-roots>
+ <root id="test.src.dir"/>
+ </test-roots>
+ </data>
+ </configuration>
+</project>
diff --git a/RestaCoef/src/com/honzasterba/dbfcoef/DbCoef.java b/RestaCoef/src/com/honzasterba/dbfcoef/DbCoef.java
new file mode 100644
index 0000000..cd308b1
--- /dev/null
+++ b/RestaCoef/src/com/honzasterba/dbfcoef/DbCoef.java
@@ -0,0 +1,25 @@
+package com.honzasterba.dbfcoef;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+
+
+public class DbCoef {
+
+ static {
+ try {
+ Class.forName("com.hxtt.sql.dbf.DBFDriver");
+ } catch (ClassNotFoundException e) {
+ System.out.println("Cannot load driver.");
+ e.printStackTrace();
+ }
+ }
+
+ public static void run(String path, float coef) throws Exception {
+ Connection c = DriverManager.getConnection("jdbc:dbf:///"+path);
+ Statement s = c.createStatement();
+ s.executeUpdate("UPDATE mp.dbf SET CENA_MONT = CENA_MONT * " + coef + ", CENA_DEM = CENA_DEM * " + coef);
+ s.close();
+ }
+}
diff --git a/RestaCoef/src/restacoef/Main.java b/RestaCoef/src/restacoef/Main.java
new file mode 100644
index 0000000..6696f66
--- /dev/null
+++ b/RestaCoef/src/restacoef/Main.java
@@ -0,0 +1,70 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package restacoef;
+
+import com.honzasterba.dbfcoef.DbCoef;
+import java.io.File;
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+import javax.swing.filechooser.FileFilter;
+
+/**
+ *
+ * @author honza
+ */
+public class Main {
+
+ static MainUI ui;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ ui = new MainUI();
+ ui.setVisible(true);
+ }
+
+ public static void work(String path, String coefStr) {
+ try {
+ float coef = Float.parseFloat(coefStr);
+ path = path.replaceAll("\\\\", "/");
+ System.out.print("RUN IN " + path + " " + coef);
+ DbCoef.run(path, coef);
+ showMessage("Hotovo.");
+ } catch (NumberFormatException e) {
+ showMessage("Koeficient musi byt cislo.");
+ } catch (Exception e) {
+ showMessage("Chyba: " + e.getMessage());
+ }
+
+ }
+
+ public static void findFiles() {
+ JFileChooser jfc = new JFileChooser();
+ jfc.setDialogTitle("Vyberte umisteni ceniku");
+ jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ jfc.setFileFilter(new FileFilter() {
+
+ @Override
+ public boolean accept(File f) {
+ return f.isDirectory();
+ }
+
+ @Override
+ public String getDescription() {
+ return "Pouze adresare";
+ }
+ });
+ int res = jfc.showDialog(ui, "Vybrat");
+ if (res == JFileChooser.APPROVE_OPTION) {
+ ui.filesField.setText(jfc.getSelectedFile().getAbsolutePath());
+ }
+ }
+
+ public static void showMessage(String msg) {
+ System.out.print("Zprava: " + msg);
+ JOptionPane.showMessageDialog(ui, msg);
+ }
+}
diff --git a/RestaCoef/src/restacoef/MainUI.form b/RestaCoef/src/restacoef/MainUI.form
new file mode 100644
index 0000000..3757d57
--- /dev/null
+++ b/RestaCoef/src/restacoef/MainUI.form
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="3"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jLabel4" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
+ <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="coefTextField" pref="315" max="32767" attributes="0"/>
+ <Component id="filesField" alignment="0" min="-2" pref="315" max="-2" attributes="1"/>
+ </Group>
+ </Group>
+ <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Group type="102" attributes="0">
+ <Component id="filesButton" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
+ </Group>
+ <Component id="workButton" alignment="1" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jLabel4" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="filesField" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="filesButton" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="workButton" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Group type="103" alignment="0" groupAlignment="3" attributes="0">
+ <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="coefTextField" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace pref="28" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+ <Font name="Lucida Grande" size="18" style="0"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="RestaCoef"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="filesField">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="c:\Program Files\RESTA\data\ceniky"/>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JButton" name="filesButton">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Hledat"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="filesButtonActionPerformed"/>
+ </Events>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
+ </AuxValues>
+ </Component>
+ <Component class="javax.swing.JTextField" name="coefTextField">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="1.0"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JButton" name="workButton">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Pracuj!"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="workButtonActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabel2">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Umisteni ceniku:"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabel3">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Koeficient:"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabel4">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="nasobi cenu montaze i demontaze koeficientem"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+</Form>
diff --git a/RestaCoef/src/restacoef/MainUI.java b/RestaCoef/src/restacoef/MainUI.java
new file mode 100644
index 0000000..c775b24
--- /dev/null
+++ b/RestaCoef/src/restacoef/MainUI.java
@@ -0,0 +1,155 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * MainUI.java
+ *
+ * Created on Feb 21, 2010, 10:55:08 AM
+ */
+
+package restacoef;
+
+/**
+ *
+ * @author honza
+ */
+public class MainUI extends javax.swing.JFrame {
+
+ /** Creates new form MainUI */
+ public MainUI() {
+ initComponents();
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jLabel1 = new javax.swing.JLabel();
+ filesField = new javax.swing.JTextField();
+ filesButton = new javax.swing.JButton();
+ coefTextField = new javax.swing.JTextField();
+ workButton = new javax.swing.JButton();
+ jLabel2 = new javax.swing.JLabel();
+ jLabel3 = new javax.swing.JLabel();
+ jLabel4 = new javax.swing.JLabel();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+ jLabel1.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N
+ jLabel1.setText("RestaCoef");
+
+ filesField.setText("c:\\Program Files\\RESTA\\data\\ceniky");
+
+ filesButton.setText("Hledat");
+ filesButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ filesButtonActionPerformed(evt);
+ }
+ });
+
+ coefTextField.setText("1.0");
+
+ workButton.setText("Pracuj!");
+ workButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ workButtonActionPerformed(evt);
+ }
+ });
+
+ jLabel2.setText("Umisteni ceniku:");
+
+ jLabel3.setText("Koeficient:");
+
+ jLabel4.setText("nasobi cenu montaze i demontaze koeficientem");
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jLabel4))
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(20, 20, 20)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jLabel2)
+ .add(jLabel3))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(coefTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
+ .add(filesField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 315, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
+ .add(jLabel1))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(layout.createSequentialGroup()
+ .add(filesButton)
+ .add(1, 1, 1))
+ .add(workButton))))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jLabel1)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jLabel4)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(jLabel2)
+ .add(filesField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(filesButton))
+ .add(18, 18, 18)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(workButton)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(jLabel3)
+ .add(coefTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap(28, Short.MAX_VALUE))
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void workButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_workButtonActionPerformed
+ Main.work(filesField.getText(), coefTextField.getText());
+ }//GEN-LAST:event_workButtonActionPerformed
+
+ private void filesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesButtonActionPerformed
+ Main.findFiles();
+ }//GEN-LAST:event_filesButtonActionPerformed
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String args[]) {
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new MainUI().setVisible(true);
+ }
+ });
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JTextField coefTextField;
+ public javax.swing.JButton filesButton;
+ public javax.swing.JTextField filesField;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JLabel jLabel4;
+ private javax.swing.JButton workButton;
+ // End of variables declaration//GEN-END:variables
+
+}
|
nextspace/git_tutorial
|
85448377bc7621c68a5247215af7b84ba1e5a4be
|
formatting markdown
|
diff --git a/README.md b/README.md
index c924278..c7c4bbb 100644
--- a/README.md
+++ b/README.md
@@ -1,39 +1,43 @@
__ __ __
/\ \__ __ /\ \__ __/\ \__
____\ \ ,_\ __ _____ /\_\ ___\ \ ,_\ ___ __ /\_\ \ ,_\
/',__\\ \ \/ /'__`\\ '__`\ \/\ \ /' _ `\ \ \/ / __`\ /'_ `\/\ \ \ \/
/\__, `\\ \ \_/\ __/ \ \L\ \ \ \ \/\ \/\ \ \ \_/\ \L\ \ /\ \L\ \ \ \ \ \_
\/\____/ \ \__\ \____\ \ ,__/ \ \_\ \_\ \_\ \__\ \____/ \ \____ \ \_\ \__\
\/___/ \/__/\/____/\ \ \/ \/_/\/_/\/_/\/__/\/___/ \/___L\ \/_/\/__/
\ \_\ /\____/
\/_/ \_/__/
What
====
-Right here at NextSpace we will get to know git, how it works, what you can do with it, techniques for distributed development, and cocktail party tricks to impress your friends.
+Right here at NextSpace we will get to know git, how it works, what you can do with it,
+techniques for distributed development, and cocktail party tricks to impress your friends.
From the [homepage:](http://git-scm.org/)
- Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
+ Git is a free & open source, distributed version control system designed to handle
+ everything from small to very large projects with speed and efficiency.
- Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are fast and easy to do.
+ Every Git clone is a full-fledged repository with complete history and full revision
+ tracking capabilities, not dependent on network access or a central server. Branching
+ and merging are fast and easy to do.
We will cover
-------------
* Installation
* Basic concepts (how it works)
* Branching and Merging
* Distributed Workflows
* How git is better than X (where X is your other favorite version control software)
* Answer questions if I can
Where
=====
"The Slugroom" @ [Nextspace](http://nextspace.us/)
101 Cooper St.
Santa Cruz, CA 95060
When
====
Date TBD
\ No newline at end of file
|
nextspace/git_tutorial
|
9eed3c5855642774896656d803a3ec8fd4914c99
|
blastoff
|
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c924278
--- /dev/null
+++ b/README.md
@@ -0,0 +1,39 @@
+ __ __ __
+ /\ \__ __ /\ \__ __/\ \__
+ ____\ \ ,_\ __ _____ /\_\ ___\ \ ,_\ ___ __ /\_\ \ ,_\
+ /',__\\ \ \/ /'__`\\ '__`\ \/\ \ /' _ `\ \ \/ / __`\ /'_ `\/\ \ \ \/
+ /\__, `\\ \ \_/\ __/ \ \L\ \ \ \ \/\ \/\ \ \ \_/\ \L\ \ /\ \L\ \ \ \ \ \_
+ \/\____/ \ \__\ \____\ \ ,__/ \ \_\ \_\ \_\ \__\ \____/ \ \____ \ \_\ \__\
+ \/___/ \/__/\/____/\ \ \/ \/_/\/_/\/_/\/__/\/___/ \/___L\ \/_/\/__/
+ \ \_\ /\____/
+ \/_/ \_/__/
+
+
+What
+====
+Right here at NextSpace we will get to know git, how it works, what you can do with it, techniques for distributed development, and cocktail party tricks to impress your friends.
+
+From the [homepage:](http://git-scm.org/)
+
+ Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
+
+ Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are fast and easy to do.
+
+We will cover
+-------------
+* Installation
+* Basic concepts (how it works)
+* Branching and Merging
+* Distributed Workflows
+* How git is better than X (where X is your other favorite version control software)
+* Answer questions if I can
+
+Where
+=====
+"The Slugroom" @ [Nextspace](http://nextspace.us/)
+101 Cooper St.
+Santa Cruz, CA 95060
+
+When
+====
+Date TBD
\ No newline at end of file
|
idega/sunnan3
|
235db3df3e545959f9f479c0eca64e71ce9c0453
|
adding licence
|
diff --git a/LICENCE b/LICENCE
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/LICENCE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
idega/sunnan3
|
d3e2b61197d5b40ef68c44b70c53283fcb6da85b
|
Declaring new application version.
|
diff --git a/project.xml b/project.xml
index 4c21e54..1d050d0 100644
--- a/project.xml
+++ b/project.xml
@@ -1,339 +1,339 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<pomVersion>3</pomVersion>
<extend>${idegaweb.application.egov.project.dir}/project.xml</extend>
<name>sunnan3</name>
<groupId>iw-applications</groupId>
<artifactId>sunnan3</artifactId>
<currentVersion>3.1.3</currentVersion>
<inceptionYear>2007</inceptionYear>
<shortDescription>This is the eGov Application of idegaWeb for the Sunnan3 project</shortDescription>
<versions>
<version>
<id>3.1.0</id>
<name>3.1.0</name>
<tag>SUNNAN3_3_1_0</tag>
</version>
<version>
<id>3.1.1</id>
<name>3.1.1</name>
<tag>SUNNAN3_3_1_1</tag>
</version>
<version>
<id>3.1.2</id>
<name>3.1.2</name>
<tag>SUNNAN3_3_1_2</tag>
</version>
<version>
<id>3.1.3</id>
<name>3.1.3</name>
<tag>SUNNAN3_3_1_3</tag>
</version>
</versions>
<branches/>
<developers>
<developer>
<name>Pall Helgason</name>
<id>palli</id>
<email>palli@idega.is</email>
<organization>idega software</organization>
<roles/>
</developer>
</developers>
<build>
<nagEmailAddress>palli@idega.com</nagEmailAddress>
<sourceDirectory>src/java</sourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.boxoffice</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.calendar</artifactId>
<version>3.1.3</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.category</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.contract</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.dataquery</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.datareport</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.documents</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.finance</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.pdf</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.poll</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.process.webservice</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.reports</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.rss</artifactId>
<version>3.1.12</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.school</artifactId>
<version>3.1.15</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.survey</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.text</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<!-- dependencies on commune -->
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov</artifactId>
<version>1.0.11</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.accounting</artifactId>
<version>1.0.22</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.school</artifactId>
<version>1.0.19</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.afterschoolcare</artifactId>
- <version>1.0.50</version>
+ <version>1.0.52</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.childcare</artifactId>
<version>1.0.18</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.musicschool</artifactId>
<version>1.0.24</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.citizen</artifactId>
<version>1.0.20</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.application</artifactId>
<version>1.0.13</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.message</artifactId>
<version>1.0.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.finances</artifactId>
<version>1.0.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.serviceoffer</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.schoolmeal</artifactId>
<version>1.0.36</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases</artifactId>
<version>1.0.28</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases.onesystem</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor.vefthjonusta</artifactId>
<version>1.1.5</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus.svarbox</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.idegaweb</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.ldap</artifactId>
<version>3.1.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.cal</artifactId>
<version>3.1.7</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.member</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.questions</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
</dependencies>
</project>
|
idega/sunnan3
|
e5e8b52b9ec538f6a7a62efe88e92660507592db
|
A small, temporary, fix for Sunnul¾kjarskli
|
diff --git a/project.xml b/project.xml
index 24cdc16..4c21e54 100644
--- a/project.xml
+++ b/project.xml
@@ -1,339 +1,339 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<pomVersion>3</pomVersion>
<extend>${idegaweb.application.egov.project.dir}/project.xml</extend>
<name>sunnan3</name>
<groupId>iw-applications</groupId>
<artifactId>sunnan3</artifactId>
<currentVersion>3.1.3</currentVersion>
<inceptionYear>2007</inceptionYear>
<shortDescription>This is the eGov Application of idegaWeb for the Sunnan3 project</shortDescription>
<versions>
<version>
<id>3.1.0</id>
<name>3.1.0</name>
<tag>SUNNAN3_3_1_0</tag>
</version>
<version>
<id>3.1.1</id>
<name>3.1.1</name>
<tag>SUNNAN3_3_1_1</tag>
</version>
<version>
<id>3.1.2</id>
<name>3.1.2</name>
<tag>SUNNAN3_3_1_2</tag>
</version>
<version>
<id>3.1.3</id>
<name>3.1.3</name>
<tag>SUNNAN3_3_1_3</tag>
</version>
</versions>
<branches/>
<developers>
<developer>
<name>Pall Helgason</name>
<id>palli</id>
<email>palli@idega.is</email>
<organization>idega software</organization>
<roles/>
</developer>
</developers>
<build>
<nagEmailAddress>palli@idega.com</nagEmailAddress>
<sourceDirectory>src/java</sourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.boxoffice</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.calendar</artifactId>
<version>3.1.3</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.category</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.contract</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.dataquery</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.datareport</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.documents</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.finance</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.pdf</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.poll</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.process.webservice</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.reports</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.rss</artifactId>
<version>3.1.12</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.school</artifactId>
<version>3.1.15</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.survey</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.text</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<!-- dependencies on commune -->
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov</artifactId>
<version>1.0.11</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.accounting</artifactId>
<version>1.0.22</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.school</artifactId>
<version>1.0.19</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.afterschoolcare</artifactId>
<version>1.0.50</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.childcare</artifactId>
<version>1.0.18</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.musicschool</artifactId>
<version>1.0.24</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.citizen</artifactId>
<version>1.0.20</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.application</artifactId>
<version>1.0.13</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.message</artifactId>
<version>1.0.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.finances</artifactId>
<version>1.0.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.serviceoffer</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.schoolmeal</artifactId>
- <version>1.0.35</version>
+ <version>1.0.36</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases</artifactId>
<version>1.0.28</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases.onesystem</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor.vefthjonusta</artifactId>
<version>1.1.5</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus.svarbox</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.idegaweb</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.ldap</artifactId>
<version>3.1.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.cal</artifactId>
- <version>3.1.6</version>
+ <version>3.1.7</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.member</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.questions</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
</dependencies>
</project>
|
idega/sunnan3
|
35d26053e3a80ec4f3170256d9f5c5c5207a46aa
|
Declaring new application version.
|
diff --git a/project.xml b/project.xml
index 7ba9115..24cdc16 100644
--- a/project.xml
+++ b/project.xml
@@ -1,334 +1,339 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<pomVersion>3</pomVersion>
<extend>${idegaweb.application.egov.project.dir}/project.xml</extend>
<name>sunnan3</name>
<groupId>iw-applications</groupId>
<artifactId>sunnan3</artifactId>
- <currentVersion>3.1.2</currentVersion>
+ <currentVersion>3.1.3</currentVersion>
<inceptionYear>2007</inceptionYear>
<shortDescription>This is the eGov Application of idegaWeb for the Sunnan3 project</shortDescription>
<versions>
<version>
<id>3.1.0</id>
<name>3.1.0</name>
<tag>SUNNAN3_3_1_0</tag>
</version>
<version>
<id>3.1.1</id>
<name>3.1.1</name>
<tag>SUNNAN3_3_1_1</tag>
</version>
<version>
<id>3.1.2</id>
<name>3.1.2</name>
<tag>SUNNAN3_3_1_2</tag>
</version>
+ <version>
+ <id>3.1.3</id>
+ <name>3.1.3</name>
+ <tag>SUNNAN3_3_1_3</tag>
+ </version>
</versions>
<branches/>
<developers>
<developer>
<name>Pall Helgason</name>
<id>palli</id>
<email>palli@idega.is</email>
<organization>idega software</organization>
<roles/>
</developer>
</developers>
<build>
<nagEmailAddress>palli@idega.com</nagEmailAddress>
<sourceDirectory>src/java</sourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.boxoffice</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.calendar</artifactId>
<version>3.1.3</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.category</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.contract</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.dataquery</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.datareport</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.documents</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.finance</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.pdf</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.poll</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.process.webservice</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.reports</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.rss</artifactId>
<version>3.1.12</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.school</artifactId>
- <version>3.1.14</version>
+ <version>3.1.15</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.survey</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.text</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<!-- dependencies on commune -->
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov</artifactId>
- <version>1.0.10</version>
+ <version>1.0.11</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.accounting</artifactId>
<version>1.0.22</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.school</artifactId>
- <version>1.0.17</version>
+ <version>1.0.19</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.afterschoolcare</artifactId>
- <version>1.0.45</version>
+ <version>1.0.50</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.childcare</artifactId>
- <version>1.0.17</version>
+ <version>1.0.18</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.musicschool</artifactId>
- <version>1.0.22</version>
+ <version>1.0.24</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.citizen</artifactId>
- <version>1.0.17</version>
+ <version>1.0.20</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.application</artifactId>
- <version>1.0.12</version>
+ <version>1.0.13</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.message</artifactId>
<version>1.0.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.finances</artifactId>
<version>1.0.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.serviceoffer</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.schoolmeal</artifactId>
- <version>1.0.34</version>
+ <version>1.0.35</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases</artifactId>
<version>1.0.28</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases.onesystem</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor.vefthjonusta</artifactId>
<version>1.1.5</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus.svarbox</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.idegaweb</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.ldap</artifactId>
<version>3.1.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.cal</artifactId>
<version>3.1.6</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.member</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.questions</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
</dependencies>
</project>
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index f111e8f..b757b22 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -1,23 +1,29 @@
<document>
<properties>
<title>eGov Sunnan3 Changes</title>
<author email="palli@idega.com">Pall Helgason</author>
</properties>
<body>
+ <release version="3.1.3" date="2007-08-22">
+ <action dev="palli" type="update">
+ Updated several eGov bundles.
+ </action>
+ </release>
+
<release version="3.1.2" date="2007-05-30">
<action dev="palli" type="update">
AfterSchoolCare: Added fields to pdf printout of application and fixed the display of the elementary school.
</action>
</release>
<release version="3.1.1" date="2007-05-25">
<action dev="palli" type="update">
Updated afterschoolcare to fix check for mobile phone in printout.
</action>
</release>
<release version="3.1.0" date="2007-02-27">
<action dev="palli" type="update">New version for platform version 3.1.0</action>
</release>
</body>
</document>
\ No newline at end of file
|
idega/sunnan3
|
a1b6047ce1f37450fee18d897c5446e9c7f7ebb1
|
updating psf files with branched bundles for poll, questions and datareport modules
|
diff --git a/sunnan3.psf b/sunnan3.psf
index 3f24417..04003ba 100644
--- a/sunnan3.psf
+++ b/sunnan3.psf
@@ -1,45 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<psf version="2.0">
<provider id="org.eclipse.team.cvs.core.cvsnature">
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.boxoffice.bundle,com.idega.block.boxoffice"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.cal.bundle,com.idega.block.cal,BRANCH_PLATFORM_3_1"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.calendar.bundle,com.idega.block.calendar,BRANCH_PLATFORM_3_1"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.category.bundle,com.idega.block.category,BRANCH_PLATFORM_3_1"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.contract.bundle,com.idega.block.contract"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.dataquery.bundle,com.idega.block.dataquery"/>
-<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.datareport.bundle,com.idega.block.datareport"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.datareport.bundle,com.idega.block.datareport,BRANCH_PLATFORM_3_1"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.documents.bundle,com.idega.block.documents"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.finance.bundle,com.idega.block.finance"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.ldap.bundle,com.idega.block.ldap"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.pdf.bundle,com.idega.block.pdf"/>
-<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.poll.bundle,com.idega.block.poll"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.poll.bundle,com.idega.block.poll,BRANCH_PLATFORM_3_1"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.process.webservice.bundle,com.idega.block.process.webservice,BRANCH_PLATFORM_3_1"/>
-<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.questions.bundle,com.idega.block.questions"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.questions.bundle,com.idega.block.questions,BRANCH_PLATFORM_3_1"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.reports.bundle,com.idega.block.reports"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.school.bundle,com.idega.block.school"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.survey.bundle,com.idega.block.survey"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.text.bundle,com.idega.block.text,BRANCH_PLATFORM_3_1"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.weather.bundle,com.idega.block.weather"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.idegaweb.bundle,com.idega.idegaweb"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.block.modernus.bundle,is.idega.block.modernus"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.block.modernus.svarbox.bundle,is.idega.block.modernus.svarbox"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.block.weather.bundle,is.idega.block.weather"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.bundle,is.idega.idegaweb.egov"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.accounting.bundle,is.idega.idegaweb.egov.accounting"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.afterschoolcare.bundle,is.idega.idegaweb.egov.afterschoolcare"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.application.bundle,is.idega.idegaweb.egov.application,BRANCH_PLATFORM_3_1"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.cases.bundle,is.idega.idegaweb.egov.cases,BRANCH_PLATFORM_3_1"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.cases.onesystem.bundle,is.idega.idegaweb.egov.cases.onesystem"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.childcare.bundle,is.idega.idegaweb.egov.childcare"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.citizen.bundle,is.idega.idegaweb.egov.citizen"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.finances.bundle,is.idega.idegaweb.egov.finances"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.message.bundle,is.idega.idegaweb.egov.message"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.musicschool.bundle,is.idega.idegaweb.egov.musicschool"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.school.bundle,is.idega.idegaweb.egov.school"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.schoolmeal.bundle,is.idega.idegaweb.egov.schoolmeal"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.serviceoffer.bundle,is.idega.idegaweb.egov.serviceoffer"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.member.bundle,is.idega.idegaweb.member"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.mentor.bundle,is.mentor"/>
<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.mentor.vefthjonusta.bundle,is.mentor.vefthjonusta"/>
</provider>
</psf>
\ No newline at end of file
|
idega/sunnan3
|
b1b4c2dd6d41c4023ecc87b6a99c00d521359813
|
[maven-scm-plugin] prepare release 3.1.2
|
diff --git a/project.xml b/project.xml
index 07c7ed2..7ba9115 100644
--- a/project.xml
+++ b/project.xml
@@ -1,329 +1,334 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<pomVersion>3</pomVersion>
<extend>${idegaweb.application.egov.project.dir}/project.xml</extend>
<name>sunnan3</name>
<groupId>iw-applications</groupId>
<artifactId>sunnan3</artifactId>
- <currentVersion>3.1.1</currentVersion>
+ <currentVersion>3.1.2</currentVersion>
<inceptionYear>2007</inceptionYear>
<shortDescription>This is the eGov Application of idegaWeb for the Sunnan3 project</shortDescription>
<versions>
<version>
<id>3.1.0</id>
<name>3.1.0</name>
<tag>SUNNAN3_3_1_0</tag>
</version>
<version>
<id>3.1.1</id>
<name>3.1.1</name>
<tag>SUNNAN3_3_1_1</tag>
</version>
+ <version>
+ <id>3.1.2</id>
+ <name>3.1.2</name>
+ <tag>SUNNAN3_3_1_2</tag>
+ </version>
</versions>
<branches/>
<developers>
<developer>
<name>Pall Helgason</name>
<id>palli</id>
<email>palli@idega.is</email>
<organization>idega software</organization>
<roles/>
</developer>
</developers>
<build>
<nagEmailAddress>palli@idega.com</nagEmailAddress>
<sourceDirectory>src/java</sourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.boxoffice</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.calendar</artifactId>
<version>3.1.3</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.category</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.contract</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.dataquery</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.datareport</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.documents</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.finance</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.pdf</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.poll</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.process.webservice</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.reports</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.rss</artifactId>
<version>3.1.12</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.school</artifactId>
<version>3.1.14</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.survey</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.text</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<!-- dependencies on commune -->
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov</artifactId>
<version>1.0.10</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.accounting</artifactId>
<version>1.0.22</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.school</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.afterschoolcare</artifactId>
<version>1.0.45</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.childcare</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.musicschool</artifactId>
<version>1.0.22</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.citizen</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.application</artifactId>
<version>1.0.12</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.message</artifactId>
<version>1.0.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.finances</artifactId>
<version>1.0.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.serviceoffer</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.schoolmeal</artifactId>
<version>1.0.34</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases</artifactId>
<version>1.0.28</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases.onesystem</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor.vefthjonusta</artifactId>
<version>1.1.5</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus.svarbox</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.idegaweb</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.ldap</artifactId>
<version>3.1.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.cal</artifactId>
<version>3.1.6</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.member</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.questions</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
</dependencies>
</project>
|
idega/sunnan3
|
29030ccd78bf522d7e6adccf905caa24cfd85bd7
|
[maven-scm-plugin] prepare release 3.1.1
|
diff --git a/project.xml b/project.xml
index 0ad9e28..7523db0 100644
--- a/project.xml
+++ b/project.xml
@@ -1,324 +1,329 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<pomVersion>3</pomVersion>
<extend>${idegaweb.application.egov.project.dir}/project.xml</extend>
<name>sunnan3</name>
<groupId>iw-applications</groupId>
<artifactId>sunnan3</artifactId>
<currentVersion>3.1.1</currentVersion>
<inceptionYear>2007</inceptionYear>
<shortDescription>This is the eGov Application of idegaWeb for the Sunnan3 project</shortDescription>
<versions>
<version>
<id>3.1.0</id>
<name>3.1.0</name>
<tag>SUNNAN3_3_1_0</tag>
</version>
+ <version>
+ <id>3.1.1</id>
+ <name>3.1.1</name>
+ <tag>SUNNAN3_3_1_1</tag>
+ </version>
</versions>
<branches/>
<developers>
<developer>
<name>Pall Helgason</name>
<id>palli</id>
<email>palli@idega.is</email>
<organization>idega software</organization>
<roles/>
</developer>
</developers>
<build>
<nagEmailAddress>palli@idega.com</nagEmailAddress>
<sourceDirectory>src/java</sourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.boxoffice</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.calendar</artifactId>
<version>3.1.3</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.category</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.contract</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.dataquery</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.datareport</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.documents</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.finance</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.pdf</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.poll</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.process.webservice</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.reports</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.rss</artifactId>
<version>3.1.12</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.school</artifactId>
<version>3.1.14</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.survey</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.text</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<!-- dependencies on commune -->
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov</artifactId>
<version>1.0.10</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.accounting</artifactId>
<version>1.0.22</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.school</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.afterschoolcare</artifactId>
<version>1.0.44</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.childcare</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.musicschool</artifactId>
<version>1.0.22</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.citizen</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.application</artifactId>
<version>1.0.12</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.message</artifactId>
<version>1.0.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.finances</artifactId>
<version>1.0.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.serviceoffer</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.schoolmeal</artifactId>
<version>1.0.34</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases</artifactId>
<version>1.0.28</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases.onesystem</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor.vefthjonusta</artifactId>
<version>1.1.5</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus.svarbox</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.idegaweb</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.ldap</artifactId>
<version>3.1.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.cal</artifactId>
<version>3.1.6</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.member</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.questions</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
</dependencies>
</project>
|
idega/sunnan3
|
ed135772bb1914ec5c751b619078e5742bc2e699
|
Fix for afterschoolcare and new version of sunnan3
|
diff --git a/project.xml b/project.xml
index a616972..0ad9e28 100644
--- a/project.xml
+++ b/project.xml
@@ -1,324 +1,324 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<pomVersion>3</pomVersion>
<extend>${idegaweb.application.egov.project.dir}/project.xml</extend>
<name>sunnan3</name>
<groupId>iw-applications</groupId>
<artifactId>sunnan3</artifactId>
- <currentVersion>3.1.0</currentVersion>
+ <currentVersion>3.1.1</currentVersion>
<inceptionYear>2007</inceptionYear>
<shortDescription>This is the eGov Application of idegaWeb for the Sunnan3 project</shortDescription>
<versions>
<version>
<id>3.1.0</id>
<name>3.1.0</name>
<tag>SUNNAN3_3_1_0</tag>
</version>
</versions>
<branches/>
<developers>
<developer>
<name>Pall Helgason</name>
<id>palli</id>
<email>palli@idega.is</email>
<organization>idega software</organization>
<roles/>
</developer>
</developers>
<build>
<nagEmailAddress>palli@idega.com</nagEmailAddress>
<sourceDirectory>src/java</sourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.boxoffice</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.calendar</artifactId>
<version>3.1.3</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.category</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.contract</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.dataquery</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.datareport</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.documents</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.finance</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.pdf</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.poll</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.process.webservice</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.reports</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.rss</artifactId>
<version>3.1.12</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.school</artifactId>
<version>3.1.14</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.survey</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.text</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<!-- dependencies on commune -->
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov</artifactId>
<version>1.0.10</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.accounting</artifactId>
<version>1.0.22</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.school</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.afterschoolcare</artifactId>
- <version>1.0.43</version>
+ <version>1.0.44</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.childcare</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.musicschool</artifactId>
<version>1.0.22</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.citizen</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.application</artifactId>
<version>1.0.12</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.message</artifactId>
<version>1.0.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.finances</artifactId>
<version>1.0.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.serviceoffer</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.schoolmeal</artifactId>
<version>1.0.34</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases</artifactId>
<version>1.0.28</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases.onesystem</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor.vefthjonusta</artifactId>
<version>1.1.5</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus.svarbox</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.idegaweb</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.ldap</artifactId>
<version>3.1.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.cal</artifactId>
<version>3.1.6</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.member</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.questions</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
</dependencies>
</project>
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index 2a1379b..db7fd9d 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -1,11 +1,17 @@
<document>
<properties>
<title>eGov Sunnan3 Changes</title>
<author email="palli@idega.com">Pall Helgason</author>
</properties>
<body>
+ <release version="3.1.1" date="2007-05-25">
+ <action dev="palli" type="update">
+ Updated afterschoolcare to fix check for mobile phone in printout.
+ </action>
+ </release>
+
<release version="3.1.0" date="2007-02-27">
<action dev="palli" type="update">New version for platform version 3.1.0</action>
</release>
</body>
</document>
\ No newline at end of file
|
idega/sunnan3
|
35fb13fce55673e74d0398ad6fa4955d33fded47
|
[maven-scm-plugin] prepare release 3.1.0
|
diff --git a/project.xml b/project.xml
index 14fb860..a616972 100644
--- a/project.xml
+++ b/project.xml
@@ -1,322 +1,324 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
- <pomVersion>3</pomVersion>
- <extend>${idegaweb.application.egov.project.dir}/project.xml</extend>
- <name>sunnan3</name>
- <groupId>iw-applications</groupId>
- <artifactId>sunnan3</artifactId>
- <currentVersion>3.1.0</currentVersion>
- <inceptionYear>2007</inceptionYear>
- <shortDescription>
- This is the eGov Application of idegaWeb for the Sunnan3 project
- </shortDescription>
- <versions>
- </versions>
- <branches />
- <developers>
- <developer>
- <name>Pall Helgason</name>
- <id>palli</id>
- <email>palli@idega.is</email>
- <organization>idega software</organization>
- <roles />
- </developer>
- </developers>
- <build>
- <nagEmailAddress>palli@idega.com</nagEmailAddress>
- <sourceDirectory>src/java</sourceDirectory>
- </build>
- <dependencies>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.boxoffice</artifactId>
- <version>3.1.1</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.calendar</artifactId>
- <version>3.1.3</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.category</artifactId>
- <version>3.1.2</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.contract</artifactId>
- <version>3.1.1</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.dataquery</artifactId>
- <version>3.1.2</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.datareport</artifactId>
- <version>3.1.2</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.documents</artifactId>
- <version>3.1.1</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.finance</artifactId>
- <version>3.1.2</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.pdf</artifactId>
- <version>3.1.1</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.poll</artifactId>
- <version>3.1.2</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.process.webservice</artifactId>
- <version>3.1.2</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.reports</artifactId>
- <version>3.1.1</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.rss</artifactId>
- <version>3.1.12</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.school</artifactId>
- <version>3.1.14</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.survey</artifactId>
- <version>3.1.1</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.text</artifactId>
- <version>3.1.2</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <!-- dependencies on commune -->
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.egov</artifactId>
- <version>1.0.10</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.egov.accounting</artifactId>
- <version>1.0.22</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.egov.school</artifactId>
- <version>1.0.17</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>
- is.idega.idegaweb.egov.afterschoolcare
- </artifactId>
- <version>1.0.43</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.egov.childcare</artifactId>
- <version>1.0.17</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.egov.musicschool</artifactId>
- <version>1.0.22</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.egov.citizen</artifactId>
- <version>1.0.17</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.egov.application</artifactId>
- <version>1.0.12</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.egov.message</artifactId>
- <version>1.0.1</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.egov.finances</artifactId>
- <version>1.0.2</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.egov.serviceoffer</artifactId>
- <version>1.0.4</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.egov.schoolmeal</artifactId>
- <version>1.0.34</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.egov.cases</artifactId>
- <version>1.0.28</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.egov.cases.onesystem</artifactId>
- <version>1.0.4</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.weather</artifactId>
- <version>3.1.1</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.block.weather</artifactId>
- <version>3.1.1</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.mentor</artifactId>
- <version>3.1.1</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.mentor.vefthjonusta</artifactId>
- <version>1.1.5</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.block.modernus.svarbox</artifactId>
- <version>3.1.2</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.block.modernus</artifactId>
- <version>3.1.2</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.idegaweb</artifactId>
- <version>3.1.1</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.ldap</artifactId>
- <version>3.1.4</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.cal</artifactId>
- <version>3.1.6</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>is.idega.idegaweb.member</artifactId>
- <version>3.1.1</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- <dependency>
- <groupId>bundles</groupId>
- <artifactId>com.idega.block.questions</artifactId>
- <version>3.1.1</version>
- <type>iwbar</type>
- <url>http://www.idega.com</url>
- </dependency>
- </dependencies>
+ <pomVersion>3</pomVersion>
+ <extend>${idegaweb.application.egov.project.dir}/project.xml</extend>
+ <name>sunnan3</name>
+ <groupId>iw-applications</groupId>
+ <artifactId>sunnan3</artifactId>
+ <currentVersion>3.1.0</currentVersion>
+ <inceptionYear>2007</inceptionYear>
+ <shortDescription>This is the eGov Application of idegaWeb for the Sunnan3 project</shortDescription>
+ <versions>
+ <version>
+ <id>3.1.0</id>
+ <name>3.1.0</name>
+ <tag>SUNNAN3_3_1_0</tag>
+ </version>
+ </versions>
+ <branches/>
+ <developers>
+ <developer>
+ <name>Pall Helgason</name>
+ <id>palli</id>
+ <email>palli@idega.is</email>
+ <organization>idega software</organization>
+ <roles/>
+ </developer>
+ </developers>
+ <build>
+ <nagEmailAddress>palli@idega.com</nagEmailAddress>
+ <sourceDirectory>src/java</sourceDirectory>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.boxoffice</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.calendar</artifactId>
+ <version>3.1.3</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.category</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.contract</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.dataquery</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.datareport</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.documents</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.finance</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.pdf</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.poll</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.process.webservice</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.reports</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.rss</artifactId>
+ <version>3.1.12</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.school</artifactId>
+ <version>3.1.14</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.survey</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.text</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <!-- dependencies on commune -->
+
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov</artifactId>
+ <version>1.0.10</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.accounting</artifactId>
+ <version>1.0.22</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.school</artifactId>
+ <version>1.0.17</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.afterschoolcare</artifactId>
+ <version>1.0.43</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.childcare</artifactId>
+ <version>1.0.17</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.musicschool</artifactId>
+ <version>1.0.22</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.citizen</artifactId>
+ <version>1.0.17</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.application</artifactId>
+ <version>1.0.12</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.message</artifactId>
+ <version>1.0.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.finances</artifactId>
+ <version>1.0.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.serviceoffer</artifactId>
+ <version>1.0.4</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.schoolmeal</artifactId>
+ <version>1.0.34</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.cases</artifactId>
+ <version>1.0.28</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.cases.onesystem</artifactId>
+ <version>1.0.4</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.weather</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.block.weather</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.mentor</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.mentor.vefthjonusta</artifactId>
+ <version>1.1.5</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.block.modernus.svarbox</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.block.modernus</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.idegaweb</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.ldap</artifactId>
+ <version>3.1.4</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.cal</artifactId>
+ <version>3.1.6</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.member</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.questions</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ </dependencies>
</project>
|
idega/sunnan3
|
fbbbedbf3cd0ee14e7993059dcc32600e6b2deb8
|
Trying to get this to compile on the build server
|
diff --git a/project.xml b/project.xml
index fe46163..14fb860 100644
--- a/project.xml
+++ b/project.xml
@@ -1,324 +1,322 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<pomVersion>3</pomVersion>
- <extend>
- ${idegaweb.application.egov.project.dir}/project.xml
- </extend>
+ <extend>${idegaweb.application.egov.project.dir}/project.xml</extend>
<name>sunnan3</name>
<groupId>iw-applications</groupId>
<artifactId>sunnan3</artifactId>
<currentVersion>3.1.0</currentVersion>
<inceptionYear>2007</inceptionYear>
<shortDescription>
This is the eGov Application of idegaWeb for the Sunnan3 project
</shortDescription>
<versions>
</versions>
<branches />
<developers>
<developer>
<name>Pall Helgason</name>
<id>palli</id>
<email>palli@idega.is</email>
<organization>idega software</organization>
<roles />
</developer>
</developers>
<build>
<nagEmailAddress>palli@idega.com</nagEmailAddress>
<sourceDirectory>src/java</sourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.boxoffice</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.calendar</artifactId>
<version>3.1.3</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.category</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.contract</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.dataquery</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.datareport</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.documents</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.finance</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.pdf</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.poll</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.process.webservice</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.reports</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.rss</artifactId>
<version>3.1.12</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.school</artifactId>
<version>3.1.14</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.survey</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.text</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<!-- dependencies on commune -->
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov</artifactId>
<version>1.0.10</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.accounting</artifactId>
<version>1.0.22</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.school</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>
is.idega.idegaweb.egov.afterschoolcare
</artifactId>
<version>1.0.43</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.childcare</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.musicschool</artifactId>
<version>1.0.22</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.citizen</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.application</artifactId>
<version>1.0.12</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.message</artifactId>
<version>1.0.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.finances</artifactId>
<version>1.0.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.serviceoffer</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.schoolmeal</artifactId>
<version>1.0.34</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases</artifactId>
<version>1.0.28</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases.onesystem</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor.vefthjonusta</artifactId>
<version>1.1.5</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus.svarbox</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.idegaweb</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.ldap</artifactId>
<version>3.1.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.cal</artifactId>
<version>3.1.6</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.member</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.questions</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
</dependencies>
</project>
|
idega/sunnan3
|
3487cdb0141718b467e34a7720ab9cf62de129ea
|
fixed version
|
diff --git a/project.xml b/project.xml
index 9382471..fe46163 100644
--- a/project.xml
+++ b/project.xml
@@ -1,329 +1,324 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<pomVersion>3</pomVersion>
<extend>
${idegaweb.application.egov.project.dir}/project.xml
</extend>
<name>sunnan3</name>
<groupId>iw-applications</groupId>
<artifactId>sunnan3</artifactId>
<currentVersion>3.1.0</currentVersion>
<inceptionYear>2007</inceptionYear>
<shortDescription>
This is the eGov Application of idegaWeb for the Sunnan3 project
</shortDescription>
<versions>
- <version>
- <id>3.1.0</id>
- <name>3.1.0</name>
- <tag>SUNNAN3_3_1_0</tag>
- </version>
</versions>
<branches />
<developers>
<developer>
<name>Pall Helgason</name>
<id>palli</id>
<email>palli@idega.is</email>
<organization>idega software</organization>
<roles />
</developer>
</developers>
<build>
<nagEmailAddress>palli@idega.com</nagEmailAddress>
<sourceDirectory>src/java</sourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.boxoffice</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.calendar</artifactId>
<version>3.1.3</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.category</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.contract</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.dataquery</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.datareport</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.documents</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.finance</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.pdf</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.poll</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.process.webservice</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.reports</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.rss</artifactId>
<version>3.1.12</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.school</artifactId>
<version>3.1.14</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.survey</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.text</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<!-- dependencies on commune -->
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov</artifactId>
<version>1.0.10</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.accounting</artifactId>
<version>1.0.22</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.school</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>
is.idega.idegaweb.egov.afterschoolcare
</artifactId>
<version>1.0.43</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.childcare</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.musicschool</artifactId>
<version>1.0.22</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.citizen</artifactId>
<version>1.0.17</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.application</artifactId>
<version>1.0.12</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.message</artifactId>
<version>1.0.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.finances</artifactId>
<version>1.0.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.serviceoffer</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.schoolmeal</artifactId>
<version>1.0.34</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases</artifactId>
<version>1.0.28</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.egov.cases.onesystem</artifactId>
<version>1.0.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.weather</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.mentor.vefthjonusta</artifactId>
<version>1.1.5</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus.svarbox</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.block.modernus</artifactId>
<version>3.1.2</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.idegaweb</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.ldap</artifactId>
<version>3.1.4</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.cal</artifactId>
<version>3.1.6</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>is.idega.idegaweb.member</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
<dependency>
<groupId>bundles</groupId>
<artifactId>com.idega.block.questions</artifactId>
<version>3.1.1</version>
<type>iwbar</type>
<url>http://www.idega.com</url>
</dependency>
</dependencies>
</project>
|
idega/sunnan3
|
12dcb12bdbadf5a125094b9f6d7f9552048b5d48
|
New application for sunnan3
|
diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..89d79b3
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes">
+ </classpathentry>
+</classpath>
\ No newline at end of file
diff --git a/.cvsignore b/.cvsignore
new file mode 100644
index 0000000..eb5a316
--- /dev/null
+++ b/.cvsignore
@@ -0,0 +1 @@
+target
diff --git a/.project b/.project
new file mode 100644
index 0000000..7417449
--- /dev/null
+++ b/.project
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<projectDescription>
+ <name>sunnan3</name>
+ <comment>This is the standard package of the idegaWeb ePlatform Application</comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
diff --git a/WEB-INF/classes/log4j.properties b/WEB-INF/classes/log4j.properties
new file mode 100644
index 0000000..fd6f4d7
--- /dev/null
+++ b/WEB-INF/classes/log4j.properties
@@ -0,0 +1,31 @@
+#Property file for log4j. Needs to be put to classpath for eclipse or in WEB-INF/classes for tomcat outside of eclipse.
+#The log level is set to WARN here but can also be set to OFF or FATAL and more. To set log level fore package the
+#syntax is log4j.category.'package'='loglevel'.
+log4j.rootCategory=WARN,stdout,R
+
+# Set the level to DEBUG if you want to log all SlideExceptions (some of them aren't errors)
+log4j.category.org.apache.slide.common.SlideException=FATAL
+
+########################################
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Pattern to output the caller's file name and line number.
+#log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
+#log4j.appender.stdout.layout.ConversionPattern=%4p [%t] %c - %m%n
+log4j.appender.stdout.layout.ConversionPattern=[%t] %-5p %-20c{2} - %m %n
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=slide.log
+
+log4j.appender.R.ImmediateFlush=true
+
+log4j.appender.R.MaxFileSize=100KB
+# Keep one backup file
+log4j.appender.R.MaxBackupIndex=1
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+#log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
+#log4j.appender.R.layout.ConversionPattern=%4p [%t] %c - %m%n
+log4j.appender.R.layout.ConversionPattern=%d{ABSOLUTE} [%t] %-5p %-30c{3} %x - %m %n
+
diff --git a/WEB-INF/idegaweb/databases/dir_for_databases b/WEB-INF/idegaweb/databases/dir_for_databases
new file mode 100644
index 0000000..e69de29
diff --git a/WEB-INF/idegaweb/properties/db.properties b/WEB-INF/idegaweb/properties/db.properties
new file mode 100644
index 0000000..9cc05ad
--- /dev/null
+++ b/WEB-INF/idegaweb/properties/db.properties
@@ -0,0 +1,13 @@
+drivers=org.hsqldb.jdbcDriver
+
+#default.url=jdbc:hsqldb:file:/tmp/hsqliw1
+#The {iw_bundles_path} variable is resolved when the IWMainApplication
+#starts and initializes the PoolManager
+#default.url=jdbc:hsqldb:file:/{iw_bundles_path}/net.sourceforge.hsqldb.bundle/databases/iw1
+default.url=jdbc:hsqldb:file:/{iw_application_path}/WEB-INF/idegaweb/databases/iw1
+default.user=sa
+default.password=
+default.initconns=2
+default.maxconns=20
+#default.loglevel=debug
+
diff --git a/WEB-INF/idegaweb/properties/db.properties.oracle b/WEB-INF/idegaweb/properties/db.properties.oracle
new file mode 100644
index 0000000..25b00cf
--- /dev/null
+++ b/WEB-INF/idegaweb/properties/db.properties.oracle
@@ -0,0 +1,9 @@
+drivers=oracle.jdbc.driver.OracleDriver
+
+default.url=jdbc:oracle:thin:@localhost:1521:testdb
+#default.url=jdbc:oracle:oci:@(description=(address=(host=testdb)(protocol=tcp)(port=1521))(connect_data=(sid=testdb)))
+default.user=system
+default.password=enterpassword
+default.initconns=3
+default.maxconns=10
+
diff --git a/WEB-INF/idegaweb/properties/idegaweb.pxml b/WEB-INF/idegaweb/properties/idegaweb.pxml
new file mode 100644
index 0000000..f461c5a
--- /dev/null
+++ b/WEB-INF/idegaweb/properties/idegaweb.pxml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<pxml>
+ <map>
+ <key>
+ <name>defaultlocale</name>
+ <type>java.lang.String</type>
+ <value>is_IS</value>
+ </key>
+ <key>
+ <name>entity-auto-create</name>
+ <type>java.lang.Boolean</type>
+ <value>true</value>
+ </key>
+ <key>
+ <name>iw_accesscontrol_type</name>
+ <type>java.lang.String</type>
+ <value>iw</value>
+ </key>
+ <key>
+ <name>auto-create-localized-strings</name>
+ <type>java.lang.Boolean</type>
+ <value>true</value>
+ </key>
+ <key>
+ <name>debug</name>
+ <type>java.lang.Boolean</type>
+ <value>false</value>
+ </key>
+ <key>
+ <name>auto-create-properties</name>
+ <type>java.lang.Boolean</type>
+ <value>true</value>
+ </key>
+ <key>
+ <name>ido_entity_bean_caching</name>
+ <type>java.lang.Boolean</type>
+ <value>false</value>
+ </key>
+ <key>
+ <name>ido_entity_query_caching</name>
+ <type>java.lang.Boolean</type>
+ <value>false</value>
+ </key>
+ <key>
+ <name>markup_language</name>
+ <type>java.lang.String</type>
+ <value>XHTML</value>
+ </key>
+ <key>
+ <name>character_encoding</name>
+ <type>java.lang.String</type>
+ <value>UTF-8</value>
+ </key>
+ <key>
+ <name>new_url_structure</name>
+ <type>java.lang.String</type>
+ <value>true</value>
+ </key>
+ <key>
+ <name>jsf_rendering</name>
+ <type>java.lang.String</type>
+ <value>true</value>
+ </key>
+ <key>
+ <name>write_bundle_files_on_shudown</name>
+ <type>java.lang.String</type>
+ <value>false</value>
+ </key>
+ <key>
+ <name>IW_STYLEMANAGER_WRITEFILE</name>
+ <type>java.lang.Boolean</type>
+ <value>false</value>
+ </key>
+ </map>
+</pxml>
+
diff --git a/WEB-INF/idegaweb/properties/product.properties b/WEB-INF/idegaweb/properties/product.properties
new file mode 100644
index 0000000..282bcda
--- /dev/null
+++ b/WEB-INF/idegaweb/properties/product.properties
@@ -0,0 +1,7 @@
+#Properties of this application product
+#Thu Sep 01 23:32:18 GMT 2005
+application.product.inceptionyear=2007
+application.product.version=3.1.0
+application.product.build.id=20070320.102200
+application.product.vendor=
+application.product.name=eGov (sunnan3)
diff --git a/WEB-INF/idegaweb/properties/system_properties.pxml b/WEB-INF/idegaweb/properties/system_properties.pxml
new file mode 100644
index 0000000..588f3bf
--- /dev/null
+++ b/WEB-INF/idegaweb/properties/system_properties.pxml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<pxml>
+ <map>
+ <key>
+ <name>com.idega.core.editorwindow_styleSheet_path</name>
+ <type>java.lang.String</type>
+ <value>/idegaweb/bundles/com.idega.core.bundle/resources/editorwindow/</value>
+ </key>
+ </map>
+</pxml>
+
diff --git a/WEB-INF/web.xml b/WEB-INF/web.xml
new file mode 100644
index 0000000..99fbd7b
--- /dev/null
+++ b/WEB-INF/web.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE web-app
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+
+ <description>Skjalfandi eGov</description>
+ <display-name>Skjalfandi-eGov</display-name>
+
+<!-- MODULE:BEGIN org.apache.myfaces 0.0 -->
+<!-- MODULE:END org.apache.myfaces 0.0 -->
+
+<!-- MODULE:BEGIN com.idega.core 0.0 -->
+<!-- MODULE:END com.idega.core 0.0 -->
+
+<!-- MODULE:BEGIN com.idega.faces 0.0 -->
+<!-- MODULE:END com.idega.faces 0.0 -->
+
+<!-- MODULE:BEGIN org.apache.axis 0.0 -->
+<!-- MODULE:END org.apache.axis 0.0 -->
+
+</web-app>
diff --git a/idegaweb/style/style.css b/idegaweb/style/style.css
new file mode 100644
index 0000000..e69de29
diff --git a/project.xml b/project.xml
new file mode 100644
index 0000000..9382471
--- /dev/null
+++ b/project.xml
@@ -0,0 +1,329 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project>
+ <pomVersion>3</pomVersion>
+ <extend>
+ ${idegaweb.application.egov.project.dir}/project.xml
+ </extend>
+ <name>sunnan3</name>
+ <groupId>iw-applications</groupId>
+ <artifactId>sunnan3</artifactId>
+ <currentVersion>3.1.0</currentVersion>
+ <inceptionYear>2007</inceptionYear>
+ <shortDescription>
+ This is the eGov Application of idegaWeb for the Sunnan3 project
+ </shortDescription>
+ <versions>
+ <version>
+ <id>3.1.0</id>
+ <name>3.1.0</name>
+ <tag>SUNNAN3_3_1_0</tag>
+ </version>
+ </versions>
+ <branches />
+ <developers>
+ <developer>
+ <name>Pall Helgason</name>
+ <id>palli</id>
+ <email>palli@idega.is</email>
+ <organization>idega software</organization>
+ <roles />
+ </developer>
+ </developers>
+ <build>
+ <nagEmailAddress>palli@idega.com</nagEmailAddress>
+ <sourceDirectory>src/java</sourceDirectory>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.boxoffice</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.calendar</artifactId>
+ <version>3.1.3</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.category</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.contract</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.dataquery</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.datareport</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.documents</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.finance</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.pdf</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.poll</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.process.webservice</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.reports</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.rss</artifactId>
+ <version>3.1.12</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.school</artifactId>
+ <version>3.1.14</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.survey</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.text</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <!-- dependencies on commune -->
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov</artifactId>
+ <version>1.0.10</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.accounting</artifactId>
+ <version>1.0.22</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.school</artifactId>
+ <version>1.0.17</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>
+ is.idega.idegaweb.egov.afterschoolcare
+ </artifactId>
+ <version>1.0.43</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.childcare</artifactId>
+ <version>1.0.17</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.musicschool</artifactId>
+ <version>1.0.22</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.citizen</artifactId>
+ <version>1.0.17</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.application</artifactId>
+ <version>1.0.12</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.message</artifactId>
+ <version>1.0.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.finances</artifactId>
+ <version>1.0.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.serviceoffer</artifactId>
+ <version>1.0.4</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.schoolmeal</artifactId>
+ <version>1.0.34</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.cases</artifactId>
+ <version>1.0.28</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.egov.cases.onesystem</artifactId>
+ <version>1.0.4</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.weather</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.block.weather</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.mentor</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.mentor.vefthjonusta</artifactId>
+ <version>1.1.5</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.block.modernus.svarbox</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.block.modernus</artifactId>
+ <version>3.1.2</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.idegaweb</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.ldap</artifactId>
+ <version>3.1.4</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.cal</artifactId>
+ <version>3.1.6</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>is.idega.idegaweb.member</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ <dependency>
+ <groupId>bundles</groupId>
+ <artifactId>com.idega.block.questions</artifactId>
+ <version>3.1.1</version>
+ <type>iwbar</type>
+ <url>http://www.idega.com</url>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sunnan3.psf b/sunnan3.psf
new file mode 100644
index 0000000..3f24417
--- /dev/null
+++ b/sunnan3.psf
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<psf version="2.0">
+<provider id="org.eclipse.team.cvs.core.cvsnature">
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.boxoffice.bundle,com.idega.block.boxoffice"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.cal.bundle,com.idega.block.cal,BRANCH_PLATFORM_3_1"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.calendar.bundle,com.idega.block.calendar,BRANCH_PLATFORM_3_1"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.category.bundle,com.idega.block.category,BRANCH_PLATFORM_3_1"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.contract.bundle,com.idega.block.contract"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.dataquery.bundle,com.idega.block.dataquery"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.datareport.bundle,com.idega.block.datareport"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.documents.bundle,com.idega.block.documents"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.finance.bundle,com.idega.block.finance"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.ldap.bundle,com.idega.block.ldap"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.pdf.bundle,com.idega.block.pdf"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.poll.bundle,com.idega.block.poll"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.process.webservice.bundle,com.idega.block.process.webservice,BRANCH_PLATFORM_3_1"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.questions.bundle,com.idega.block.questions"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.reports.bundle,com.idega.block.reports"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.school.bundle,com.idega.block.school"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.survey.bundle,com.idega.block.survey"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.text.bundle,com.idega.block.text,BRANCH_PLATFORM_3_1"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.block.weather.bundle,com.idega.block.weather"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/com.idega.idegaweb.bundle,com.idega.idegaweb"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.block.modernus.bundle,is.idega.block.modernus"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.block.modernus.svarbox.bundle,is.idega.block.modernus.svarbox"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.block.weather.bundle,is.idega.block.weather"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.bundle,is.idega.idegaweb.egov"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.accounting.bundle,is.idega.idegaweb.egov.accounting"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.afterschoolcare.bundle,is.idega.idegaweb.egov.afterschoolcare"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.application.bundle,is.idega.idegaweb.egov.application,BRANCH_PLATFORM_3_1"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.cases.bundle,is.idega.idegaweb.egov.cases,BRANCH_PLATFORM_3_1"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.cases.onesystem.bundle,is.idega.idegaweb.egov.cases.onesystem"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.childcare.bundle,is.idega.idegaweb.egov.childcare"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.citizen.bundle,is.idega.idegaweb.egov.citizen"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.finances.bundle,is.idega.idegaweb.egov.finances"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.message.bundle,is.idega.idegaweb.egov.message"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.musicschool.bundle,is.idega.idegaweb.egov.musicschool"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.school.bundle,is.idega.idegaweb.egov.school"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.schoolmeal.bundle,is.idega.idegaweb.egov.schoolmeal"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.egov.serviceoffer.bundle,is.idega.idegaweb.egov.serviceoffer"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.idega.idegaweb.member.bundle,is.idega.idegaweb.member"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.mentor.bundle,is.mentor"/>
+<project reference="1.0,:extssh:code.idega.com:/idega/cvs,bundles/is.mentor.vefthjonusta.bundle,is.mentor.vefthjonusta"/>
+</provider>
+</psf>
\ No newline at end of file
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
new file mode 100644
index 0000000..2a1379b
--- /dev/null
+++ b/xdocs/changes.xml
@@ -0,0 +1,11 @@
+<document>
+ <properties>
+ <title>eGov Sunnan3 Changes</title>
+ <author email="palli@idega.com">Pall Helgason</author>
+ </properties>
+ <body>
+ <release version="3.1.0" date="2007-02-27">
+ <action dev="palli" type="update">New version for platform version 3.1.0</action>
+ </release>
+ </body>
+</document>
\ No newline at end of file
|
youpy/scissor-echonest
|
2ea26adc06ae3def7de2cc4a6cb6191a95ac8d85
|
depend on Scissor v0.2.3 or higher
|
diff --git a/Rakefile b/Rakefile
index a218134..981588e 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,110 +1,110 @@
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/contrib/rubyforgepublisher'
require 'rake/contrib/sshpublisher'
require 'spec/rake/spectask'
require 'fileutils'
include FileUtils
$LOAD_PATH.unshift "lib"
require "scissor/echonest"
NAME = "scissor-echonest"
AUTHOR = "youpy"
EMAIL = "youpy@buycheapviagraonlinenow.com"
DESCRIPTION = "Scissor extension to use Echo Nest Developers API"
RUBYFORGE_PROJECT = "scissorechonest"
HOMEPATH = "http://github.com/youpy/scissor-echonest"
BIN_FILES = %w( )
-VERS = "0.1.0"
+VERS = "0.1.1"
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
RDOC_OPTS = [
'--title', "#{NAME} documentation",
"--charset", "utf-8",
"--opname", "index.html",
"--line-numbers",
"--main", "README.rdoc",
"--inline-source",
]
task :default => [:spec]
task :package => [:clean]
Spec::Rake::SpecTask.new do |t|
t.spec_opts = ['--options', "spec/spec.opts"]
t.spec_files = FileList['spec/*_spec.rb']
t.rcov = true
end
spec = Gem::Specification.new do |s|
s.name = NAME
s.version = VERS
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
s.summary = DESCRIPTION
s.description = DESCRIPTION
s.author = AUTHOR
s.email = EMAIL
s.homepage = HOMEPATH
s.executables = BIN_FILES
s.rubyforge_project = RUBYFORGE_PROJECT
s.bindir = "bin"
s.require_path = "lib"
s.test_files = Dir["test/test_*.rb"]
- s.add_dependency('scissor', '>=0.0.22')
+ s.add_dependency('scissor', '>=0.2.3')
s.add_dependency('ruby-echonest', '>=0.1.1')
#s.required_ruby_version = '>= 1.8.2'
s.files = %w(README.rdoc ChangeLog Rakefile) +
Dir.glob("{bin,doc,spec,test,lib,templates,generator,extras,website,script}/**/*") +
Dir.glob("ext/**/*.{h,c,rb}") +
Dir.glob("examples/**/*.rb") +
Dir.glob("tools/*.rb")
s.extensions = FileList["ext/**/extconf.rb"].to_a
end
Rake::GemPackageTask.new(spec) do |p|
p.need_tar = true
p.gem_spec = spec
end
task :install do
name = "#{NAME}-#{VERS}.gem"
sh %{rake package}
sh %{sudo gem install pkg/#{name}}
end
task :uninstall => [:clean] do
sh %{sudo gem uninstall #{NAME}}
end
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'html'
rdoc.options += RDOC_OPTS
rdoc.template = "resh"
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
if ENV['DOC_FILES']
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
else
rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.include('ext/**/*.c')
end
end
desc "Show information about the gem"
task :debug_gem do
puts spec.to_ruby
end
diff --git a/lib/scissor/echonest.rb b/lib/scissor/echonest.rb
index 5c5d15a..1537501 100644
--- a/lib/scissor/echonest.rb
+++ b/lib/scissor/echonest.rb
@@ -1,77 +1,77 @@
require 'scissor'
require 'echonest'
-require 'scissor/echonest/chunk_ext.rb'
+require 'scissor/echonest/tape_ext.rb'
module Scissor
def self.echonest_api_key=(echonest_api_key)
- Scissor::Chunk.echonest_api_key = echonest_api_key
+ Scissor::Tape.echonest_api_key = echonest_api_key
end
- class Chunk
+ class Tape
class << self
attr_accessor :echonest_api_key
def echonest
@echonest ||= Echonest(echonest_api_key)
end
end
def bars
analyze do |analysis|
bars = analysis.bars
- bars.inject([]) do |chunks, bar|
- chunk = self[bar.start, bar.duration]
- chunk.set_delegate(bar)
- chunks << chunk
- chunks
+ bars.inject([]) do |tapes, bar|
+ tape = self[bar.start, bar.duration]
+ tape.set_delegate(bar)
+ tapes << tape
+ tapes
end
end
end
def beats
analyze do |analysis|
- chunks = []
+ tapes = []
beats = analysis.beats
if beats.size != 0
- chunk = self[0, beats.first.start]
+ tape = self[0, beats.first.start]
beat = Beat.new(0.0, beats.first.start, 1.0)
- chunk.set_delegate(beat)
- chunks << chunk
+ tape.set_delegate(beat)
+ tapes << tape
end
beats.inject do |m, beat|
- chunk = self[m.start, beat.start - m.start]
- chunk.set_delegate(m)
- chunks << chunk
+ tape = self[m.start, beat.start - m.start]
+ tape.set_delegate(m)
+ tapes << tape
beat
end
- chunks
+ tapes
end
end
def segments
analyze do |analysis|
segments = analysis.segments
- segments.inject([]) do |chunks, segment|
- chunk = self[segment.start, segment.duration]
- chunk.set_delegate(segment)
- chunks << chunk
- chunks
+ segments.inject([]) do |tapes, segment|
+ tape = self[segment.start, segment.duration]
+ tape.set_delegate(segment)
+ tapes << tape
+ tapes
end
end
end
private
def analyze
tmpfile = Pathname.new('/tmp/scissor_echonest_temp_' + $$.to_s + '.mp3')
scissor = to_file(tmpfile, :bitrate => '64k')
yield self.class.echonest.track.analysis(tmpfile)
ensure
tmpfile.unlink if tmpfile.exist?
end
end
end
diff --git a/lib/scissor/echonest/chunk_ext.rb b/lib/scissor/echonest/tape_ext.rb
similarity index 93%
rename from lib/scissor/echonest/chunk_ext.rb
rename to lib/scissor/echonest/tape_ext.rb
index a54a461..577abd1 100644
--- a/lib/scissor/echonest/chunk_ext.rb
+++ b/lib/scissor/echonest/tape_ext.rb
@@ -1,11 +1,11 @@
module Scissor
- class Chunk
+ class Tape
def set_delegate(delegate)
@delegate = delegate
end
def method_missing(name, *args, &block)
@delegate.send(name, *args, &block)
end
end
end
diff --git a/spec/scissor-echonest_spec.rb b/spec/scissor-echonest_spec.rb
index c281ed5..f407159 100755
--- a/spec/scissor-echonest_spec.rb
+++ b/spec/scissor-echonest_spec.rb
@@ -1,81 +1,81 @@
$:.unshift File.dirname(__FILE__)
require 'spec_helper'
include SpecHelper
describe Scissor do
it 'should set Echo Nest API key' do
Scissor.echonest_api_key = 'XXX'
- Scissor::Chunk.echonest_api_key.should eql('XXX')
+ Scissor::Tape.echonest_api_key.should eql('XXX')
end
it 'should get an instance of EchoNest::Api' do
Scissor.echonest_api_key = 'XXX'
- echonest = Scissor::Chunk.echonest
+ echonest = Scissor::Tape.echonest
echonest.user_agent.send_timeout = 300
echonest.should be_an_instance_of(Echonest::Api)
- Scissor::Chunk.echonest.user_agent.send_timeout.should eql(300)
+ Scissor::Tape.echonest.user_agent.send_timeout.should eql(300)
end
describe 'analysis' do |object|
before do
Scissor.echonest_api_key = 'XXX'
api = Echonest::Api.new('XXX')
track_methods = Echonest::ApiMethods::Track.new(api)
api.stub!(:track).and_return(track_methods)
track_methods.stub!(:analysis).and_return(Echonest::Analysis.new(open(fixture('analysis.json')).read))
@scissor = Scissor(fixture('sample.mp3'))
- Scissor::Chunk.stub!(:echonest).and_return(api)
+ Scissor::Tape.stub!(:echonest).and_return(api)
end
it 'should get bars' do
bars = @scissor.bars
bar = bars.first
bars.size.should eql(80)
bar.start.should be_close(1.0, 0.1)
bar.duration.should be_close(1.48, 0.01)
bar.confidence.should be_close(0.18, 0.01)
end
it 'should get beats' do
beats = @scissor.beats
beats.size.should eql(324)
- beats[0].should be_an_instance_of(Scissor::Chunk)
+ beats[0].should be_an_instance_of(Scissor::Tape)
beats[0].start.should eql(0.0)
beats[0].duration.should eql(0.27661)
beats[0].fragments.first.filename.should eql(fixture('sample.mp3'))
beats[0].confidence.should eql(1.0)
- beats[1].should be_an_instance_of(Scissor::Chunk)
+ beats[1].should be_an_instance_of(Scissor::Tape)
beats[1].start.should eql(0.27661)
beats[1].duration.should eql(0.36476)
beats[1].fragments.first.filename.should eql(fixture('sample.mp3'))
beats[1].confidence.should eql(0.468)
end
it 'should get segments' do
segments = @scissor.segments
segment = segments.first
segments.size.should eql(274)
segment.start.should eql(0.0)
segment.duration.should eql(0.43909)
segment.confidence.should eql(1.0)
segment.loudness.time.should eql(0.0)
segment.loudness.value.should eql(-60.0)
segment.max_loudness.time.should eql(0.11238)
segment.max_loudness.value.should eql(-33.563)
segment.pitches.size.should eql(12)
segment.pitches.first.should eql(0.138)
segment.timbre.size.should eql(12)
segment.timbre.first.should eql(11.525)
end
end
end
|
youpy/scissor-echonest
|
bb30a39d668b9cf290e464856277d4a1853095d1
|
version bunp to 0.1.0
|
diff --git a/Rakefile b/Rakefile
index 065434e..a218134 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,110 +1,110 @@
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/contrib/rubyforgepublisher'
require 'rake/contrib/sshpublisher'
require 'spec/rake/spectask'
require 'fileutils'
include FileUtils
$LOAD_PATH.unshift "lib"
require "scissor/echonest"
NAME = "scissor-echonest"
AUTHOR = "youpy"
EMAIL = "youpy@buycheapviagraonlinenow.com"
DESCRIPTION = "Scissor extension to use Echo Nest Developers API"
RUBYFORGE_PROJECT = "scissorechonest"
HOMEPATH = "http://github.com/youpy/scissor-echonest"
BIN_FILES = %w( )
-VERS = "0.0.8"
+VERS = "0.1.0"
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
RDOC_OPTS = [
'--title', "#{NAME} documentation",
"--charset", "utf-8",
"--opname", "index.html",
"--line-numbers",
"--main", "README.rdoc",
"--inline-source",
]
task :default => [:spec]
task :package => [:clean]
Spec::Rake::SpecTask.new do |t|
t.spec_opts = ['--options', "spec/spec.opts"]
t.spec_files = FileList['spec/*_spec.rb']
t.rcov = true
end
spec = Gem::Specification.new do |s|
s.name = NAME
s.version = VERS
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
s.summary = DESCRIPTION
s.description = DESCRIPTION
s.author = AUTHOR
s.email = EMAIL
s.homepage = HOMEPATH
s.executables = BIN_FILES
s.rubyforge_project = RUBYFORGE_PROJECT
s.bindir = "bin"
s.require_path = "lib"
s.test_files = Dir["test/test_*.rb"]
s.add_dependency('scissor', '>=0.0.22')
s.add_dependency('ruby-echonest', '>=0.1.1')
#s.required_ruby_version = '>= 1.8.2'
s.files = %w(README.rdoc ChangeLog Rakefile) +
Dir.glob("{bin,doc,spec,test,lib,templates,generator,extras,website,script}/**/*") +
Dir.glob("ext/**/*.{h,c,rb}") +
Dir.glob("examples/**/*.rb") +
Dir.glob("tools/*.rb")
s.extensions = FileList["ext/**/extconf.rb"].to_a
end
Rake::GemPackageTask.new(spec) do |p|
p.need_tar = true
p.gem_spec = spec
end
task :install do
name = "#{NAME}-#{VERS}.gem"
sh %{rake package}
sh %{sudo gem install pkg/#{name}}
end
task :uninstall => [:clean] do
sh %{sudo gem uninstall #{NAME}}
end
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'html'
rdoc.options += RDOC_OPTS
rdoc.template = "resh"
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
if ENV['DOC_FILES']
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
else
rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.include('ext/**/*.c')
end
end
desc "Show information about the gem"
task :debug_gem do
puts spec.to_ruby
end
|
youpy/scissor-echonest
|
831b6b5e887ce5ee9f70ac654ae6221fc1fc364f
|
add Scissor::Chunk#bars
|
diff --git a/lib/scissor/echonest.rb b/lib/scissor/echonest.rb
index 333df1f..5c5d15a 100644
--- a/lib/scissor/echonest.rb
+++ b/lib/scissor/echonest.rb
@@ -1,82 +1,77 @@
require 'scissor'
require 'echonest'
require 'scissor/echonest/chunk_ext.rb'
module Scissor
def self.echonest_api_key=(echonest_api_key)
Scissor::Chunk.echonest_api_key = echonest_api_key
end
class Chunk
class << self
attr_accessor :echonest_api_key
def echonest
@echonest ||= Echonest(echonest_api_key)
end
end
def bars
- tempfile_for_echonest do |tmpfile|
- chunks = []
- scissor = to_file(tmpfile, :bitrate => '64k')
-
- bars = self.class.echonest.get_bars(tmpfile)
+ analyze do |analysis|
+ bars = analysis.bars
bars.inject([]) do |chunks, bar|
chunk = self[bar.start, bar.duration]
chunk.set_delegate(bar)
chunks << chunk
chunks
end
end
end
def beats
- tempfile_for_echonest do |tmpfile|
+ analyze do |analysis|
chunks = []
- scissor = to_file(tmpfile, :bitrate => '64k')
-
- beats = self.class.echonest.get_beats(tmpfile)
+ beats = analysis.beats
if beats.size != 0
chunk = self[0, beats.first.start]
beat = Beat.new(0.0, beats.first.start, 1.0)
chunk.set_delegate(beat)
chunks << chunk
end
beats.inject do |m, beat|
chunk = self[m.start, beat.start - m.start]
chunk.set_delegate(m)
chunks << chunk
beat
end
chunks
end
end
def segments
- tempfile_for_echonest do |tmpfile|
- scissor = to_file(tmpfile, :bitrate => '64k')
-
- segments = self.class.echonest.get_segments(tmpfile)
+ analyze do |analysis|
+ segments = analysis.segments
segments.inject([]) do |chunks, segment|
chunk = self[segment.start, segment.duration]
chunk.set_delegate(segment)
chunks << chunk
chunks
end
end
end
private
- def tempfile_for_echonest
+ def analyze
tmpfile = Pathname.new('/tmp/scissor_echonest_temp_' + $$.to_s + '.mp3')
- yield tmpfile
+ scissor = to_file(tmpfile, :bitrate => '64k')
+
+ yield self.class.echonest.track.analysis(tmpfile)
ensure
- tmpfile.unlink
+ tmpfile.unlink if tmpfile.exist?
end
end
end
|
youpy/scissor-echonest
|
68315a0c0e64b7d5d1765dc87ed5da5d4ae6c0c0
|
add Scissor::Chunk#bars
|
diff --git a/lib/scissor/echonest.rb b/lib/scissor/echonest.rb
index 58bf277..333df1f 100644
--- a/lib/scissor/echonest.rb
+++ b/lib/scissor/echonest.rb
@@ -1,67 +1,82 @@
require 'scissor'
require 'echonest'
require 'scissor/echonest/chunk_ext.rb'
module Scissor
def self.echonest_api_key=(echonest_api_key)
Scissor::Chunk.echonest_api_key = echonest_api_key
end
class Chunk
class << self
attr_accessor :echonest_api_key
def echonest
@echonest ||= Echonest(echonest_api_key)
end
end
+ def bars
+ tempfile_for_echonest do |tmpfile|
+ chunks = []
+ scissor = to_file(tmpfile, :bitrate => '64k')
+
+ bars = self.class.echonest.get_bars(tmpfile)
+ bars.inject([]) do |chunks, bar|
+ chunk = self[bar.start, bar.duration]
+ chunk.set_delegate(bar)
+ chunks << chunk
+ chunks
+ end
+ end
+ end
+
def beats
tempfile_for_echonest do |tmpfile|
chunks = []
scissor = to_file(tmpfile, :bitrate => '64k')
beats = self.class.echonest.get_beats(tmpfile)
if beats.size != 0
chunk = self[0, beats.first.start]
beat = Beat.new(0.0, beats.first.start, 1.0)
chunk.set_delegate(beat)
chunks << chunk
end
beats.inject do |m, beat|
chunk = self[m.start, beat.start - m.start]
chunk.set_delegate(m)
chunks << chunk
beat
end
chunks
end
end
def segments
tempfile_for_echonest do |tmpfile|
scissor = to_file(tmpfile, :bitrate => '64k')
segments = self.class.echonest.get_segments(tmpfile)
segments.inject([]) do |chunks, segment|
chunk = self[segment.start, segment.duration]
chunk.set_delegate(segment)
chunks << chunk
chunks
end
end
end
private
def tempfile_for_echonest
tmpfile = Pathname.new('/tmp/scissor_echonest_temp_' + $$.to_s + '.mp3')
yield tmpfile
ensure
tmpfile.unlink
end
end
end
diff --git a/spec/scissor-echonest_spec.rb b/spec/scissor-echonest_spec.rb
index 1b59a20..c281ed5 100755
--- a/spec/scissor-echonest_spec.rb
+++ b/spec/scissor-echonest_spec.rb
@@ -1,71 +1,81 @@
$:.unshift File.dirname(__FILE__)
require 'spec_helper'
include SpecHelper
describe Scissor do
it 'should set Echo Nest API key' do
Scissor.echonest_api_key = 'XXX'
Scissor::Chunk.echonest_api_key.should eql('XXX')
end
it 'should get an instance of EchoNest::Api' do
Scissor.echonest_api_key = 'XXX'
echonest = Scissor::Chunk.echonest
echonest.user_agent.send_timeout = 300
echonest.should be_an_instance_of(Echonest::Api)
Scissor::Chunk.echonest.user_agent.send_timeout.should eql(300)
end
describe 'analysis' do |object|
before do
Scissor.echonest_api_key = 'XXX'
api = Echonest::Api.new('XXX')
track_methods = Echonest::ApiMethods::Track.new(api)
api.stub!(:track).and_return(track_methods)
track_methods.stub!(:analysis).and_return(Echonest::Analysis.new(open(fixture('analysis.json')).read))
@scissor = Scissor(fixture('sample.mp3'))
Scissor::Chunk.stub!(:echonest).and_return(api)
end
+ it 'should get bars' do
+ bars = @scissor.bars
+ bar = bars.first
+
+ bars.size.should eql(80)
+ bar.start.should be_close(1.0, 0.1)
+ bar.duration.should be_close(1.48, 0.01)
+ bar.confidence.should be_close(0.18, 0.01)
+ end
+
it 'should get beats' do
beats = @scissor.beats
beats.size.should eql(324)
beats[0].should be_an_instance_of(Scissor::Chunk)
beats[0].start.should eql(0.0)
beats[0].duration.should eql(0.27661)
beats[0].fragments.first.filename.should eql(fixture('sample.mp3'))
beats[0].confidence.should eql(1.0)
beats[1].should be_an_instance_of(Scissor::Chunk)
beats[1].start.should eql(0.27661)
beats[1].duration.should eql(0.36476)
beats[1].fragments.first.filename.should eql(fixture('sample.mp3'))
beats[1].confidence.should eql(0.468)
end
it 'should get segments' do
segments = @scissor.segments
segment = segments.first
segments.size.should eql(274)
segment.start.should eql(0.0)
segment.duration.should eql(0.43909)
segment.confidence.should eql(1.0)
segment.loudness.time.should eql(0.0)
segment.loudness.value.should eql(-60.0)
segment.max_loudness.time.should eql(0.11238)
segment.max_loudness.value.should eql(-33.563)
segment.pitches.size.should eql(12)
segment.pitches.first.should eql(0.138)
segment.timbre.size.should eql(12)
segment.timbre.first.should eql(11.525)
end
end
end
|
youpy/scissor-echonest
|
4c9c1bac6c1a913f46fc2945819b25511e8f87a9
|
bumped the version to 0.0.8
|
diff --git a/Rakefile b/Rakefile
index b6152b7..065434e 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,110 +1,110 @@
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/contrib/rubyforgepublisher'
require 'rake/contrib/sshpublisher'
require 'spec/rake/spectask'
require 'fileutils'
include FileUtils
$LOAD_PATH.unshift "lib"
require "scissor/echonest"
NAME = "scissor-echonest"
AUTHOR = "youpy"
EMAIL = "youpy@buycheapviagraonlinenow.com"
DESCRIPTION = "Scissor extension to use Echo Nest Developers API"
RUBYFORGE_PROJECT = "scissorechonest"
HOMEPATH = "http://github.com/youpy/scissor-echonest"
BIN_FILES = %w( )
-VERS = "0.0.7"
+VERS = "0.0.8"
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
RDOC_OPTS = [
'--title', "#{NAME} documentation",
"--charset", "utf-8",
"--opname", "index.html",
"--line-numbers",
"--main", "README.rdoc",
"--inline-source",
]
task :default => [:spec]
task :package => [:clean]
Spec::Rake::SpecTask.new do |t|
t.spec_opts = ['--options', "spec/spec.opts"]
t.spec_files = FileList['spec/*_spec.rb']
t.rcov = true
end
spec = Gem::Specification.new do |s|
s.name = NAME
s.version = VERS
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
s.summary = DESCRIPTION
s.description = DESCRIPTION
s.author = AUTHOR
s.email = EMAIL
s.homepage = HOMEPATH
s.executables = BIN_FILES
s.rubyforge_project = RUBYFORGE_PROJECT
s.bindir = "bin"
s.require_path = "lib"
s.test_files = Dir["test/test_*.rb"]
s.add_dependency('scissor', '>=0.0.22')
s.add_dependency('ruby-echonest', '>=0.1.1')
#s.required_ruby_version = '>= 1.8.2'
s.files = %w(README.rdoc ChangeLog Rakefile) +
Dir.glob("{bin,doc,spec,test,lib,templates,generator,extras,website,script}/**/*") +
Dir.glob("ext/**/*.{h,c,rb}") +
Dir.glob("examples/**/*.rb") +
Dir.glob("tools/*.rb")
s.extensions = FileList["ext/**/extconf.rb"].to_a
end
Rake::GemPackageTask.new(spec) do |p|
p.need_tar = true
p.gem_spec = spec
end
task :install do
name = "#{NAME}-#{VERS}.gem"
sh %{rake package}
sh %{sudo gem install pkg/#{name}}
end
task :uninstall => [:clean] do
sh %{sudo gem uninstall #{NAME}}
end
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'html'
rdoc.options += RDOC_OPTS
rdoc.template = "resh"
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
if ENV['DOC_FILES']
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
else
rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.include('ext/**/*.c')
end
end
desc "Show information about the gem"
task :debug_gem do
puts spec.to_ruby
end
|
youpy/scissor-echonest
|
cf58d7307dd79ae26bb27c8c1b53d61c2ae40eaf
|
add example
|
diff --git a/examples/afromb.rb b/examples/afromb.rb
new file mode 100644
index 0000000..f529d2c
--- /dev/null
+++ b/examples/afromb.rb
@@ -0,0 +1,87 @@
+#!/usr/bin/ruby
+
+# Re-synthesize song A using the segments of song B.
+#
+# original
+# http://code.google.com/p/echo-nest-remix/source/browse/trunk/examples/afromb/vafroma.py
+#
+# example result
+# http://soundcloud.com/youpy/pocket-calculator-scissor-afroma-mix
+
+require 'rubygems'
+require 'scissor/echonest'
+require 'narray'
+
+class AfromB
+ def initialize(a, b = nil)
+ @a, @b = [a, b || a]
+
+ @segments_of_a = Scissor(@a).segments
+ @segments_of_b = (@a == @b) ? @segments_of_a : Scissor(@b).segments
+ end
+
+ def get_distance_from(target)
+ dur_weight = 1000
+ timbre_weight = 0.001
+ pitch_weight = 10
+ loudness_weight = 1
+
+ distances = []
+
+ @segments_of_a.each do |segment|
+ ddur = (target.duration - segment.duration) ** 2
+ dloud = (target.max_loudness.value - segment.max_loudness.value) ** 2
+
+ timbre_diff = NArray.to_na(target.timbre) - segment.timbre
+ dtimbre = (timbre_diff ** 2).sum
+
+ pitch_diff = NArray.to_na(target.pitches) - segment.pitches
+ dpitch = (pitch_diff ** 2).sum
+
+ distance = dur_weight * ddur +
+ loudness_weight * dloud +
+ timbre_weight * dtimbre +
+ pitch_weight * dpitch;
+
+ distances << distance
+ end
+
+ distances
+ end
+
+ def run
+ result = []
+
+ @segments_of_b.each_with_index do |segment, index|
+ distances = get_distance_from(segment)
+ distances[index] = 99999.0 if @b == @a
+ segment_from_a = @segments_of_a[distances.index(distances.min)]
+
+ if segment_from_a.duration > segment.duration
+ result << segment_from_a[0, segment.duration]
+ else
+ result << segment_from_a + Scissor.silence(segment.duration - segment_from_a.duration)
+ end
+ end
+
+ Scissor.join(result)
+ end
+end
+
+if __FILE__ == $0
+ require 'pit'
+
+ Scissor.echonest_api_key = Pit.get('echonest.com', :require => {
+ 'api_key' => 'your Echo Nest API key'
+ })['api_key']
+ Scissor::Chunk.echonest.user_agent.send_timeout = 300
+
+ if ARGV.size == 3
+ a, b, outfile = ARGV
+ else
+ a, outfile = ARGV
+ b = a
+ end
+
+ AfromB.new(a, b).run >> outfile
+end
|
youpy/scissor-echonest
|
4fb76b1de2098f7826853f930298763febd67df3
|
version 0.0.7
|
diff --git a/Rakefile b/Rakefile
index cdfc4b9..bebcea4 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,110 +1,110 @@
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/contrib/rubyforgepublisher'
require 'rake/contrib/sshpublisher'
require 'spec/rake/spectask'
require 'fileutils'
include FileUtils
$LOAD_PATH.unshift "lib"
require "scissor/echonest"
NAME = "scissor-echonest"
AUTHOR = "youpy"
EMAIL = "youpy@buycheapviagraonlinenow.com"
DESCRIPTION = "Scissor extension to use Echo Nest Developers API"
RUBYFORGE_PROJECT = "scissorechonest"
HOMEPATH = "http://github.com/youpy/scissor-echonest"
BIN_FILES = %w( )
-VERS = "0.0.6"
+VERS = "0.0.7"
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
RDOC_OPTS = [
'--title', "#{NAME} documentation",
"--charset", "utf-8",
"--opname", "index.html",
"--line-numbers",
"--main", "README.rdoc",
"--inline-source",
]
task :default => [:spec]
task :package => [:clean]
Spec::Rake::SpecTask.new do |t|
t.spec_opts = ['--options', "spec/spec.opts"]
t.spec_files = FileList['spec/*_spec.rb']
t.rcov = true
end
spec = Gem::Specification.new do |s|
s.name = NAME
s.version = VERS
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
s.summary = DESCRIPTION
s.description = DESCRIPTION
s.author = AUTHOR
s.email = EMAIL
s.homepage = HOMEPATH
s.executables = BIN_FILES
s.rubyforge_project = RUBYFORGE_PROJECT
s.bindir = "bin"
s.require_path = "lib"
s.test_files = Dir["test/test_*.rb"]
s.add_dependency('scissor', '>=0.0.22')
s.add_dependency('ruby-echonest', '>=0.0.6')
#s.required_ruby_version = '>= 1.8.2'
s.files = %w(README.rdoc ChangeLog Rakefile) +
Dir.glob("{bin,doc,spec,test,lib,templates,generator,extras,website,script}/**/*") +
Dir.glob("ext/**/*.{h,c,rb}") +
Dir.glob("examples/**/*.rb") +
Dir.glob("tools/*.rb")
s.extensions = FileList["ext/**/extconf.rb"].to_a
end
Rake::GemPackageTask.new(spec) do |p|
p.need_tar = true
p.gem_spec = spec
end
task :install do
name = "#{NAME}-#{VERS}.gem"
sh %{rake package}
sh %{sudo gem install pkg/#{name}}
end
task :uninstall => [:clean] do
sh %{sudo gem uninstall #{NAME}}
end
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'html'
rdoc.options += RDOC_OPTS
rdoc.template = "resh"
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
if ENV['DOC_FILES']
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
else
rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.include('ext/**/*.c')
end
end
desc "Show information about the gem"
task :debug_gem do
puts spec.to_ruby
end
|
youpy/scissor-echonest
|
305ee3b4b6ec5f0280c9d120a671cc16f00f28d1
|
Scissor::Chunk: instance variable "echonest" is moved into class variable
|
diff --git a/lib/scissor/echonest.rb b/lib/scissor/echonest.rb
index d36efdf..5b050af 100644
--- a/lib/scissor/echonest.rb
+++ b/lib/scissor/echonest.rb
@@ -1,67 +1,67 @@
require 'scissor'
require 'echonest'
require 'scissor/echonest/chunk_ext.rb'
module Scissor
def self.echonest_api_key=(echonest_api_key)
Scissor::Chunk.echonest_api_key = echonest_api_key
end
class Chunk
class << self
attr_accessor :echonest_api_key
- end
- def echonest
- Echonest(self.class.echonest_api_key)
+ def echonest
+ @echonest ||= Echonest(echonest_api_key)
+ end
end
def beats
tempfile_for_echonest do |tmpfile|
chunks = []
scissor = to_file(tmpfile, :bitrate => '64k')
- beats = echonest.get_beats(tmpfile)
+ beats = self.class.echonest.get_beats(tmpfile)
if beats.size != 0
chunk = self[0, beats.first.start]
beat = Beat.new(beats.first.start, 1.0)
chunk.set_delegate(beat)
chunks << chunk
end
beats.inject do |m, beat|
chunk = self[m.start, beat.start - m.start]
chunk.set_delegate(m)
chunks << chunk
beat
end
chunks
end
end
def segments
tempfile_for_echonest do |tmpfile|
scissor = to_file(tmpfile, :bitrate => '64k')
- segments = echonest.get_segments(tmpfile)
+ segments = self.class.echonest.get_segments(tmpfile)
segments.inject([]) do |chunks, segment|
chunk = self[segment.start, segment.duration]
chunk.set_delegate(segment)
chunks << chunk
chunks
end
end
end
private
def tempfile_for_echonest
tmpfile = Pathname.new('/tmp/scissor_echonest_temp_' + $$.to_s + '.mp3')
yield tmpfile
ensure
tmpfile.unlink
end
end
end
diff --git a/spec/scissor-echonest_spec.rb b/spec/scissor-echonest_spec.rb
index 8fde436..80f8d7d 100755
--- a/spec/scissor-echonest_spec.rb
+++ b/spec/scissor-echonest_spec.rb
@@ -1,57 +1,67 @@
$:.unshift File.dirname(__FILE__)
require 'spec_helper'
include SpecHelper
describe Scissor do
it 'should set Echo Nest API key' do
Scissor.echonest_api_key = 'XXX'
Scissor::Chunk.echonest_api_key.should eql('XXX')
end
+ it 'should get an instance of EchoNest::Api' do
+ Scissor.echonest_api_key = 'XXX'
+
+ echonest = Scissor::Chunk.echonest
+ echonest.user_agent.send_timeout = 300
+
+ echonest.should be_an_instance_of(Echonest::Api)
+ Scissor::Chunk.echonest.user_agent.send_timeout.should eql(300)
+ end
+
it 'should get beats' do
Scissor.echonest_api_key = 'XXX'
api = Echonest::Api.new('XXX')
api.user_agent.stub!(:get_content).and_return(open(fixture('get_beats.xml')).read)
scissor = Scissor(fixture('sample.mp3'))
- scissor.stub!(:echonest).and_return(api)
+ Scissor::Chunk.stub!(:echonest).and_return(api)
beats = scissor.beats
beats.size.should eql(385)
beats[0].should be_an_instance_of(Scissor::Chunk)
beats[0].duration.should eql(0.35812)
beats[0].fragments.first.filename.should eql(fixture('sample.mp3'))
beats[0].confidence.should eql(1.0)
beats[1].should be_an_instance_of(Scissor::Chunk)
beats[1].duration.should eql(0.47604)
beats[1].fragments.first.filename.should eql(fixture('sample.mp3'))
beats[1].confidence.should eql(0.296)
end
it 'should get segments' do
Scissor.echonest_api_key = 'XXX'
api = Echonest::Api.new('XXX')
api.user_agent.stub!(:get_content).and_return(open(fixture('get_segments.xml')).read)
scissor = Scissor(fixture('sample.mp3'))
- scissor.stub!(:echonest).and_return(api)
+ Scissor::Chunk.stub!(:echonest).and_return(api)
segments = scissor.segments
segments.size.should eql(830)
segments[0].should be_an_instance_of(Scissor::Chunk)
segments[0].duration.should eql(0.30327)
segments[0].fragments.first.filename.should eql(fixture('sample.mp3'))
segments[0].start.should eql(0.0)
segments[0].loudness.time.should eql(0.0)
segments[0].loudness.value.should eql(-60.0)
segments[0].max_loudness.time.should eql(0.31347)
segments[0].max_loudness.value.should eql(-56.818)
segments[0].pitches.first.should eql(0.835)
segments[0].timbre.first.should eql(0.079)
end
end
|
youpy/scissor-echonest
|
1a6eae60df7bc4847306503815c0913ee0dcb68f
|
version 0.0.6
|
diff --git a/Rakefile b/Rakefile
index c5ab388..0a029b2 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,110 +1,110 @@
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/contrib/rubyforgepublisher'
require 'rake/contrib/sshpublisher'
require 'spec/rake/spectask'
require 'fileutils'
include FileUtils
$LOAD_PATH.unshift "lib"
require "scissor/echonest"
NAME = "scissor-echonest"
AUTHOR = "youpy"
EMAIL = "youpy@buycheapviagraonlinenow.com"
DESCRIPTION = "Scissor extension to use Echo Nest Developers API"
RUBYFORGE_PROJECT = "scissorechonest"
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
BIN_FILES = %w( )
-VERS = "0.0.5"
+VERS = "0.0.6"
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
RDOC_OPTS = [
'--title', "#{NAME} documentation",
"--charset", "utf-8",
"--opname", "index.html",
"--line-numbers",
"--main", "README.rdoc",
"--inline-source",
]
task :default => [:spec]
task :package => [:clean]
Spec::Rake::SpecTask.new do |t|
t.spec_opts = ['--options', "spec/spec.opts"]
t.spec_files = FileList['spec/*_spec.rb']
t.rcov = true
end
spec = Gem::Specification.new do |s|
s.name = NAME
s.version = VERS
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
s.summary = DESCRIPTION
s.description = DESCRIPTION
s.author = AUTHOR
s.email = EMAIL
s.homepage = HOMEPATH
s.executables = BIN_FILES
s.rubyforge_project = RUBYFORGE_PROJECT
s.bindir = "bin"
s.require_path = "lib"
s.test_files = Dir["test/test_*.rb"]
s.add_dependency('scissor', '>=0.0.22')
s.add_dependency('ruby-echonest', '>=0.0.6')
#s.required_ruby_version = '>= 1.8.2'
s.files = %w(README.rdoc ChangeLog Rakefile) +
Dir.glob("{bin,doc,spec,test,lib,templates,generator,extras,website,script}/**/*") +
Dir.glob("ext/**/*.{h,c,rb}") +
Dir.glob("examples/**/*.rb") +
Dir.glob("tools/*.rb")
s.extensions = FileList["ext/**/extconf.rb"].to_a
end
Rake::GemPackageTask.new(spec) do |p|
p.need_tar = true
p.gem_spec = spec
end
task :install do
name = "#{NAME}-#{VERS}.gem"
sh %{rake package}
sh %{sudo gem install pkg/#{name}}
end
task :uninstall => [:clean] do
sh %{sudo gem uninstall #{NAME}}
end
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'html'
rdoc.options += RDOC_OPTS
rdoc.template = "resh"
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
if ENV['DOC_FILES']
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
else
rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.include('ext/**/*.c')
end
end
desc "Show information about the gem"
task :debug_gem do
puts spec.to_ruby
end
diff --git a/scissor-echonest.gemspec b/scissor-echonest.gemspec
index fd86ab4..53505c6 100644
--- a/scissor-echonest.gemspec
+++ b/scissor-echonest.gemspec
@@ -1,40 +1,36 @@
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{scissor-echonest}
- s.version = "0.0.5"
+ s.version = "0.0.6"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["youpy"]
- s.date = %q{2009-10-05}
+ s.date = %q{2009-10-11}
s.description = %q{Scissor extension to use Echo Nest Developers API}
s.email = %q{youpy@buycheapviagraonlinenow.com}
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
s.files = ["README.rdoc", "ChangeLog", "Rakefile", "spec/fixtures", "spec/fixtures/get_beats.xml", "spec/fixtures/get_segments.xml", "spec/fixtures/sample.mp3", "spec/scissor-echonest_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "lib/scissor", "lib/scissor/echonest", "lib/scissor/echonest/chunk_ext.rb", "lib/scissor/echonest.rb"]
- s.has_rdoc = true
s.homepage = %q{http://scissorechonest.rubyforge.org}
s.rdoc_options = ["--title", "scissor-echonest documentation", "--charset", "utf-8", "--opname", "index.html", "--line-numbers", "--main", "README.rdoc", "--inline-source", "--exclude", "^(examples|extras)/"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{scissorechonest}
- s.rubygems_version = %q{1.3.1}
+ s.rubygems_version = %q{1.3.5}
s.summary = %q{Scissor extension to use Echo Nest Developers API}
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 2
+ s.specification_version = 3
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<youpy-scissor>, [">= 0.0.19"])
- s.add_runtime_dependency(%q<youpy-ruby-echonest>, [">= 0.0.6"])
- s.add_runtime_dependency(%q<youpy-scissor>, [">= 0.0.22"])
+ s.add_runtime_dependency(%q<scissor>, [">= 0.0.22"])
+ s.add_runtime_dependency(%q<ruby-echonest>, [">= 0.0.6"])
else
- s.add_dependency(%q<youpy-scissor>, [">= 0.0.19"])
- s.add_dependency(%q<youpy-ruby-echonest>, [">= 0.0.6"])
- s.add_dependency(%q<youpy-scissor>, [">= 0.0.22"])
+ s.add_dependency(%q<scissor>, [">= 0.0.22"])
+ s.add_dependency(%q<ruby-echonest>, [">= 0.0.6"])
end
else
- s.add_dependency(%q<youpy-scissor>, [">= 0.0.19"])
- s.add_dependency(%q<youpy-ruby-echonest>, [">= 0.0.6"])
- s.add_dependency(%q<youpy-scissor>, [">= 0.0.22"])
+ s.add_dependency(%q<scissor>, [">= 0.0.22"])
+ s.add_dependency(%q<ruby-echonest>, [">= 0.0.6"])
end
end
|
youpy/scissor-echonest
|
c0e0a0e0a8eb6ceba11f78cd8c7b8da6d287be33
|
version 0.0.5
|
diff --git a/Rakefile b/Rakefile
index 712f75a..33f5eee 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,110 +1,110 @@
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/contrib/rubyforgepublisher'
require 'rake/contrib/sshpublisher'
require 'spec/rake/spectask'
require 'fileutils'
include FileUtils
$LOAD_PATH.unshift "lib"
require "scissor/echonest"
NAME = "scissor-echonest"
AUTHOR = "youpy"
EMAIL = "youpy@buycheapviagraonlinenow.com"
DESCRIPTION = "Scissor extension to use Echo Nest Developers API"
RUBYFORGE_PROJECT = "scissorechonest"
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
BIN_FILES = %w( )
-VERS = "0.0.4"
+VERS = "0.0.5"
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
RDOC_OPTS = [
'--title', "#{NAME} documentation",
"--charset", "utf-8",
"--opname", "index.html",
"--line-numbers",
"--main", "README.rdoc",
"--inline-source",
]
task :default => [:spec]
task :package => [:clean]
Spec::Rake::SpecTask.new do |t|
t.spec_opts = ['--options', "spec/spec.opts"]
t.spec_files = FileList['spec/*_spec.rb']
t.rcov = true
end
spec = Gem::Specification.new do |s|
s.name = NAME
s.version = VERS
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
s.summary = DESCRIPTION
s.description = DESCRIPTION
s.author = AUTHOR
s.email = EMAIL
s.homepage = HOMEPATH
s.executables = BIN_FILES
s.rubyforge_project = RUBYFORGE_PROJECT
s.bindir = "bin"
s.require_path = "lib"
s.test_files = Dir["test/test_*.rb"]
- s.add_dependency('youpy-scissor', '>=0.0.19')
- s.add_dependency('youpy-ruby-echonest', '>=0.0.3')
+ s.add_dependency('youpy-scissor', '>=0.0.22')
+ s.add_dependency('youpy-ruby-echonest', '>=0.0.6')
#s.required_ruby_version = '>= 1.8.2'
s.files = %w(README.rdoc ChangeLog Rakefile) +
Dir.glob("{bin,doc,spec,test,lib,templates,generator,extras,website,script}/**/*") +
Dir.glob("ext/**/*.{h,c,rb}") +
Dir.glob("examples/**/*.rb") +
Dir.glob("tools/*.rb")
s.extensions = FileList["ext/**/extconf.rb"].to_a
end
Rake::GemPackageTask.new(spec) do |p|
p.need_tar = true
p.gem_spec = spec
end
task :install do
name = "#{NAME}-#{VERS}.gem"
sh %{rake package}
sh %{sudo gem install pkg/#{name}}
end
task :uninstall => [:clean] do
sh %{sudo gem uninstall #{NAME}}
end
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'html'
rdoc.options += RDOC_OPTS
rdoc.template = "resh"
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
if ENV['DOC_FILES']
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
else
rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.include('ext/**/*.c')
end
end
desc "Show information about the gem"
task :debug_gem do
puts spec.to_ruby
end
diff --git a/scissor-echonest.gemspec b/scissor-echonest.gemspec
index 3e2967a..fd86ab4 100644
--- a/scissor-echonest.gemspec
+++ b/scissor-echonest.gemspec
@@ -1,37 +1,40 @@
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{scissor-echonest}
- s.version = "0.0.4"
+ s.version = "0.0.5"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["youpy"]
- s.date = %q{2009-08-31}
+ s.date = %q{2009-10-05}
s.description = %q{Scissor extension to use Echo Nest Developers API}
s.email = %q{youpy@buycheapviagraonlinenow.com}
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
s.files = ["README.rdoc", "ChangeLog", "Rakefile", "spec/fixtures", "spec/fixtures/get_beats.xml", "spec/fixtures/get_segments.xml", "spec/fixtures/sample.mp3", "spec/scissor-echonest_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "lib/scissor", "lib/scissor/echonest", "lib/scissor/echonest/chunk_ext.rb", "lib/scissor/echonest.rb"]
s.has_rdoc = true
s.homepage = %q{http://scissorechonest.rubyforge.org}
s.rdoc_options = ["--title", "scissor-echonest documentation", "--charset", "utf-8", "--opname", "index.html", "--line-numbers", "--main", "README.rdoc", "--inline-source", "--exclude", "^(examples|extras)/"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{scissorechonest}
s.rubygems_version = %q{1.3.1}
s.summary = %q{Scissor extension to use Echo Nest Developers API}
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<youpy-scissor>, [">= 0.0.19"])
- s.add_runtime_dependency(%q<youpy-ruby-echonest>, [">= 0.0.3"])
+ s.add_runtime_dependency(%q<youpy-ruby-echonest>, [">= 0.0.6"])
+ s.add_runtime_dependency(%q<youpy-scissor>, [">= 0.0.22"])
else
s.add_dependency(%q<youpy-scissor>, [">= 0.0.19"])
- s.add_dependency(%q<youpy-ruby-echonest>, [">= 0.0.3"])
+ s.add_dependency(%q<youpy-ruby-echonest>, [">= 0.0.6"])
+ s.add_dependency(%q<youpy-scissor>, [">= 0.0.22"])
end
else
s.add_dependency(%q<youpy-scissor>, [">= 0.0.19"])
- s.add_dependency(%q<youpy-ruby-echonest>, [">= 0.0.3"])
+ s.add_dependency(%q<youpy-ruby-echonest>, [">= 0.0.6"])
+ s.add_dependency(%q<youpy-scissor>, [">= 0.0.22"])
end
end
|
youpy/scissor-echonest
|
a6cfb292c13bff23fd38ced7c12366e828c1b97a
|
set bitrate
|
diff --git a/lib/scissor/echonest.rb b/lib/scissor/echonest.rb
index 8e11c7f..d36efdf 100644
--- a/lib/scissor/echonest.rb
+++ b/lib/scissor/echonest.rb
@@ -1,67 +1,67 @@
require 'scissor'
require 'echonest'
require 'scissor/echonest/chunk_ext.rb'
module Scissor
def self.echonest_api_key=(echonest_api_key)
Scissor::Chunk.echonest_api_key = echonest_api_key
end
class Chunk
class << self
attr_accessor :echonest_api_key
end
def echonest
Echonest(self.class.echonest_api_key)
end
def beats
tempfile_for_echonest do |tmpfile|
chunks = []
- scissor = to_file(tmpfile)
+ scissor = to_file(tmpfile, :bitrate => '64k')
beats = echonest.get_beats(tmpfile)
if beats.size != 0
chunk = self[0, beats.first.start]
beat = Beat.new(beats.first.start, 1.0)
chunk.set_delegate(beat)
chunks << chunk
end
beats.inject do |m, beat|
chunk = self[m.start, beat.start - m.start]
chunk.set_delegate(m)
chunks << chunk
beat
end
chunks
end
end
def segments
tempfile_for_echonest do |tmpfile|
- scissor = to_file(tmpfile)
+ scissor = to_file(tmpfile, :bitrate => '64k')
segments = echonest.get_segments(tmpfile)
segments.inject([]) do |chunks, segment|
chunk = self[segment.start, segment.duration]
chunk.set_delegate(segment)
chunks << chunk
chunks
end
end
end
private
def tempfile_for_echonest
tmpfile = Pathname.new('/tmp/scissor_echonest_temp_' + $$.to_s + '.mp3')
yield tmpfile
ensure
tmpfile.unlink
end
end
end
|
youpy/scissor-echonest
|
7b0f7e18caca299042bedc196c1ce88fc9f9d51c
|
fix spec to reflect API changes on ruby-echonest
|
diff --git a/spec/scissor-echonest_spec.rb b/spec/scissor-echonest_spec.rb
index 21279f3..8fde436 100755
--- a/spec/scissor-echonest_spec.rb
+++ b/spec/scissor-echonest_spec.rb
@@ -1,57 +1,57 @@
$:.unshift File.dirname(__FILE__)
require 'spec_helper'
include SpecHelper
describe Scissor do
it 'should set Echo Nest API key' do
Scissor.echonest_api_key = 'XXX'
Scissor::Chunk.echonest_api_key.should eql('XXX')
end
it 'should get beats' do
Scissor.echonest_api_key = 'XXX'
api = Echonest::Api.new('XXX')
- api.connection.stub!(:request).and_return(open(fixture('get_beats.xml')).read)
+ api.user_agent.stub!(:get_content).and_return(open(fixture('get_beats.xml')).read)
scissor = Scissor(fixture('sample.mp3'))
scissor.stub!(:echonest).and_return(api)
beats = scissor.beats
beats.size.should eql(385)
beats[0].should be_an_instance_of(Scissor::Chunk)
beats[0].duration.should eql(0.35812)
beats[0].fragments.first.filename.should eql(fixture('sample.mp3'))
beats[0].confidence.should eql(1.0)
beats[1].should be_an_instance_of(Scissor::Chunk)
beats[1].duration.should eql(0.47604)
beats[1].fragments.first.filename.should eql(fixture('sample.mp3'))
beats[1].confidence.should eql(0.296)
end
it 'should get segments' do
Scissor.echonest_api_key = 'XXX'
api = Echonest::Api.new('XXX')
- api.connection.stub!(:request).and_return(open(fixture('get_segments.xml')).read)
+ api.user_agent.stub!(:get_content).and_return(open(fixture('get_segments.xml')).read)
scissor = Scissor(fixture('sample.mp3'))
scissor.stub!(:echonest).and_return(api)
segments = scissor.segments
segments.size.should eql(830)
segments[0].should be_an_instance_of(Scissor::Chunk)
segments[0].duration.should eql(0.30327)
segments[0].fragments.first.filename.should eql(fixture('sample.mp3'))
segments[0].start.should eql(0.0)
segments[0].loudness.time.should eql(0.0)
segments[0].loudness.value.should eql(-60.0)
segments[0].max_loudness.time.should eql(0.31347)
segments[0].max_loudness.value.should eql(-56.818)
segments[0].pitches.first.should eql(0.835)
segments[0].timbre.first.should eql(0.079)
end
end
|
youpy/scissor-echonest
|
0d5d760bc3d22e9d9d0a40f9c3050b82708363cb
|
version 0.0.4
|
diff --git a/Rakefile b/Rakefile
index e62ffa5..712f75a 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,110 +1,110 @@
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/contrib/rubyforgepublisher'
require 'rake/contrib/sshpublisher'
require 'spec/rake/spectask'
require 'fileutils'
include FileUtils
$LOAD_PATH.unshift "lib"
require "scissor/echonest"
NAME = "scissor-echonest"
AUTHOR = "youpy"
EMAIL = "youpy@buycheapviagraonlinenow.com"
DESCRIPTION = "Scissor extension to use Echo Nest Developers API"
RUBYFORGE_PROJECT = "scissorechonest"
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
BIN_FILES = %w( )
-VERS = "0.0.3"
+VERS = "0.0.4"
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
RDOC_OPTS = [
'--title', "#{NAME} documentation",
"--charset", "utf-8",
"--opname", "index.html",
"--line-numbers",
"--main", "README.rdoc",
"--inline-source",
]
task :default => [:spec]
task :package => [:clean]
Spec::Rake::SpecTask.new do |t|
t.spec_opts = ['--options', "spec/spec.opts"]
t.spec_files = FileList['spec/*_spec.rb']
t.rcov = true
end
spec = Gem::Specification.new do |s|
s.name = NAME
s.version = VERS
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
s.summary = DESCRIPTION
s.description = DESCRIPTION
s.author = AUTHOR
s.email = EMAIL
s.homepage = HOMEPATH
s.executables = BIN_FILES
s.rubyforge_project = RUBYFORGE_PROJECT
s.bindir = "bin"
s.require_path = "lib"
s.test_files = Dir["test/test_*.rb"]
s.add_dependency('youpy-scissor', '>=0.0.19')
s.add_dependency('youpy-ruby-echonest', '>=0.0.3')
#s.required_ruby_version = '>= 1.8.2'
s.files = %w(README.rdoc ChangeLog Rakefile) +
Dir.glob("{bin,doc,spec,test,lib,templates,generator,extras,website,script}/**/*") +
Dir.glob("ext/**/*.{h,c,rb}") +
Dir.glob("examples/**/*.rb") +
Dir.glob("tools/*.rb")
s.extensions = FileList["ext/**/extconf.rb"].to_a
end
Rake::GemPackageTask.new(spec) do |p|
p.need_tar = true
p.gem_spec = spec
end
task :install do
name = "#{NAME}-#{VERS}.gem"
sh %{rake package}
sh %{sudo gem install pkg/#{name}}
end
task :uninstall => [:clean] do
sh %{sudo gem uninstall #{NAME}}
end
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'html'
rdoc.options += RDOC_OPTS
rdoc.template = "resh"
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
if ENV['DOC_FILES']
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
else
rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.include('ext/**/*.c')
end
end
desc "Show information about the gem"
task :debug_gem do
puts spec.to_ruby
end
diff --git a/scissor-echonest.gemspec b/scissor-echonest.gemspec
index 625b1ed..3e2967a 100644
--- a/scissor-echonest.gemspec
+++ b/scissor-echonest.gemspec
@@ -1,37 +1,37 @@
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{scissor-echonest}
- s.version = "0.0.3"
+ s.version = "0.0.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["youpy"]
- s.date = %q{2009-07-23}
+ s.date = %q{2009-08-31}
s.description = %q{Scissor extension to use Echo Nest Developers API}
s.email = %q{youpy@buycheapviagraonlinenow.com}
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
- s.files = ["README.rdoc", "ChangeLog", "Rakefile", "spec/fixtures", "spec/fixtures/get_beats.xml", "spec/fixtures/get_segments.xml", "spec/fixtures/sample.mp3", "spec/scissor-echonest_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "lib/scissor", "lib/scissor/echonest", "lib/scissor/echonest/meta.rb", "lib/scissor/echonest.rb"]
+ s.files = ["README.rdoc", "ChangeLog", "Rakefile", "spec/fixtures", "spec/fixtures/get_beats.xml", "spec/fixtures/get_segments.xml", "spec/fixtures/sample.mp3", "spec/scissor-echonest_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "lib/scissor", "lib/scissor/echonest", "lib/scissor/echonest/chunk_ext.rb", "lib/scissor/echonest.rb"]
s.has_rdoc = true
s.homepage = %q{http://scissorechonest.rubyforge.org}
s.rdoc_options = ["--title", "scissor-echonest documentation", "--charset", "utf-8", "--opname", "index.html", "--line-numbers", "--main", "README.rdoc", "--inline-source", "--exclude", "^(examples|extras)/"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{scissorechonest}
s.rubygems_version = %q{1.3.1}
s.summary = %q{Scissor extension to use Echo Nest Developers API}
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<youpy-scissor>, [">= 0.0.19"])
s.add_runtime_dependency(%q<youpy-ruby-echonest>, [">= 0.0.3"])
else
s.add_dependency(%q<youpy-scissor>, [">= 0.0.19"])
s.add_dependency(%q<youpy-ruby-echonest>, [">= 0.0.3"])
end
else
s.add_dependency(%q<youpy-scissor>, [">= 0.0.19"])
s.add_dependency(%q<youpy-ruby-echonest>, [">= 0.0.3"])
end
end
|
youpy/scissor-echonest
|
63aaf13d832c91f9ae1fc31214e0b1bb70773eac
|
fix gh-1
|
diff --git a/lib/scissor/echonest.rb b/lib/scissor/echonest.rb
index 7e30cdc..8e11c7f 100644
--- a/lib/scissor/echonest.rb
+++ b/lib/scissor/echonest.rb
@@ -1,59 +1,67 @@
require 'scissor'
require 'echonest'
require 'scissor/echonest/chunk_ext.rb'
module Scissor
def self.echonest_api_key=(echonest_api_key)
Scissor::Chunk.echonest_api_key = echonest_api_key
end
class Chunk
class << self
attr_accessor :echonest_api_key
end
def echonest
Echonest(self.class.echonest_api_key)
end
def beats
tempfile_for_echonest do |tmpfile|
chunks = []
scissor = to_file(tmpfile)
beats = echonest.get_beats(tmpfile)
+
+ if beats.size != 0
+ chunk = self[0, beats.first.start]
+ beat = Beat.new(beats.first.start, 1.0)
+ chunk.set_delegate(beat)
+ chunks << chunk
+ end
+
beats.inject do |m, beat|
chunk = self[m.start, beat.start - m.start]
chunk.set_delegate(m)
chunks << chunk
beat
end
chunks
end
end
def segments
tempfile_for_echonest do |tmpfile|
scissor = to_file(tmpfile)
segments = echonest.get_segments(tmpfile)
segments.inject([]) do |chunks, segment|
chunk = self[segment.start, segment.duration]
chunk.set_delegate(segment)
chunks << chunk
chunks
end
end
end
private
def tempfile_for_echonest
tmpfile = Pathname.new('/tmp/scissor_echonest_temp_' + $$.to_s + '.mp3')
yield tmpfile
ensure
tmpfile.unlink
end
end
end
diff --git a/spec/scissor-echonest_spec.rb b/spec/scissor-echonest_spec.rb
index 07ef414..21279f3 100755
--- a/spec/scissor-echonest_spec.rb
+++ b/spec/scissor-echonest_spec.rb
@@ -1,53 +1,57 @@
$:.unshift File.dirname(__FILE__)
require 'spec_helper'
include SpecHelper
describe Scissor do
it 'should set Echo Nest API key' do
Scissor.echonest_api_key = 'XXX'
Scissor::Chunk.echonest_api_key.should eql('XXX')
end
it 'should get beats' do
Scissor.echonest_api_key = 'XXX'
api = Echonest::Api.new('XXX')
api.connection.stub!(:request).and_return(open(fixture('get_beats.xml')).read)
scissor = Scissor(fixture('sample.mp3'))
scissor.stub!(:echonest).and_return(api)
beats = scissor.beats
- beats.size.should eql(384)
+ beats.size.should eql(385)
beats[0].should be_an_instance_of(Scissor::Chunk)
- beats[0].duration.should eql(0.47604)
+ beats[0].duration.should eql(0.35812)
beats[0].fragments.first.filename.should eql(fixture('sample.mp3'))
- beats[0].confidence.should eql(0.296)
+ beats[0].confidence.should eql(1.0)
+ beats[1].should be_an_instance_of(Scissor::Chunk)
+ beats[1].duration.should eql(0.47604)
+ beats[1].fragments.first.filename.should eql(fixture('sample.mp3'))
+ beats[1].confidence.should eql(0.296)
end
it 'should get segments' do
Scissor.echonest_api_key = 'XXX'
api = Echonest::Api.new('XXX')
api.connection.stub!(:request).and_return(open(fixture('get_segments.xml')).read)
scissor = Scissor(fixture('sample.mp3'))
scissor.stub!(:echonest).and_return(api)
segments = scissor.segments
segments.size.should eql(830)
segments[0].should be_an_instance_of(Scissor::Chunk)
segments[0].duration.should eql(0.30327)
segments[0].fragments.first.filename.should eql(fixture('sample.mp3'))
segments[0].start.should eql(0.0)
segments[0].loudness.time.should eql(0.0)
segments[0].loudness.value.should eql(-60.0)
segments[0].max_loudness.time.should eql(0.31347)
segments[0].max_loudness.value.should eql(-56.818)
segments[0].pitches.first.should eql(0.835)
segments[0].timbre.first.should eql(0.079)
end
end
|
youpy/scissor-echonest
|
a824035468169514c7b6ed48213e9578799f8f60
|
add link to Scissor
|
diff --git a/README.rdoc b/README.rdoc
index 526bd3d..d48525c 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -1,40 +1,40 @@
= scissor-echonest
-Scissor extension to use Echo Nest Developers API
+{Scissor}[http://github.com/youpy/scissor/tree/master] extension to use Echo Nest Developers API
== Description
== Installation
=== Archive Installation
rake install
=== Gem Installation
gem sources -a http://gems.github.com/
gem install youpy-scissor-echonest
== Features/Problems
== Synopsis
require 'rubygems'
require 'scissor/echonest'
Scissor.echonest_api_key = 'YOUR_API_KEY'
# sort beats by duration
beats = Scissor('trans_europe_express.mp3').beats.
sort_by {|beat| beat.duration }
# join beats and write into file
Scissor.join(beats) > 'sorted.mp3'
== Copyright
Author:: youpy <youpy@buycheapviagraonlinenow.com>
Copyright:: Copyright (c) 2009 youpy
License:: MIT
|
youpy/scissor-echonest
|
1f26a14bd9ce46d6d771a4d45408bdcbc3cc4dae
|
add delegation on Scissor::Chunk
|
diff --git a/lib/scissor/echonest.rb b/lib/scissor/echonest.rb
index 2e5ed6f..7e30cdc 100644
--- a/lib/scissor/echonest.rb
+++ b/lib/scissor/echonest.rb
@@ -1,59 +1,59 @@
require 'scissor'
require 'echonest'
-require 'scissor/echonest/meta'
+require 'scissor/echonest/chunk_ext.rb'
module Scissor
def self.echonest_api_key=(echonest_api_key)
Scissor::Chunk.echonest_api_key = echonest_api_key
end
class Chunk
class << self
attr_accessor :echonest_api_key
end
def echonest
Echonest(self.class.echonest_api_key)
end
def beats
tempfile_for_echonest do |tmpfile|
chunks = []
scissor = to_file(tmpfile)
beats = echonest.get_beats(tmpfile)
beats.inject do |m, beat|
chunk = self[m.start, beat.start - m.start]
- Echonest::Meta::Beat.init(chunk, m)
+ chunk.set_delegate(m)
chunks << chunk
beat
end
chunks
end
end
def segments
tempfile_for_echonest do |tmpfile|
scissor = to_file(tmpfile)
segments = echonest.get_segments(tmpfile)
segments.inject([]) do |chunks, segment|
chunk = self[segment.start, segment.duration]
- Echonest::Meta::Segment.init(chunk, segment)
+ chunk.set_delegate(segment)
chunks << chunk
chunks
end
end
end
private
def tempfile_for_echonest
tmpfile = Pathname.new('/tmp/scissor_echonest_temp_' + $$.to_s + '.mp3')
yield tmpfile
ensure
tmpfile.unlink
end
end
end
diff --git a/lib/scissor/echonest/chunk_ext.rb b/lib/scissor/echonest/chunk_ext.rb
new file mode 100644
index 0000000..a54a461
--- /dev/null
+++ b/lib/scissor/echonest/chunk_ext.rb
@@ -0,0 +1,11 @@
+module Scissor
+ class Chunk
+ def set_delegate(delegate)
+ @delegate = delegate
+ end
+
+ def method_missing(name, *args, &block)
+ @delegate.send(name, *args, &block)
+ end
+ end
+end
diff --git a/lib/scissor/echonest/meta.rb b/lib/scissor/echonest/meta.rb
deleted file mode 100644
index 3c7b92c..0000000
--- a/lib/scissor/echonest/meta.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-module Scissor
- module Echonest
- module Meta
- module Beat
- def self.init(obj, beat)
- obj.extend self
- obj.instance_eval {
- @confidence = beat.confidence
- @start = beat.start
- }
- end
-
- attr_reader :confidence, :start
- end
-
- module Segment
- def self.init(obj, segment)
- obj.extend self
- obj.instance_eval {
- @start = segment.start
- @loudness = segment.loudness
- @max_loudness = segment.max_loudness
- @pitches = segment.pitches
- @timbre = segment.timbre
- }
- end
-
- attr_reader :start, :loudness, :max_loudness, :pitches, :timbre
- end
- end
- end
-end
|
youpy/scissor-echonest
|
a9c1d2ee4fa650edc6863bc6aaa2f2f23cacfc00
|
version 0.0.3
|
diff --git a/Rakefile b/Rakefile
index 30d6730..e62ffa5 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,110 +1,110 @@
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/contrib/rubyforgepublisher'
require 'rake/contrib/sshpublisher'
require 'spec/rake/spectask'
require 'fileutils'
include FileUtils
$LOAD_PATH.unshift "lib"
require "scissor/echonest"
NAME = "scissor-echonest"
AUTHOR = "youpy"
EMAIL = "youpy@buycheapviagraonlinenow.com"
DESCRIPTION = "Scissor extension to use Echo Nest Developers API"
RUBYFORGE_PROJECT = "scissorechonest"
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
BIN_FILES = %w( )
-VERS = "0.0.2"
+VERS = "0.0.3"
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
RDOC_OPTS = [
'--title', "#{NAME} documentation",
"--charset", "utf-8",
"--opname", "index.html",
"--line-numbers",
"--main", "README.rdoc",
"--inline-source",
]
task :default => [:spec]
task :package => [:clean]
Spec::Rake::SpecTask.new do |t|
t.spec_opts = ['--options', "spec/spec.opts"]
t.spec_files = FileList['spec/*_spec.rb']
t.rcov = true
end
spec = Gem::Specification.new do |s|
s.name = NAME
s.version = VERS
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
s.summary = DESCRIPTION
s.description = DESCRIPTION
s.author = AUTHOR
s.email = EMAIL
s.homepage = HOMEPATH
s.executables = BIN_FILES
s.rubyforge_project = RUBYFORGE_PROJECT
s.bindir = "bin"
s.require_path = "lib"
s.test_files = Dir["test/test_*.rb"]
s.add_dependency('youpy-scissor', '>=0.0.19')
s.add_dependency('youpy-ruby-echonest', '>=0.0.3')
#s.required_ruby_version = '>= 1.8.2'
s.files = %w(README.rdoc ChangeLog Rakefile) +
Dir.glob("{bin,doc,spec,test,lib,templates,generator,extras,website,script}/**/*") +
Dir.glob("ext/**/*.{h,c,rb}") +
Dir.glob("examples/**/*.rb") +
Dir.glob("tools/*.rb")
s.extensions = FileList["ext/**/extconf.rb"].to_a
end
Rake::GemPackageTask.new(spec) do |p|
p.need_tar = true
p.gem_spec = spec
end
task :install do
name = "#{NAME}-#{VERS}.gem"
sh %{rake package}
sh %{sudo gem install pkg/#{name}}
end
task :uninstall => [:clean] do
sh %{sudo gem uninstall #{NAME}}
end
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'html'
rdoc.options += RDOC_OPTS
rdoc.template = "resh"
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
if ENV['DOC_FILES']
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
else
rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_files.include('ext/**/*.c')
end
end
desc "Show information about the gem"
task :debug_gem do
puts spec.to_ruby
end
diff --git a/lib/scissor/echonest.rb b/lib/scissor/echonest.rb
index a37e37a..2e5ed6f 100644
--- a/lib/scissor/echonest.rb
+++ b/lib/scissor/echonest.rb
@@ -1,59 +1,59 @@
require 'scissor'
require 'echonest'
require 'scissor/echonest/meta'
module Scissor
def self.echonest_api_key=(echonest_api_key)
Scissor::Chunk.echonest_api_key = echonest_api_key
end
class Chunk
class << self
attr_accessor :echonest_api_key
end
def echonest
Echonest(self.class.echonest_api_key)
end
def beats
tempfile_for_echonest do |tmpfile|
chunks = []
scissor = to_file(tmpfile)
beats = echonest.get_beats(tmpfile)
beats.inject do |m, beat|
chunk = self[m.start, beat.start - m.start]
Echonest::Meta::Beat.init(chunk, m)
chunks << chunk
beat
end
chunks
end
end
def segments
tempfile_for_echonest do |tmpfile|
scissor = to_file(tmpfile)
segments = echonest.get_segments(tmpfile)
segments.inject([]) do |chunks, segment|
chunk = self[segment.start, segment.duration]
- Echonest::Meta::Segment.init(chunk, segment )
+ Echonest::Meta::Segment.init(chunk, segment)
chunks << chunk
chunks
end
end
end
private
def tempfile_for_echonest
tmpfile = Pathname.new('/tmp/scissor_echonest_temp_' + $$.to_s + '.mp3')
yield tmpfile
ensure
tmpfile.unlink
end
end
end
diff --git a/scissor-echonest.gemspec b/scissor-echonest.gemspec
index f24d7d3..625b1ed 100644
--- a/scissor-echonest.gemspec
+++ b/scissor-echonest.gemspec
@@ -1,37 +1,37 @@
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{scissor-echonest}
- s.version = "0.0.2"
+ s.version = "0.0.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["youpy"]
- s.date = %q{2009-07-06}
+ s.date = %q{2009-07-23}
s.description = %q{Scissor extension to use Echo Nest Developers API}
s.email = %q{youpy@buycheapviagraonlinenow.com}
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
- s.files = ["README.rdoc", "ChangeLog", "Rakefile", "spec/fixtures", "spec/fixtures/get_beats.xml", "spec/fixtures/get_segments.xml", "spec/fixtures/sample.mp3", "spec/scissor-echonest_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "lib/scissor", "lib/scissor/echonest.rb"]
+ s.files = ["README.rdoc", "ChangeLog", "Rakefile", "spec/fixtures", "spec/fixtures/get_beats.xml", "spec/fixtures/get_segments.xml", "spec/fixtures/sample.mp3", "spec/scissor-echonest_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "lib/scissor", "lib/scissor/echonest", "lib/scissor/echonest/meta.rb", "lib/scissor/echonest.rb"]
s.has_rdoc = true
s.homepage = %q{http://scissorechonest.rubyforge.org}
s.rdoc_options = ["--title", "scissor-echonest documentation", "--charset", "utf-8", "--opname", "index.html", "--line-numbers", "--main", "README.rdoc", "--inline-source", "--exclude", "^(examples|extras)/"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{scissorechonest}
s.rubygems_version = %q{1.3.1}
s.summary = %q{Scissor extension to use Echo Nest Developers API}
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<scissor>, [">= 0.0.19"])
- s.add_runtime_dependency(%q<ruby-echonest>, [">= 0.0.3"])
+ s.add_runtime_dependency(%q<youpy-scissor>, [">= 0.0.19"])
+ s.add_runtime_dependency(%q<youpy-ruby-echonest>, [">= 0.0.3"])
else
- s.add_dependency(%q<scissor>, [">= 0.0.19"])
- s.add_dependency(%q<ruby-echonest>, [">= 0.0.3"])
+ s.add_dependency(%q<youpy-scissor>, [">= 0.0.19"])
+ s.add_dependency(%q<youpy-ruby-echonest>, [">= 0.0.3"])
end
else
- s.add_dependency(%q<scissor>, [">= 0.0.19"])
- s.add_dependency(%q<ruby-echonest>, [">= 0.0.3"])
+ s.add_dependency(%q<youpy-scissor>, [">= 0.0.19"])
+ s.add_dependency(%q<youpy-ruby-echonest>, [">= 0.0.3"])
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.