<commit_before><?php

require("lib/main.php");

// Database connection
require "lib/db.php";

$app = new Rout();

$login = new Login();

$posts = new Posts();
$posts->setDb($db);


$app->get("/", function() use($app){

	$app->render("home.php");

});

$app->get("/news", function() use($app, $posts){

    $post = [];

    foreach($posts->getPosts() as $row) {
        $post[] = $row;
    }

  	$app->render("news.php", $post);

});

$app->get("/post/:id", function($id) use($app, $posts) {

    $r = $posts->getPost($id);

    $app->render("article.php", $r);

});

$app->post("/add/post", function() use ($app, $posts, $login){

});


/* FOR TESTING PURPOSES

$app->get("/news/redir", function() use ($app){

	$app->redirect("/news/news");

});
<commit_msg>added more routes to index<commit_after><?php

require("lib/main.php");

// Database connection
require "lib/db.php";

$app = new Rout();

$login = new Login();

$posts = new Posts();
$posts->setDb($db);


$app->get("/", function() use($app){

	$app->render("home.php");

});

$app->get("/news", function() use($app, $posts){

    $post = [];

    foreach($posts->getPosts() as $row) {
        $post[] = $row;
    }

  	$app->render("news.php", $post);

});

$app->get("/post/:id", function($id) use($app, $posts) {

    $r = $posts->getPost($id);

    $app->render("article.php", $r);

});

$app->get("/post", function() use ($app, $login) {

	$app->render("add.php");

});

$app->post("/post/add", function() use ($app, $posts, $login){

	$cont = [];

	$cont[] = $_POST["title"];
	$cont[] = $_POST["text"];
	$cont[] = "default.jpg";
	$cont[] = $login->getUserId();

	$posts->addPost($cont);

});


/* FOR TESTING PURPOSES

$app->get("/news/redir", function() use ($app){

	$app->redirect("/news");

});

{'fraction_non_alphanumeric': 0.28401360544217685, 'fraction_numerical': 0.0, 'mean_word_length': 3.77027027027027, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2693537', 'n_tokens_mistral': 689, 'n_tokens_neox': 667, 'n_words': 128}