<commit_before><?php

/*
  |--------------------------------------------------------------------------
  | Application \Routes
  |--------------------------------------------------------------------------
  |
  | Here is where you can register all of the routes for an application.
  | It's a breeze. Simply tell Laravel the URIs it should respond to
  | and give it the Closure to execute when that URI is requested.
  |
 */

use OMLB\Models\Post\Repository\PostRepositoryFactory;
use OMLB\Models\Comment\Comment;

/**
 * Backoffice routes
 * */
\Route::group(['prefix' => 'admin',  'before' => 'auth.basic'], function() {
    
    \Route::get('/', ['as' => 'admin.dashboard', function() {
        $posts = PostRepositoryFactory::make()->getAll('admin');
        $unpublished_comments_count = Comment::wherePublished('0')->count();
        return View::make(\Config::get('blog.theme').'::admin.dashboard', compact('posts', 'unpublished_comments_count'));
    }]);
    
    \Route::group(['prefix' => 'post'], function() { 
	    // edit/post
	    // edit
	    \Route::get('/edit/{id?}', ['as' => 'admin.post.edit', function($id = null) {
                $post = PostRepositoryFactory::make()->getByIdOrNew($id);            
                return View::make(\Config::get('blog.theme').'::admin.edit', compact('post'));
            }]);
            
	    // post
	    \Route::post('/edit/{id?}', ['as' => 'admin.post.submit', function($id = null) {
                $inputs = Input::only(['title', 'slug', 'teaser', 'content', 'published', 'hidden-tags']);

                if(PostRepositoryFactory::make()->save($id, $inputs))
                {
                    return Redirect::route('admin.dashboard')->with('message', Lang::get('admin.post.saved'));
                }
                return Redirect::back()->withInput()->withErrors(Session::get('errors'));
            }]);

	    \Route::get('/togglePublished/{id}', ['as' => 'admin.post.togglePublished', function($id) {
                $post = PostRepositoryFactory::make()->getById($id);
                $post->published = abs($post->published - 1);
                $post->save();
                return Redirect::back()->with('message', $post->published ? 'published' : 'unpublished');
            }]);

	    \Route::post('/delete/{id}', ['as' => 'admin.post.delete', function($id) {
                if(PostRepositoryFactory::make()->getById($id)->delete())    {
                    return Redirect::back()->with('message', trans('admin.post.deleted'));
                }
                return Redirect::back()->with('message', trans('admin.post.deletion_failled'));
            }]);

	    \Route::get('/preview/{slug}', ['as' => 'admin.post.preview',  function($slug) {
	        $post = PostRepositoryFactory::make()->getBySlug($slug);
	        if ($post)
	        {
	            return View::make(\Config::get('blog.theme').'::post', compact('post'));
	        }
	        app::abort(404);
	    }]);
	});

    \Route::group(['prefix' => 'comment'], function() {

	    \Route::get('/moderate', ['as' => 'admin.comment.moderate', function() {
		    $unpublished_comments = Comment::wherePublished('0')->paginate(\Config::get('blog.comments_per_page_admin', 20));
		    return View::make(\Config::get('blog.theme').'::admin.comment_moderate', compact('unpublished_comments'));
		}]);

	    \Route::get('/approuve/{comment_id}', ['as' => 'admin.comment.approuve', function($comment_id) {
		    $comment = Comment::whereId($comment_id)->first();
		    if ($comment->approve())
		    {
		        return Redirect::back()->with('message', 'admin.comment.approved');
		    }
		    return Redirect::back()->with('error', 'admin.comment.approved_failled');
		}]);

	    \Route::get('/delete/{comment_id}', ['as' => 'admin.comment.delete', function($comment_id) {
	        $comment = Comment::whereId($comment_id)->first();
	        if ($comment->delete())
	        {
	            return Redirect::back()->with('message', 'admin.comment.deleted');
	        }
	    }]);
	});
        
    \Route::group(['prefix' => 'cache'], function() {
    
        \Route::get('flush', ['as' => 'admin.cache.flush', function() {
            BlogCacheManager::flush();
            return Redirect::back()->with('message', Lang::get('admin.cache.flushed'));
        }]);
    });
});


/**
 * Front office routes
 * */
\Route::group(['before' => 'cache_retrieve', 'after' => 'cache_create'], function() {
    \Route::get('/', ['as' => 'home', function() {
        $posts = PostRepositoryFactory::make()->getAll();
        return View::make(\Config::get('blog.theme').'::home', compact('posts'))->render();
    }
    ]);
<commit_msg>fix translations in route.php<commit_after><?php

/*
  |--------------------------------------------------------------------------
  | Application \Routes
  |--------------------------------------------------------------------------
  |
  | Here is where you can register all of the routes for an application.
  | It's a breeze. Simply tell Laravel the URIs it should respond to
  | and give it the Closure to execute when that URI is requested.
  |
 */

use OMLB\Models\Post\Repository\PostRepositoryFactory;
use OMLB\Models\Comment\Comment;

/**
 * Backoffice routes
 * */
\Route::group(['prefix' => 'admin',  'before' => 'auth.basic'], function() {
    
    \Route::get('/', ['as' => 'admin.dashboard', function() {
        $posts = PostRepositoryFactory::make()->getAll('admin');
        $unpublished_comments_count = Comment::wherePublished('0')->count();
        return View::make(\Config::get('blog.theme').'::admin.dashboard', compact('posts', 'unpublished_comments_count'));
    }]);
    
    \Route::group(['prefix' => 'post'], function() { 
	    // edit/post
	    // edit
	    \Route::get('/edit/{id?}', ['as' => 'admin.post.edit', function($id = null) {
                $post = PostRepositoryFactory::make()->getByIdOrNew($id);            
                return View::make(\Config::get('blog.theme').'::admin.edit', compact('post'));
            }]);
            
	    // post
	    \Route::post('/edit/{id?}', ['as' => 'admin.post.submit', function($id = null) {
                $inputs = Input::only(['title', 'slug', 'teaser', 'content', 'published', 'hidden-tags']);

                if(PostRepositoryFactory::make()->save($id, $inputs))
                {
                    return Redirect::route('admin.dashboard')->with('message', trans('admin.post.saved'));
                }
                return Redirect::back()->withInput()->withErrors(Session::get('errors'));
            }]);

	    \Route::get('/togglePublished/{id}', ['as' => 'admin.post.togglePublished', function($id) {
                $post = PostRepositoryFactory::make()->getById($id);
                $post->published = abs($post->published - 1);
                $post->save();
                return Redirect::back()->with('message', $post->published ? 'published' : 'unpublished');
            }]);

	    \Route::post('/delete/{id}', ['as' => 'admin.post.delete', function($id) {
                if(PostRepositoryFactory::make()->getById($id)->delete())    {
                    return Redirect::back()->with('message', trans('admin.post.deleted'));
                }
                return Redirect::back()->with('message', trans('admin.post.deletion_failled'));
            }]);

	    \Route::get('/preview/{slug}', ['as' => 'admin.post.preview',  function($slug) {
	        $post = PostRepositoryFactory::make()->getBySlug($slug);
	        if ($post)
	        {
	            return View::make(\Config::get('blog.theme').'::post', compact('post'));
	        }
	        app::abort(404);
	    }]);
	});

    \Route::group(['prefix' => 'comment'], function() {

	    \Route::get('/moderate', ['as' => 'admin.comment.moderate', function() {
		    $unpublished_comments = Comment::wherePublished('0')->paginate(\Config::get('blog.comments_per_page_admin', 20));
		    return View::make(\Config::get('blog.theme').'::admin.comment_moderate', compact('unpublished_comments'));
		}]);

	    \Route::get('/approuve/{comment_id}', ['as' => 'admin.comment.approuve', function($comment_id) {
		    $comment = Comment::whereId($comment_id)->first();
		    if ($comment->approve())
		    {
		        return Redirect::back()->with('message', trans('admin.comment.approved') );
		    }
		    return Redirect::back()->with('error', trans('admin.comment.approved_failled') );
		}]);

	    \Route::get('/delete/{comment_id}', ['as' => 'admin.comment.delete', function($comment_id) {
	        $comment = Comment::whereId($comment_id)->first();
	        if ($comment->delete())
	        {
	            return Redirect::back()->with('message', trans('admin.comment.deleted'));
	        }
	    }]);
	});
        
    \Route::group(['prefix' => 'cache'], function() {
    
        \Route::get('flush', ['as' => 'admin.cache.flush', function() {
            BlogCacheManager::flush();
            return Redirect::back()->with('message', trans('admin.cache.flushed'));
        }]);
    });
});


/**
 * Front office routes
 * */
\Route::group(['before' => 'cache_retrieve', 'after' => 'cache_create'], function() {
    \Route::get('/', ['as' => 'home', function() {
        $posts = PostRepositoryFactory::make()->getAll();
        return View::make(\Config::get('blog.theme').'::home', compact('posts'))->render();
    }
    ]);

{'fraction_non_alphanumeric': 0.24179933753606153, 'fraction_numerical': 0.0017095843573031308, 'mean_word_length': 2.4912346139500188, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 97, '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': '1146340', 'n_tokens_mistral': 2730, 'n_tokens_neox': 2580, 'n_words': 407}