From 3dc8c8b08a0ae212088967b125d19b2825a8c708 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Wed, 16 Jan 2013 06:10:53 +0100 Subject: [PATCH] Add some stuff, remove active config.json from tracked files, update config --- .gitignore | 1 + config.json => config.json.example | 14 ++++-- public_html/authenticators/project.php | 28 +++++++++++ public_html/debug.createuser.php | 13 +++++ public_html/modules/error/project.php | 16 ++++++ public_html/modules/home/index.php | 16 ++++++ public_html/modules/project/index.php | 25 ++++++++++ public_html/rewrite.php | 63 ++++++++++++++++++++++++ public_html/templates/home/layout.tpl | 13 +++++ public_html/templates/project/index.tpl | 51 +++++++++++++++++++ public_html/templates/project/layout.tpl | 19 +++++++ 11 files changed, 254 insertions(+), 5 deletions(-) create mode 100644 .gitignore rename config.json => config.json.example (62%) create mode 100644 public_html/authenticators/project.php create mode 100644 public_html/debug.createuser.php create mode 100644 public_html/modules/error/project.php create mode 100644 public_html/modules/home/index.php create mode 100644 public_html/modules/project/index.php create mode 100644 public_html/rewrite.php create mode 100644 public_html/templates/home/layout.tpl create mode 100644 public_html/templates/project/index.tpl create mode 100644 public_html/templates/project/layout.tpl diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d344ba6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.json diff --git a/config.json b/config.json.example similarity index 62% rename from config.json rename to config.json.example index a465a4a..44abe10 100644 --- a/config.json +++ b/config.json.example @@ -20,11 +20,15 @@ "port": 11211 }, "class_map": { - "user": "User", - "interestgroup": "InterestGroup", - "project": "Project", - "repository": "Repository", - "ticket": "Ticket" + "user": "User", + "interestgroup": "InterestGroup", + "project": "Project", + "repository": "Repository", + "ticket": "Ticket", + "tickettag": "TicketTag", + "ticketmessage": "TicketMessage", + "ticketattachment": "TicketAttachment", + "logentry": "LogEntry" }, "components": [ "router", diff --git a/public_html/authenticators/project.php b/public_html/authenticators/project.php new file mode 100644 index 0000000..2c9bd7a --- /dev/null +++ b/public_html/authenticators/project.php @@ -0,0 +1,28 @@ +uParameters[1]; + +try +{ + $sProject = Project::CreateFromQuery("SELECT * FROM projects WHERE `Slug` = :Slug", array(":Slug" => $uSlug)); + NewTemplater::SetGlobalVariable("project-name", $sProject->sName); + NewTemplater::SetGlobalVariable("project-url", "/project/{$sProject->sSlug}"); + $sRouterAuthenticated = true; +} +catch (NotFoundException $e) +{ + $sRouterAuthenticated = false; +} diff --git a/public_html/debug.createuser.php b/public_html/debug.createuser.php new file mode 100644 index 0000000..2568baf --- /dev/null +++ b/public_html/debug.createuser.php @@ -0,0 +1,13 @@ +uUsername = "test"; +$sUser->uPassword = "test"; +$suser->uDisplayName = "Test user"; /* This does not work?! */ +$sUser->uEmailAddress = "test@test.com"; +$sUser->uIsActivated = true; +$sUser->uIsAdmin = true; +$sUser->GenerateSalt(); +$sUser->GenerateHash(); +$sUser->InsertIntoDatabase(); diff --git a/public_html/modules/error/project.php b/public_html/modules/error/project.php new file mode 100644 index 0000000..32f1e38 --- /dev/null +++ b/public_html/modules/error/project.php @@ -0,0 +1,16 @@ +strings, array( + "long-description" => $sProject->sLongDescription, + "no-downloads" => false, + "stable-version" => "1.5.3", + "experimental-version" => "1.6.1", + "line-count" => "62,671", + "ticket-count" => 12, + "tickets" => array(), + "more-tickets" => false +)); diff --git a/public_html/rewrite.php b/public_html/rewrite.php new file mode 100644 index 0000000..8cabec6 --- /dev/null +++ b/public_html/rewrite.php @@ -0,0 +1,63 @@ +allow_slash = true; +$router->ignore_query = true; + +$router->routes = array( + 0 => array( + "^/$" => "modules/home/index.php", + "^/project/([a-zA-Z0-9_-]+)$" => array("target" => "modules/project/index.php", + "authenticator" => "authenticators/project.php", + "auth_error" => "modules/error/project.php", + "_page_type" => "project"), + "^/project/([a-zA-Z0-9_-]+)/tickets$" => array("target" => "modules/project/tickets/index.php", + "authenticator" => "authenticators/project.php", + "auth_error" => "modules/error/project.php", + "_page_type" => "project"), + "^/project/([a-zA-Z0-9_-]+)/ticket/([0-9]+)$" => array("target" => "modules/project/tickets/view.php", + "authenticator" => "authenticators/project.php", + "auth_error" => "modules/error/project.php", + "_page_type" => "project"), + ) +); + +$router->RouteRequest(); + +if(empty($router->uVariables['page_type'])) +{ + $sContents = NewTemplater::Render("home/layout", $locale->strings, array( + "contents" => $sPageContents + )); +} +elseif($router->uVariables['page_type'] == "project") +{ + $sContents = NewTemplater::Render("project/layout", $locale->strings, array( + "contents" => $sPageContents + )); +} +else +{ + die(); +} + +echo(NewTemplater::Render("layout", $locale->strings, array( + "contents" => $sContents +))); + diff --git a/public_html/templates/home/layout.tpl b/public_html/templates/home/layout.tpl new file mode 100644 index 0000000..0f82bfb --- /dev/null +++ b/public_html/templates/home/layout.tpl @@ -0,0 +1,13 @@ +
+

Team

+
+
+ +
+ {%?contents} +
+
diff --git a/public_html/templates/project/index.tpl b/public_html/templates/project/index.tpl new file mode 100644 index 0000000..6817e8d --- /dev/null +++ b/public_html/templates/project/index.tpl @@ -0,0 +1,51 @@ + +
+

Introduction

+ {%?long-description} +
diff --git a/public_html/templates/project/layout.tpl b/public_html/templates/project/layout.tpl new file mode 100644 index 0000000..dc99c3f --- /dev/null +++ b/public_html/templates/project/layout.tpl @@ -0,0 +1,19 @@ +
+

Team

+

{%?project-name}

+
+
+ +
+ {%?contents} +
+