Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: eahlys/EdPaste
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: pitchum/EdPaste
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: auth-cas
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.

Commits on Dec 23, 2018

  1. Remove captcha

    vrumger committed Dec 23, 2018
    Copy the full SHA
    4d4ec09 View commit details
  2. Copy the full SHA
    ccfbcf1 View commit details

Commits on Dec 24, 2018

  1. Copy the full SHA
    b179924 View commit details
  2. Copy the full SHA
    7c56f23 View commit details
  3. Copy the full SHA
    ec591ed View commit details
  4. Add timezone to .env

    vrumger committed Dec 24, 2018
    Copy the full SHA
    f20a225 View commit details
  5. Copy the full SHA
    654580e View commit details
  6. Fix dashboard content section

    vrumger committed Dec 24, 2018
    Copy the full SHA
    68d43ab View commit details

Commits on Dec 26, 2018

  1. Add editing pastes

    vrumger committed Dec 26, 2018
    Copy the full SHA
    07096b2 View commit details
  2. Copy the full SHA
    162c981 View commit details
  3. Update date format

    vrumger committed Dec 26, 2018
    Copy the full SHA
    7ecc7d2 View commit details
  4. Fix navbar when editing

    vrumger committed Dec 26, 2018
    Copy the full SHA
    25851ad View commit details

Commits on Jan 9, 2019

  1. Copy the full SHA
    a05023b View commit details
  2. Fix error with https

    vrumger committed Jan 9, 2019
    Copy the full SHA
    fa803c3 View commit details

Commits on Feb 5, 2019

  1. Update view.blade.php

    vrumger authored Feb 5, 2019
    Copy the full SHA
    9917075 View commit details

Commits on Sep 19, 2019

  1. Copy the full SHA
    fe674c1 View commit details
  2. Add CHANGELOG.md

    pitchum committed Sep 19, 2019
    Copy the full SHA
    897de15 View commit details
  3. Copy the full SHA
    05b9dca View commit details
  4. Copy the full SHA
    aa1a63d View commit details
  5. Copy the full SHA
    d9e64a8 View commit details

Commits on Oct 4, 2019

  1. CAS Auth is operational.

    pitchum committed Oct 4, 2019
    Copy the full SHA
    2e576ed View commit details
  2. Copy the full SHA
    3e0cf0c View commit details
  3. Add example CAS config file.

    pitchum committed Oct 4, 2019
    Copy the full SHA
    26ac2f8 View commit details
  4. Copy the full SHA
    313996f View commit details

Commits on Oct 7, 2019

  1. Copy the full SHA
    ef4cbd5 View commit details

Commits on Oct 21, 2019

  1. Copy the full SHA
    251b493 View commit details
  2. Copy the full SHA
    00a6899 View commit details
  3. Copy the full SHA
    7c7eedb View commit details
  4. Minor change.

    pitchum committed Oct 21, 2019
    Copy the full SHA
    d0eacf0 View commit details

Commits on Oct 24, 2019

  1. Improve pgsql compat.

    pitchum committed Oct 24, 2019
    Copy the full SHA
    6a84bb0 View commit details
  2. Improve pgsql compat.

    pitchum committed Oct 24, 2019
    Copy the full SHA
    0e8d72f View commit details

Commits on Oct 28, 2019

  1. Copy the full SHA
    d6ac876 View commit details
  2. Update composer.lock

    pitchum committed Oct 28, 2019
    Copy the full SHA
    d35fd42 View commit details
  3. New visibility option: "internal"

    Share pastes only with CAS authenticated users.
    pitchum committed Oct 28, 2019
    Copy the full SHA
    63c7157 View commit details
  4. Copy the full SHA
    a50748c View commit details

Commits on Nov 8, 2019

  1. Enable i18n.

    pitchum committed Nov 8, 2019
    Copy the full SHA
    a00210c View commit details

Commits on Mar 13, 2020

  1. Update french translations.

    pitchum committed Mar 13, 2020
    Copy the full SHA
    25f7730 View commit details
  2. Add missing translatable strings.

    fr and en translations included.
    pitchum committed Mar 13, 2020
    Copy the full SHA
    91ce2e0 View commit details
  3. Copy the full SHA
    5b5bf81 View commit details

Commits on Mar 26, 2020

  1. Set LOCALE in .env.

    pitchum committed Mar 26, 2020
    Copy the full SHA
    4a174bb View commit details
  2. Copy the full SHA
    72cd15e View commit details

Commits on Aug 21, 2020

  1. Copy the full SHA
    7120a54 View commit details
  2. Copy the full SHA
    68d9e50 View commit details
  3. Update changelog.

    pitchum committed Aug 21, 2020
    Copy the full SHA
    6d678ca View commit details

Commits on Sep 22, 2020

  1. Change wording on page 404.

    pitchum committed Sep 22, 2020
    Copy the full SHA
    131b51a View commit details

Commits on Oct 9, 2020

  1. Copy the full SHA
    f71014a View commit details
  2. Copy the full SHA
    5ff933b View commit details
  3. Copy the full SHA
    5280dfb View commit details
  4. Copy the full SHA
    81a45a7 View commit details
  5. Add translatable string.

    pitchum committed Oct 9, 2020
    Copy the full SHA
    fa89e47 View commit details
Showing with 3,153 additions and 1,427 deletions.
  1. +1 −2 .env.example
  2. +1 −0 .gitignore
  3. +34 −0 CHANGELOG.md
  4. +8 −3 README.md
  5. +4 −0 app/Http/Controllers/Auth/LoginController.php
  6. +124 −0 app/Http/Controllers/EditPasteController.php
  7. +277 −232 app/Http/Controllers/PasteController.php
  8. +9 −9 app/Http/Controllers/UserController.php
  9. +4 −0 app/Http/Kernel.php
  10. +26 −0 app/Http/Middleware/HttpsProtocol.php
  11. +23 −0 app/Http/Middleware/Localization.php
  12. +43 −0 app/Http/Requests/EditPaste.php
  13. +3 −12 app/Http/Requests/StorePaste.php
  14. +1 −1 app/Paste.php
  15. +37 −0 app/User.php
  16. +6 −3 composer.json
  17. +1,862 −967 composer.lock
  18. +5 −6 config/app.php
  19. +170 −0 config/cas.example.php
  20. +2 −2 database/migrations/2018_03_21_174309_update-paste-expiration.php
  21. +4 −10 database/migrations/2018_04_09_134904_utf8mb4.php
  22. +44 −0 database/migrations/2020_05_22_100435_invert_syntaxhl_option.php
  23. +81 −0 resources/lang/en/edpaste.php
  24. +81 −0 resources/lang/fr/edpaste.php
  25. +4 −2 resources/views/auth/login.blade.php
  26. +5 −13 resources/views/auth/register.blade.php
  27. +8 −8 resources/views/default.blade.php
  28. +17 −11 resources/views/errors/404.blade.php
  29. +3 −2 resources/views/layouts/app.blade.php
  30. +15 −13 resources/views/paste/account.blade.php
  31. +43 −37 resources/views/paste/dashboard.blade.php
  32. +131 −0 resources/views/paste/edit.blade.php
  33. +29 −38 resources/views/paste/index.blade.php
  34. +9 −7 resources/views/paste/password.blade.php
  35. +30 −42 resources/views/paste/view.blade.php
  36. +3 −3 routes/api.php
  37. +6 −4 routes/web.php
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -33,5 +33,4 @@ PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=

NOCAPTCHA_SECRET=get it at https://www.google.com/recaptcha
NOCAPTCHA_SITEKEY=get it at https://www.google.com/recaptcha
TIMEZONE=UTC
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -45,3 +45,4 @@ composer.phar
/.vscode
composer.lock
/.vscode
config/cas.php
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Next release

- Allow minimal branding (customizeable app name)
- Misc translation fixes
- Add more expiration options
- Add logout button


## 1.1.1 - 2020-09-22

- Minor changes (wording)


## 1.1.0 - 2020-08-21

- Enable syntax HL instead of disable
- Better 404 page, suggesting authentication
- Redirect to the requested paste after succeasful authentication


## 1.0.0 - 2020-05-03

- CAS authentication


## 0.1 - 2018-12-19

Forking from Edraens/EdPaste
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# EdPaste
EdPaste is a Laravel 5.5 (PHP Framework)-driven self-hosted Pastebin. Demo : https://paste.edra.ovh

EdPaste is self-hosted Pastebin.

It is a Laravel 5.5 (PHP Framework)-driven self-hosted Pastebin. Demo : https://paste.edra.ovh

## Features :
- Privacy options
@@ -8,6 +11,7 @@ EdPaste is a Laravel 5.5 (PHP Framework)-driven self-hosted Pastebin. Demo : htt
- Password protection (server-side hashed)
- User dashboard
- Raw paste viewing
- CAS authentication

Just git clone this repo on your server, make the `public` folder your webserver's `DocumentRoot`, for instance with an Apache2.4 VirtualHost :
```
@@ -18,8 +22,9 @@ Just git clone this repo on your server, make the `public` folder your webserver
```
Run a `composer install`/`php composer install` (depends of your configuration) within the app root path (you'll need composer)
Rename `.env.example` to `.env` and run `php artisan key:generate` from the app's root path.
Open `.env` and fill it with your database details, and with Secret and Site Key from Google's reCaptcha (in order to avoid spam from guests)
Open `.env` and fill it with your database details
Run `php artisan migrate` from the app's root path, and you're all done.
Copy and adapt CAS configuration from `config/cas.example.php` to `config/cas.php`.

Go to `http://your.vhost.server.com/` which leads to the DocumentRoot `/app/path/public`, and this should work !

@@ -36,4 +41,4 @@ You're free to fork this and modify it as you want (according to MIT license), b

# Todo :
- Admin panel
- Fix raw view
- Fix raw view
4 changes: 4 additions & 0 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
@@ -36,4 +36,8 @@ public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}

public function casLogout(){
cas()->logoutWithRedirectService(cas()->getConfig()['cas_logout_redirect']);
}
}
124 changes: 124 additions & 0 deletions app/Http/Controllers/EditPasteController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Paste;
use Auth;
use App\User;
use \Input;
use \Hash;
use Session;
use Cookie;
use DB;
use \Carbon;

class EditPasteController extends Controller
{
public function index($link, Request $request){
$paste = Paste::where('link', $link)->firstOrFail();

// Est-ce que l'utilisateur connecté est celui qui a écrit la paste ?
if (!User::is_owner($paste) || $paste->userId == 0) {
return abort('403');
}

// Renvoi de la view
return view('paste/edit', [
'username' => ($paste->userId != 0) ? $paste->user->name : 'Guest',
'link' => $link,
'title' => ($paste->title != 'Untitled') ? $paste->title : '',
'content' => $paste->content,
'expiration' => $paste->expiration,
'privacy' => $paste->privacy,
'date' => $paste->created_at->format('Y-m-d'),
'fulldate' => $paste->created_at->format('Y-m-d H:i:s'),
'syntaxHl' => $paste->syntaxHl,
]);
}

public function edit($link, Requests\EditPaste $request){
$paste = Paste::where('link', $link)->firstOrFail();

// Est-ce que l'utilisateur connecté est celui qui a écrit la paste ?
if (!User::is_owner($paste) || $paste->userId == 0) {
return abort('403');
}

$title = (empty(trim(Input::get('pasteTitle')))) ? __('edpaste.paste.untitled') : Input::get('pasteTitle');

$expiration = Input::get('expire');
$privacy = Input::get('privacy');

// Ici on vérifie que l'user a pas foutu le bronx dans les dropdown list
$possibleValuesPrivacy = array("link", "internal", "password", "private");
if (in_array($privacy, $possibleValuesPrivacy) == false) return view('paste/edit');

// Si l'user a choisi password-protected, on hash son pass, sinon on met 'disabled' dans la variable
if ($privacy == 'password') $password = bcrypt(Input::get('pastePassword'));
else $password = 'disabled';

$burnAfter = 0;
// Ici on génère le timestamp d'expiration
switch ($expiration) {
case 'never':
$timestampExp = 0;
break;
case 'burn':
$timestampExp = date('Y-m-d H:i:s', time());
$burnAfter = 1;
break;
case '10m':
$timestampExp = date('Y-m-d H:i:s', time()+600);
break;
case '1h':
$timestampExp = date('Y-m-d H:i:s', time()+3600);
break;
case '1d':
$timestampExp = date('Y-m-d H:i:s', time()+86400);
break;
case '1w':
$timestampExp = date('Y-m-d H:i:s', time()+604800);
break;
case '1m':
$timestampExp = date('Y-m-d H:i:s', time()+2678400);
break;
case '3m':
$timestampExp = date('Y-m-d H:i:s', time()+8035200);
break;
default:
die("User input error.");
break;
}

$paste->title = $title;
$paste->content = Input::get('pasteContent');
$paste->expiration = $timestampExp;
$paste->privacy = $privacy;
$paste->password = $password;
$paste->syntaxHl = Input::has('syntaxHl');
$paste->burnAfter = $burnAfter;

$paste->save();

return redirect('/'.$link);
}

public function password($link, Request $request){
$paste = Paste::where('link', $link)->firstOrFail();
$messages = array(
'pastePassword.required' => __('edpaste.validation.error.password'),
);
$this->validate($request, [
'pastePassword' => 'required',
], $messages);

if (Hash::check(Input::get('pastePassword'), $paste->password)) {
Cookie::queue($paste->link, Input::get('pastePassword'), 15);
return redirect('/'.$link);
}
else {
return view('paste/password', ['link' => $paste->link, 'wrongPassword' => true]);
}
}
}
509 changes: 277 additions & 232 deletions app/Http/Controllers/PasteController.php

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
@@ -18,26 +18,26 @@ class UserController extends Controller
// Every function in this controller requires auth
public function __construct()
{
$this->middleware('auth');
//$this->middleware('auth');
}

public function dashboard(){
return view('paste/dashboard', ['userPastes' => Auth::user()->pastes()->get()]);
return view('paste/dashboard', ['userPastes' => User::getCurrentUser()->pastes()->get()]);
}
public function delete($link){
if (!Auth::check()) return redirect('/');
if (!cas()->isAuthenticated()) return redirect('/');
$userPaste = Paste::where('link', $link)->firstOrFail();
if ($userPaste->userId != Auth::user()->id) return redirect('/login');
if ($userPaste->userId != User::getCurrentUser()->id) return redirect('/login');
$userPaste->forceDelete();
return redirect('/users/dashboard');
}
public function account(){
if (!Auth::check()) return redirect('/login');
$user = User::where('id', Auth::user()->id)->first();
if (!cas()->isAuthenticated()) return redirect('/login');
$user = User::where('id', User::getCurrentUser()->id)->first();
return view('paste.account', ['user' => $user]);
}
public function editAccount(Request $request){
if (!Auth::check()) return redirect('/login');
if (!cas()->isAuthenticated()) return redirect('/login');
if (Input::get('password') != ""){
$this->validate($request, [
'name' => 'max:30|required',
@@ -53,9 +53,9 @@ public function editAccount(Request $request){
'email' => 'required|email',
]);
}
$user = User::where('id', Auth::user()->id)->first();
$user = User::where('id', User::getCurrentUser()->id)->first();
$checkEmail = User::where('email', Input::get('email'))->first();
if (!is_null($checkEmail) && $checkEmail->id != Auth::user()->id) return Redirect::back()->withErrors(['Specified e-mail address already exists']);
if (!is_null($checkEmail) && $checkEmail->id != User::getCurrentUser()->id) return Redirect::back()->withErrors(['Specified e-mail address already exists']);
$user->name = Input::get('name');
$user->email = Input::get('email');
if (Input::get('password') != "") {
4 changes: 4 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@ class Kernel extends HttpKernel
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\HttpsProtocol::class,
\App\Http\Middleware\Localization::class,
],

'api' => [
@@ -48,6 +50,8 @@ class Kernel extends HttpKernel
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'cas.auth' => \Subfission\Cas\Middleware\CASAuth::class,
'cas.guest' => \Subfission\Cas\Middleware\RedirectCASAuthenticated::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
26 changes: 26 additions & 0 deletions app/Http/Middleware/HttpsProtocol.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\Http\Middleware;

use App;
use Closure;

class HttpsProtocol
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// https://stackoverflow.com/a/28403907
if (!$request->secure() && App::environment() === 'production') {
return redirect()->secure($request->getRequestUri());
}

return $next($request);
}
}
23 changes: 23 additions & 0 deletions app/Http/Middleware/Localization.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Http\Middleware;

use Closure;

class Localization
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (session()->has('locale')) {
App::setLocale(session()->get('locale'));
}
return $next($request);
}
}
43 changes: 43 additions & 0 deletions app/Http/Requests/EditPaste.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class EditPaste extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'pasteTitle' => 'max:70',
'pasteContent' => 'required',
'pastePassword' => 'required_if:privacy,password',
'expire' => 'required',
];
}

public function messages()
{
return [
'pasteContent.required' => __('edpaste.validation.error.notempty'),
'pastePassword.required_if' => __('edpaste.validation.error.password'),
'pasteTitle.max' => __('edpaste.validation.error.maxlength'),
'expire.required' => __('edpaste.validation.error.expiration.required'),
];
}
}
15 changes: 3 additions & 12 deletions app/Http/Requests/StorePaste.php
Original file line number Diff line number Diff line change
@@ -34,18 +34,9 @@ public function rules()
public function messages()
{
return [
'pasteContent.required' => 'Your paste cannot be empty',
'pastePassword.required_if' => 'Please enter a password',
'pasteTitle.max' => 'Title must not exceed 70 characters',
'g-recaptcha-response.required' => 'Captcha required',
'g-recaptcha-response.captcha' => 'Captcha required'
'pasteContent.required' => 'Your paste cannot be empty.',
'pastePassword.required_if' => 'Please enter a password.',
'pasteTitle.max' => 'Title must not exceed 70 characters.',
];
}

public function withValidator($validator)
{
$validator->sometimes('g-recaptcha-response', 'required|captcha', function ($input) {
return !\Auth::check();
});
}
}
2 changes: 1 addition & 1 deletion app/Paste.php
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

class Paste extends Model
{
protected $fillable = ['link', 'userId', 'title', 'content', 'ip', 'noSyntax', 'expiration', 'privacy', 'password', 'views', 'burnAfter'];
protected $fillable = ['link', 'userId', 'title', 'content', 'ip', 'syntaxHl', 'expiration', 'privacy', 'password', 'views', 'burnAfter'];

public function user()
{
37 changes: 37 additions & 0 deletions app/User.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Support\Facades\Log;

class User extends Authenticatable
{
@@ -31,4 +32,40 @@ public function pastes()
{
return $this->hasMany('App\Paste', 'userId');
}

public static function create_if_absent($username) {
$user = User::where('name', $username)->first();
if ($user == null) {
Log::debug('Inserting new user.', ['username' => $username]);
$user = User::create([
'name' => $username,
'email' => $username .'@example.local',
'password' => '',
]);
Log::info('User created.', ['user' => $user]);
}
return $user;
}


/**
* This stupid function exists because I couldn't find how to
* properly implement CAS authentication as a Facade for Auth.
* When I have time I'll try to read all Laravel doc and find out.
*/
public static function getCurrentUser() {
cas()->isAuthenticated(); // XXX workaround CAS_OutOfSequenceBeforeAuthenticationCallException (because I don't know how to use Laravel properly)
$username = cas()->getCurrentUser();
$user = User::where('name', $username)->first();
if ($user == null) {
$user = User::create_if_absent($username);
}
return $user;
}

public static function is_owner($paste) {
$user = User::getCurrentUser();
return (($user->id == $paste->userId && $paste->userId != 0)) ? true : false;
}

}
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.1.3",
"laravel/framework": "5.7.*",
"anhskohbo/no-captcha": "3.*",
"laravel/framework": ">=5.7 <6.0",
"subfission/cas": ">=2.1.1 <3.0",
"soundasleep/html2text": "~0.3"
},
"require-dev": {
2,829 changes: 1,862 additions & 967 deletions composer.lock

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions config/app.php
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
| any other location as required by the application or its packages.
*/

'name' => 'Laravel',
'name' => env('APP_NAME', 'Laravel'),

/*
|--------------------------------------------------------------------------
@@ -64,7 +64,7 @@
|
*/

'timezone' => 'UTC',
'timezone' => env('TIMEZONE', 'UTC'),

/*
|--------------------------------------------------------------------------
@@ -77,7 +77,7 @@
|
*/

'locale' => 'en',
'locale' => env('LOCALE', 'en'),

/*
|--------------------------------------------------------------------------
@@ -166,8 +166,7 @@
/*
* Package Service Providers...
*/

//
Subfission\Cas\CasServiceProvider::class,

/*
* Application Service Providers...
@@ -177,7 +176,6 @@
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Anhskohbo\NoCaptcha\NoCaptchaServiceProvider::class,

],

@@ -200,6 +198,7 @@
'Blade' => Illuminate\Support\Facades\Blade::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Cas' => Subfission\Cas\Facades\Cas::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
170 changes: 170 additions & 0 deletions config/cas.example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| CAS Hostname
|--------------------------------------------------------------------------
| Example: 'cas.myuniv.edu'.
*/
'cas_hostname' => env('CAS_HOSTNAME', 'sso.mycompany.com'),

/*
|--------------------------------------------------------------------------
| CAS Authorized Hosts
|--------------------------------------------------------------------------
| Example: 'cas.myuniv.edu'. This is used when SAML is active and is
| recommended for protecting against DOS attacks. If using load
| balanced hosts, then separate each with a comma.
*/
'cas_real_hosts' => env('CAS_REAL_HOSTS', 'sso.mycompany.com'),


/*
|--------------------------------------------------------------------------
| Customize CAS Session Cookie Name
|--------------------------------------------------------------------------
*/
'cas_session_name' => env('CAS_SESSION_NAME', 'CASAuth'),

/*
|--------------------------------------------------------------------------
| Laravel has it's own authentication sessions. Unless you want phpCAS
| to manage the session, leave this set to false. Note that the
| middleware and redirect classes will be handling removal
| of the Laravel sessions when this is set to false.
|--------------------------------------------------------------------------
*/
'cas_control_session' => env('CAS_CONTROL_SESSIONS', false),

/*
|--------------------------------------------------------------------------
| Enable using this as a cas proxy
|--------------------------------------------------------------------------
*/
'cas_proxy' => env('CAS_PROXY', false),

/*
|--------------------------------------------------------------------------
| Cas Port
|--------------------------------------------------------------------------
| Usually 443
*/
'cas_port' => env('CAS_PORT', 443),

/*
|--------------------------------------------------------------------------
| CAS URI
|--------------------------------------------------------------------------
| Sometimes is /cas
*/
'cas_uri' => env('CAS_URI', '/idp/cas'),

/*
|--------------------------------------------------------------------------
| CAS Validation
|--------------------------------------------------------------------------
| CAS server SSL validation: 'self' for self-signed certificate, 'ca' for
| certificate from a CA, empty for no SSL validation.
|
| VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS PROTOCOL
*/
'cas_validation' => env('CAS_VALIDATION', ''),

/*
|--------------------------------------------------------------------------
| CA Certificate
|--------------------------------------------------------------------------
| Path to the CA certificate file. For production use set
| the CA certificate that is the issuer of the cert
*/
'cas_cert' => env('CAS_CERT', ''),

/*
|--------------------------------------------------------------------------
| CN Validation (if you are using CA certs)
|--------------------------------------------------------------------------
| If for some reason you want to disable validating the certificate
| intermediaries, here is where you can. Recommended to leave
| this set with default (true).
*/
'cas_validate_cn' => env('CAS_VALIDATE_CN', true),

/*
|--------------------------------------------------------------------------
| CAS Login URI
|--------------------------------------------------------------------------
| Empty is fine
*/
'cas_login_url' => env('CAS_LOGIN_URL', ''),

/*
|--------------------------------------------------------------------------
| CAS Logout URI
|--------------------------------------------------------------------------
*/
'cas_logout_url' => env('CAS_LOGOUT_URL', 'https://sso.mycompany.com/idp/cas/logout'),

/*
|--------------------------------------------------------------------------
| CAS Logout Redirect Services
|--------------------------------------------------------------------------
| If your server supports redirection services, enter the redirect url
| in this section. If left blank, it will default to disabled.
*/
'cas_logout_redirect' => env('CAS_LOGOUT_REDIRECT', ''),

/*
|--------------------------------------------------------------------------
| CAS Successful Logon Redirection Url
|--------------------------------------------------------------------------
| By default, CAS will assume that the user should be redirected to the
| page in which the call was initiated. You can override this method
| and force the user to be redirected to a specific URL here.
*/
'cas_redirect_path' => env('CAS_REDIRECT_PATH', ''),

/*
|--------------------------------------------------------------------------
| CAS Supports SAML 1.1, allowing you to retrieve more than just the
| user identifier. If your CAS authentication service supports
| this feature, you may be able to retrieve user meta data.
|--------------------------------------------------------------------------
*/
'cas_enable_saml' => env('CAS_ENABLE_SAML', false),

/*
|--------------------------------------------------------------------------
| CAS will support version 1.0, 2.0, 3.0 of the protocol. It is recommended
| to use version 2.0, 3.0, or SAML 1.1. If you enable SAML, then that
| will override this configuration.
|--------------------------------------------------------------------------
*/
'cas_version' => env('CAS_VERSION', "2.0"),

/*
|--------------------------------------------------------------------------
| Enable PHPCas Debug Mode
| Options are:
| 1) true (defaults logfile creation to /tmp/phpCAS.log)
| 2) 'path/to/logfile'
| 3) false
|--------------------------------------------------------------------------
*/
'cas_debug' => env('CAS_DEBUG', false),

/*
|--------------------------------------------------------------------------
| Enable Verbose error messages. Not recommended for production.
| true | false
|--------------------------------------------------------------------------
*/
'cas_verbose_errors' => env('CAS_VERBOSE_ERRORS', false),

/*
|--------------------------------------------------------------------------
| This will cause CAS to skip authentication and assume this user id.
| This should only be used for developmental purposes. getAttributes()
| will return null in this condition.
*/
'cas_masquerade' => env('CAS_MASQUERADE', '')
];
Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@ public function up()
{
Schema::table('pastes', function(Blueprint $table){
$table->boolean('burnAfter');
DB::statement('UPDATE pastes SET expiration = "1990-01-01 00:00:00" WHERE expiration IN ("expired", "10m", "1d", "1w", "1h", "burn");');
DB::statement('UPDATE pastes SET expiration = "0" WHERE expiration = "never";');
DB::statement("UPDATE pastes SET expiration = '1990-01-01 00:00:00' WHERE expiration IN ('expired', '10m', '1d', '1w', '1h', 'burn');");
DB::statement("UPDATE pastes SET expiration = '0' WHERE expiration = 'never';");
});
}

14 changes: 4 additions & 10 deletions database/migrations/2018_04_09_134904_utf8mb4.php
Original file line number Diff line number Diff line change
@@ -12,15 +12,9 @@ class Utf8mb4 extends Migration
* @return void
*/
public function up() {
DB::unprepared('ALTER TABLE `pastes` CONVERT TO CHARACTER SET utf8mb4');
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down() {
DB::unprepared('ALTER TABLE `pastes` CONVERT TO CHARACTER SET utf8');
Schema::table('pastes', function (Blueprint $table) {
$table->charset = 'utf8';
});
}

}
44 changes: 44 additions & 0 deletions database/migrations/2020_05_22_100435_invert_syntaxhl_option.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

use App\Paste;

class InvertSyntaxhlOption extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('pastes', function (Blueprint $table) {
$table->boolean('syntaxHl')->nullable();
});
Paste::where('noSyntax', 1)->update(['syntaxHl' => 0]);
Paste::where('noSyntax', 0)->update(['syntaxHl' => 1]);
Schema::table('pastes', function (Blueprint $table) {
$table->dropColumn(['noSyntax']);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('pastes', function (Blueprint $table) {
$table->boolean('noSyntax')->nullable();
});
Paste::where('syntaxHl', 1)->update(['noSyntax' => 0]);
Paste::where('syntaxHl', 0)->update(['noSyntax' => 1]);
Schema::table('pastes', function (Blueprint $table) {
$table->dropColumn(['syntaxHl']);
});
}
}
81 changes: 81 additions & 0 deletions resources/lang/en/edpaste.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

return [

'page.title.dashboard' => 'Dashboard',
'page.title.home' => 'Home',
'page.title.notfound' => 'Not found',
'page.title.account' => 'My Account',
'page.title.login' => 'Login',
'page.title.register' => 'Register',

'menu.home' => 'Home',
'menu.dashboard' => 'Dashboard',
'menu.logout' => 'Logout',
'button.yes' => 'Yes',
'button.no' => 'No',

'paste.title' => 'Title',
'paste.untitled' => 'Untitled',
'paste.title.placeholder' => 'Title (optional)',
'paste.content' => 'Content',
'paste.content.placeholder' => 'Paste your text here...',
'paste.expiration' => 'Paste expiration',
'paste.privacy' => 'Privacy',
'paste.option.enable.syntax' => 'Enable syntax highlighting',
'paste.submit.tooltip' => 'Registered users have access to other privacy tools',
'paste.submit' => 'Submit',


'paste.option.expiration.never' => 'Never',
'paste.option.expiration.burn_after_reading' => 'Burn after reading',
'paste.option.expiration.10min' => '10 minutes',
'paste.option.expiration.1h' => '1 hour',
'paste.option.expiration.1d' => '1 day',
'paste.option.expiration.1w' => '1 week',
'paste.option.expiration.1m' => '1 month',
'paste.option.expiration.3m' => '3 months',

'paste.option.privacy.link' => 'Unlisted, access with link',
'paste.option.privacy.internal' => 'Internal, authenticated users with link',
'paste.option.privacy.password' => 'Password-protected',
'paste.option.privacy.private' => 'Private (only me)',

/* Dashboard */
'paste.views' => 'Views',
'paste.creation' => 'Creation',
'paste.confirm.delete.title' => 'Delete "<i>{{ :pastename }}</i>"?',
'paste.confirm.delete' => 'Are you sure? You <strong>cannot</strong> undo this',
'paste.option.expired' => 'Expired',

/* View paste */
'paste.msg.expired.viewable' => 'This paste has expired, however since you wrote it you may view it whenever you want.',
'paste.msg.burnafter.viewable' => 'This paste is in burn after reading. From now, it could be viewed only one time.',
'paste.msg.burnafter.last.view' => '<strong>Be careful!</strong> This paste is in burn after reading mode and you won\'t be able to see it again',
'paste.syntax-highlighted' => 'Syntax-highlighted',
'paste.plain-text' => 'Plain-text',
'paste.raw' => 'Raw paste',
'paste.edit' => 'Edit paste',
'paste.view_count' => 'Times viewed',
'paste.views' => '{1} :count view|[2,*] :count views',
'paste.username' => 'Username',
'password.title' => 'Password',
'paste.notfound' => 'Content may be not found or expired, or access may be denied. Please <a href="/users/dashboard">log-in here</a>',
'button.goto.home' => 'Return to home page',
'button.goto.auth' => 'If you\'re confident in your link, click here to authenticate!',

/* Password prompt page */
'page.title.password.prompt' => 'Password prompt',
'password.field.placeholder' => 'Enter paste pasword',
'password.submit' => 'Submit',

/* Edit paste page */
'page.title.edit' => 'Edit :pastename',

/* Validation messages */
'validation.error.password' => 'Please enter a password please',
'validation.error.notempty' => 'Your paste cannot be empty.',
'validation.error.maxlength' => 'Title must not exceed 70 characters.',
'validation.error.expiration.required' => 'Paste expiration is required.',

];
81 changes: 81 additions & 0 deletions resources/lang/fr/edpaste.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

return [

'page.title.dashboard' => 'Tableau de bord',
'page.title.home' => 'Accueil',
'page.title.notfound' => 'Non trouvé',
'page.title.account' => 'Mon compte',
'page.title.login' => 'Authenfitication',
'page.title.register' => 'Enregistrement',

'menu.home' => 'Accueil',
'menu.dashboard' => 'Tableau de bord',
'menu.logout' => 'Déconnexion',
'button.yes' => 'Oui',
'button.no' => 'Non',

'paste.title' => 'Titre',
'paste.untitled' => 'Sans titre',
'paste.title.placeholder' => 'Nom du post-it (facultatif)',
'paste.content' => 'Contenu',
'paste.content.placeholder' => 'Collez votre texte ici...',
'paste.expiration' => 'Expiration du post-it',
'paste.privacy' => 'Type d\'accès',
'paste.option.enable.syntax' => 'Activer le surlignage syntaxique',
'paste.submit.tooltip' => 'Plus d\'options de visibilité sont disponibles pour les utilisateurs authentifés',
'paste.submit' => 'Soumettre',


'paste.option.expiration.never' => 'Jamais',
'paste.option.expiration.burn_after_reading' => 'S\'autodétruit après lecture',
'paste.option.expiration.10min' => '10 minutes',
'paste.option.expiration.1h' => '1 heure',
'paste.option.expiration.1d' => '1 jour',
'paste.option.expiration.1w' => '1 semaine',
'paste.option.expiration.1m' => '1 mois',
'paste.option.expiration.3m' => '3 mois',

'paste.option.privacy.link' => 'Non listé, accès public avec un lien',
'paste.option.privacy.internal' => 'Interne, accès pour les utilisateurs authentifiés avec un lien',
'paste.option.privacy.password' => 'Public, protégé par un mot de passe',
'paste.option.privacy.private' => 'Privé, pour vous seulement',

/* Dashboard */
'paste.views' => 'Vues',
'paste.creation' => 'Création',
'paste.confirm.delete.title' => 'Supprimer "<i>:pastename</i>" ?',
'paste.confirm.delete' => 'Êtes vous sûr ? Il est <strong>impossible</strong> de revenir en arrière !',
'paste.option.expired' => 'Expiré',

/* View paste */
'paste.msg.expired.viewable' => 'Ce post-it a expiré, mais vous pouvez toujours le consulter en tant que rédacteur·trice.',
'paste.msg.burnafter.viewable' => 'Ce post-it s\'autodétruira après lecture. À partir de maintenant, il ne peut être visionné qu\'une seule fois.',
'paste.msg.burnafter.last.view' => '<strong>Attention !</strong> Ce post-it va s\'autodétruire après lecture et vous ne pourrez plus le voir.',
'paste.syntax-highlighted' => 'Surlignage syntaxique',
'paste.plain-text' => 'Texte brut',
'paste.raw' => 'Afficher',
'paste.edit' => 'Modifier le post-it',
'paste.view_count' => 'Nombre de vues',
'paste.views' => '{1} :count vue|[2,*] :count vues',
'paste.username' => 'Auteur',
'password.title' => 'Mot de passe',
'paste.notfound' => 'Page non trouvée - Le post-it n\'existe pas, a expiré, ou nécessite une authentification.',
'button.goto.home' => 'Retourner à la page d\'accueil',
'button.goto.auth' => 'Vous êtes sûr·e de votre lien ? Cliquez ici pour vous authentifier !',

/* Password prompt page */
'page.title.password.prompt' => 'Demande de mot de passe',
'password.field.placeholder' => 'Entrez le mot de passe',
'password.submit' => 'Soumettre',

/* Edit paste page */
'page.title.edit' => 'Edition :pastename',

/* Validation messages */
'validation.error.password' => 'Veuillez saisir un mot de passe',
'validation.error.notempty' => 'Votre post-it ne peut être vide.',
'validation.error.maxlength' => 'Le titre ne doit pas excéder 70 caractères',
'validation.error.expiration.required' => 'L\'expiration du post-it est obligatoire',

];
6 changes: 4 additions & 2 deletions resources/views/auth/login.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
@extends('default')

@section('pagetitle') Login - EdPaste @endsection
@section('pagetitle') {{ __('edpaste.page.title.login') }} - {{ config('app.name', 'EdPaste') }} @endsection

@section('navbar')
<li class="nav-item"><a href="/" class="nav-link">Home</a></li>
<li class="nav-item"><a href="/" class="nav-link">{{ __('edpaste.menu.home') }}</a></li>
{{--
<li class="nav-item active"><a href="#" class="nav-link">Login</a></li>
<li class="nav-item"><a href="/register" class="nav-link">Register</a></li>
--}}
@endsection

@section('content')
18 changes: 5 additions & 13 deletions resources/views/auth/register.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
@extends('default')

@section('pagetitle') Register - EdPaste @endsection
@section('pagetitle') {{ __('edpaste.page.title.register') }} - {{ config('app.name', 'EdPaste') }} @endsection

@section('navbar')
<li class="nav-item"><a href="/" class="nav-link">Home</a></li>
<li class="nav-item"><a href="/" class="nav-link">{{ __('edpaste.menu.home') }}</a></li>
{{--
<li class="nav-item"><a href="/login" class="nav-link">Login</a></li>
<li class="nav-item active"><a href="#" class="nav-link">Register</a></li>
--}}
@endsection

@section('content')
@@ -71,16 +73,6 @@
@endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4 @if ($errors->has('g-recaptcha-response')) has-error @endif">
{!! app('captcha')->display(); !!}
@if ($errors->has('g-recaptcha-response'))
<span class="help-block">
<strong>Captcha required</strong>
</span>
@endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
@@ -90,4 +82,4 @@
</div>
</form>
</div>
@endsection
@endsection
16 changes: 8 additions & 8 deletions resources/views/default.blade.php
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
<nav class="navbar navbar-fixed-top navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/">EdPaste</a>
<a class="navbar-brand" href="/">{{ config('app.name', 'EdPaste') }}</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
@@ -46,13 +46,13 @@

<body>
@yield('content')
<footer>
<div class="container">
<div class="row">
<h5 class="text-center"><small><i>Made by Pierre T. - <a href="https://github.com/Edraens" target="_blank">Edraens</a>, 2016, adapté par Easter-Eggs et DSI EHESS</i></small></h5>
</div>
</div>
</footer>
</body>
<footer>
<div class="container">
<div class="row">
<h5 class="text-center"><small><i>Made by Pierre T. - <a href="https://github.com/Edraens" target="_blank">Edraens</a>, 2016</i></small></h5>
</div>
</div><br />
</footer>

</html>
28 changes: 17 additions & 11 deletions resources/views/errors/404.blade.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
@extends('default')

@section('pagetitle') Not found - EdPaste @endsection
@section('pagetitle') {{ __('edpaste.page.title.notfound') }} - {{ config('app.name', 'EdPaste') }} @endsection

@section('navbar')

@endsection

@section('content')
<div class="container">
<div class="text-center">
<div class="jumbotron">
<h1><i>Page not found</i></h1>
<p class="lead hidden-xs">Content may be not found or expired, or access may be denied</p>
<hr class="m-y-2">
<p class="lead">
<a class="btn btn-danger btn-lg" href="/" role="button">Return to homepage</a>
</p>
</div>
</div>
<div class="text-center">
<div class="jumbotron">
<h1><i>Page not found</i></h1>
<p class="lead hidden-xs">{{ __('edpaste.paste.notfound') }}</p>
<hr class="m-y-2">
@if (cas()->isAuthenticated())
<p class="lead">
<a class="btn btn-danger btn-lg" href="/" role="button">{{ __('edpaste.button.goto.home') }}</a>
</p>
@else
<p class="lead">
<a id="authlink" class="btn btn-danger btn-lg" href="/retryAfterAuth" role="button">{{ __('edpaste.button.goto.auth') }}</a>
</p>
@endif
</div>
</div>
</div>
@endsection
5 changes: 3 additions & 2 deletions resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@
<ul class="nav navbar-nav">
&nbsp;
</ul>

{{--
<!-- Right Side Of Navbar -->
<ul class="nav navbar-nav navbar-right">
<!-- Authentication Links -->
@@ -55,7 +55,7 @@
@else
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
{{ Auth::user()->name }} <span class="caret"></span>
{{ User::getCurrentUser()->name }} <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
@@ -74,6 +74,7 @@
</li>
@endif
</ul>
--}}
</div>
</div>
</nav>
28 changes: 15 additions & 13 deletions resources/views/paste/account.blade.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
@extends('default')

@section('pagetitle') My Account - EdPaste @endsection
@section('pagetitle') {{ __('edpaste.page.title.account') }} - {{ config('app.name', 'EdPaste') }} @endsection

@section('navbar')
<li class="nav-item"><a href="/" class="nav-link">Home</a></li>
@if (Auth::check())
<li class="nav-item"><a href="/users/dashboard" class="nav-link">Dashboard</a></li>
<li class="nav-item"><a href="/" class="nav-link">{{ __('edpaste.menu.home') }}</a></li>
{{--
@if (cas()->isAuthenticated())
<li class="nav-item"><a href="/users/dashboard" class="nav-link">{{ __('edpaste.menu.dashboard') }}</a></li>
<li class="nav-item active"><a href="/users/account" class="nav-link">My Account</a></li>
<li class="nav-item"><a href="/logout" class="nav-link">Logout <i>({{ Auth::user()->name }})</i></a></li>
<li class="nav-item"><a href="/logout" class="nav-link">Logout <i>({{ User::getCurrentUser()->name }})</i></a></li>
@else
<li class="nav-item"><a href="/login" class="nav-link">Login</a></li>
<li class="nav-item"><a href="/register" class="nav-link">Register</a></li>
@endif
--}}
@endsection

@section('content')<div class="container">
@@ -43,24 +45,24 @@
<input id="email" type="text" class="form-control" name="email" maxlength="50" value="{{ $user->email }}" >
</div>
</div>
<div class="form-group{{ $errors->has('currentpassword') ? ' has-error' : '' }}">
<label for="currentpassword" class="col-md-4 control-label">Current password</label>
<div class="col-md-3">
<input id="currentpassword" type="password" class="form-control" name="currentpassword" maxlength="100" placeholder="Leave blank if password unchanged" >
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">New password</label>
<div class="col-md-3">
<input id="password" type="password" class="form-control" name="password" maxlength="100" placeholder="Leave blank if password unchanged" >
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="passwordconfirm" class="col-md-4 control-label">Confirmation</label>
<label for="passwordconfirm" class="col-md-4 control-label">Confirm password</label>
<div class="col-md-3">
<input id="passwordconfirm" type="password" class="form-control" name="passwordconfirm" maxlength="100" placeholder="Leave blank if password unchanged" >
</div>
</div>
<div class="form-group{{ $errors->has('currentpassword') ? ' has-error' : '' }}">
<label for="currentpassword" class="col-md-4 control-label">Current password</label>
<div class="col-md-3">
<input id="currentpassword" type="password" class="form-control" name="currentpassword" maxlength="100" placeholder="Leave blank if password unchanged" >
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
@@ -70,4 +72,4 @@
</div>
</form>
</div>
@endsection
@endsection
80 changes: 43 additions & 37 deletions resources/views/paste/dashboard.blade.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
@extends('default')

@section('pagetitle') Dashboard - EdPaste @endsection
@section('pagetitle') {{ __('edpaste.page.title.dashboard') }} - {{ config('app.name', 'EdPaste') }} @endsection

@section('navbar')
<li class="nav-item"><a href="/" class="nav-link">Home</a></li>
@if (Auth::check())
<li class="nav-item active"><a href="/users/dashboard" class="nav-link">Dashboard</a></li>
<li class="nav-item"><a href="/" class="nav-link">{{ __('edpaste.menu.home') }}</a></li>
@if (cas()->isAuthenticated())
<li class="nav-item active"><a href="/users/dashboard" class="nav-link">{{ __('edpaste.menu.dashboard') }}</a></li>
{{--
<li class="nav-item"><a href="/users/account" class="nav-link">My Account</a></li>
<li class="nav-item"><a href="/logout" class="nav-link">Logout <i>({{ Auth::user()->name }})</i></a></li>
--}}
<li class="nav-item"><a href="/logout" class="nav-link">{{ __('edpaste.menu.logout') }} <i>({{ cas()->getCurrentUser() }})</i></a></li>
@else
{{--
<li class="nav-item"><a href="/login" class="nav-link">Login</a></li>
<li class="nav-item"><a href="/register" class="nav-link">Register</a></li>
--}}
@endif
@endsection

@@ -25,41 +29,41 @@
@section('content')
<div class="container">
<div class="row">
<h2 class="text-center display-4">Dashboard</h2>
<h2 class="text-center display-4">{{ __('edpaste.page.title.dashboard') }}</h2>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Title</th>
<th class="hidden-xs">Content</th>
<th>{{ __('edpaste.paste.title') }}</th>
<th class="hidden-xs">{{ __('edpaste.paste.content') }}</th>
<th class="hidden-xs"></th>
<th class="hidden-xs"></th>
<th class="hidden-xs">Views</th>
<th>Creation</th>
<th>{{ __('edpaste.paste.view_count') }}</th>
<th>{{ __('edpaste.paste.creation') }}</th>
<th></th>
</tr>
</thead>
</tbody>
@foreach ($userPastes as $userPaste)
<tr>
<td><a href="/{{ $userPaste->link }}">@if (strlen($userPaste->title) <= 20) {{ $userPaste->title}} @else {{ mb_substr($userPaste->title,0,20,'UTF-8') }}... @endif</a></td>
<td class="hidden-xs"><i>@if (!$userPaste->noSyntax) <i class="fa fa-file-code-o"></i> &nbsp; @endif @if (strlen($userPaste->content) < 90) {{ $userPaste->content}} @else {{ mb_substr($userPaste->content,0,90,'UTF-8') }}... @endif</i></td>
{{-- Bloc d'infos --}}
<td class="hidden-xs">
@if ($userPaste->privacy == "link") <i class="fa fa-globe fa-lg" data-toggle="tooltip" data-placement="bottom" title="Public"></i>
@elseif ($userPaste->privacy == "password") <i class="fa fa-key fa-lg" data-toggle="tooltip" data-placement="bottom" title="Password-protected"></i>
@elseif ($userPaste->privacy == "private") <i class="fa fa-user-secret fa-lg" data-toggle="tooltip" data-placement="bottom" title="Private"></i> @endif
</td>
<td class="hidden-xs">
@if ($userPaste->expiration == "0") <i class="fa fa-calendar-check-o fa-lg" data-toggle="tooltip" data-placement="bottom" title="Never expires"></i>
@elseif ($userPaste->burnAfter == "1") <i class="fa fa-exclamation-circle fa-lg" data-toggle="tooltip" data-placement="bottom" title="Burn after reading"></i>
@elseif (time() > strtotime($userPaste->expiration)) <i class="fa fa-calendar-times-o fa-lg" data-toggle="tooltip" data-placement="bottom" title="Expired"></i>
@else <i class="fa fa-hourglass fa-lg" data-toggle="tooltip" data-placement="bottom" title="Expiration set"></i>@endif
</td>
<td> {{ $userPaste->views }}</td>
{{-- Là on repasse à la date --}}
<td>{{ $userPaste->created_at->format('M jS, Y') }}</td>
<td>
<button class="btn btn-danger btn-sm pull-right" type="button" data-toggle="modal" data-target="#delete{{ $loop->iteration }}" aria-expanded="false" aria-controls="collapseExample{{ $loop->iteration }}"><i class="fa fa-trash-o"></i></button></td>
<tbody>
@foreach ($userPastes as $userPaste)
<tr>
<td><a href="/{{ $userPaste->link }}">@if (strlen($userPaste->title) <= 20) {{ $userPaste->title}} @else {{ mb_substr($userPaste->title,0,20,'UTF-8') }}... @endif</a></td>
<td class="hidden-xs"><i>@if ($userPaste->syntaxHl) <i class="fa fa-file-code-o"></i> &nbsp; @endif @if (strlen($userPaste->content) < 90) {{ $userPaste->content}} @else {{ mb_substr($userPaste->content,0,90,'UTF-8') }}... @endif</i></td>
{{-- Bloc d'infos --}}
<td class="hidden-xs">
@if ($userPaste->privacy == "link") <i class="fa fa-globe fa-lg" data-toggle="tooltip" data-placement="bottom" title="{{ __('edpaste.paste.option.privacy.link') }}"></i>
@elseif ($userPaste->privacy == "internal") <i class="fa fa-users fa-lg" data-toggle="tooltip" data-placement="bottom" title="{{ __('edpaste.paste.option.privacy.internal') }}"></i>
@elseif ($userPaste->privacy == "password") <i class="fa fa-key fa-lg" data-toggle="tooltip" data-placement="bottom" title="{{ __('edpaste.paste.option.privacy.password') }}"></i>
@elseif ($userPaste->privacy == "private") <i class="fa fa-user-secret fa-lg" data-toggle="tooltip" data-placement="bottom" title="{{ __('edpaste.paste.option.privacy.private') }}"></i> @endif
</td>
<td class="hidden-xs">
@if ($userPaste->expiration == "0") <i class="fa fa-calendar-check-o fa-lg" data-toggle="tooltip" data-placement="bottom" title="{{ __('edpaste.paste.option.expiration.never') }}"></i>
@elseif ($userPaste->burnAfter == "1") <i class="fa fa-exclamation-circle fa-lg" data-toggle="tooltip" data-placement="bottom" title="{{ __('edpaste.paste.option.expiration.burn_after_reading') }}"></i>
@elseif (time() > strtotime($userPaste->expiration)) <i class="fa fa-calendar-times-o fa-lg" data-toggle="tooltip" data-placement="bottom" title="{{ __('edpaste.paste.option.expired') }}"></i>
@else <i class="fa fa-hourglass fa-lg" data-toggle="tooltip" data-placement="bottom" title="Expiration set"></i>@endif
</td>
<td class="pull-right"> {{ $userPaste->views }}</td>
{{-- Là on repasse à la date --}}
<td>{{ $userPaste->created_at->format('Y-m-d') }}</td>
<td><button class="btn btn-danger btn-sm pull-right" type="button" data-toggle="modal" data-target="#delete{{ $loop->iteration }}" aria-expanded="false" aria-controls="collapseExample{{ $loop->iteration }}"><i class="fa fa-trash-o"></i></button></td>
</tr>
<div class="modal fade" id="delete{{ $loop->iteration }}" tabindex="-1" role="dialog" aria-labelledby="preview" aria-hidden="true">
<div class="modal-dialog" role="document">
@@ -68,17 +72,19 @@
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="preview" style="word-wrap: break-word;">Delete "<i>{{ $userPaste->title }}</i>" ?</h4>
<h4 class="modal-title" id="preview" style="word-wrap: break-word;">@lang('edpaste.paste.confirm.delete.title', ['pastename' => $userPaste->title])</h4>
</div>
<div class="modal-body">Are you sure ? You <b>cannot</b> undo this !</div>
<div class="modal-body">@lang('edpaste.paste.confirm.delete')</div>
<div class="modal-footer">
<a class="btn btn-danger btn-sm" href="/users/delete/{{ $userPaste->link }}" role="button">Yes</a>
<button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">No</button>
<a class="btn btn-danger btn-sm" href="/users/delete/{{ $userPaste->link }}" role="button">{{ __('edpaste.button.yes') }}</a>
<button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">{{ __('edpaste.button.no') }}</button>
</div>
</div>
</div>
</div>
@endforeach
</tbody>
</table>

</div>
</div>
@endsection
131 changes: 131 additions & 0 deletions resources/views/paste/edit.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
@extends('default')

@section('pagetitle') {{ __('edpaste.page.title.edit', ['pastename' => $title]) }} - {{ config('app.name', 'EdPaste') }} @endsection

@section('navbar')
<li class="nav-item"><a href="/" class="nav-link">{{ __('edpaste.menu.home') }}</a></li>
@if (cas()->isAuthenticated())
<li class="nav-item"><a href="/users/dashboard" class="nav-link">{{ __('edpaste.menu.dashboard') }}</a></li>
<li class="nav-item"><a href=" /logout" class="nav-link">{{ __('edpaste.menu.logout') }} <i>({{ cas()->getCurrentUser() }})</i></a></li>
@endif
{{--
@if (cas()->isAuthenticated())
<li class="nav-item"><a href="/users/account" class="nav-link">My Account</a></li>
<li class="nav-item"><a href=" /logout" class="nav-link">Logout <i>({{ User::getCurrentUser()->name }})</i></a></li>
@else
<li class="nav-item"><a href="/login" class="nav-link">Login</a></li>
<li class="nav-item"><a href="/register" class="nav-link">Register</a></li>
@endif
--}}
@endsection

@section('script')
<script src="../jquery.autogrowtextarea.min.js"></script>
<script>
function checkvalue(value)
{
if(value==="password")
document.getElementById('passwordInput').style.display='block';
else
document.getElementById('passwordInput').style.display='none';
}
</script>
@endsection

@section('content')
<div class="container">
<form action="/edit/{{ $link }}" method="post" accept-charset="utf-8">
{{ csrf_field() }}
{{-- Ca c'est pour éviter que les navigateurs préremplissent les champs --}}
<input style="display:none" type="text" name="fakeusernameremembered"/>
<input style="display:none" type="password" name="fakepasswordremembered"/>

<div class="row">
<div class="form-group col-xs-12 @if ($errors->has('pasteTitle')) has-error @endif">
<label for="pasteTitle">{{ __('edpaste.paste.title') }}</label>
<input type="text" class="form-control" name="pasteTitle" id="pasteTitle" placeholder="{{ __('edpaste.paste.title.placeholder') }}" maxlength="70" value="{{ old('pasteTitle') ? old('pasteTitle') : $title }}">
@if ($errors->has('pasteTitle'))
<span class="help-block">
<strong>{{ $errors->first('pasteTitle') }}</strong>
</span>
@endif
</div>
</div>
<div class="row">
<div class="form-group col-xs-12 @if ($errors->has('pasteContent')) has-error @endif">
<label for="pasteContent">{{ __('edpaste.paste.content') }}</label>
<script type="text/javascript">
$(document).ready(function(){
$("#pasteContent").autoGrow();
});
</script>
<textarea class="form-control input-sm" name="pasteContent" id="pasteContent" rows="15" placeholder="{{ __('edpaste.paste.content.placeholder') }}" style="font-family: monospace;">{{ old('pasteContent') ? old('pasteContent') : $content }}</textarea>
@if ($errors->has('pasteContent'))
<span class="help-block">
<strong>{{ $errors->first('pasteContent') }}</strong>
</span>
@endif
</div>
</div>
<div class="row">
<div class="form-group col-sm-3 @if ($errors->has('expire')) has-error @endif">
<label for="expire">{{ __('edpaste.paste.expiration') }}</label>
<select class="form-control" name="expire" id="expire">
<option disabled selected></option>
<option value="never" selected="selected">{{ __('edpaste.paste.option.expiration.never') }}</option>
<option value="burn">{{ __('edpaste.paste.option.expiration.burn_after_reading') }}</option>
<option value="10m">{{ __('edpaste.paste.option.expiration.10min') }}</option>
<option value="1h">{{ __('edpaste.paste.option.expiration.1h') }}</option>
<option value="1d">{{ __('edpaste.paste.option.expiration.1d') }}</option>
<option value="1w">{{ __('edpaste.paste.option.expiration.1w') }}</option>
<option value="1m">{{ __('edpaste.paste.option.expiration.1m') }}</option>
<option value="3m">{{ __('edpaste.paste.option.expiration.3m') }}</option>
</select>
@if ($errors->has('expire'))
<span class="help-block">
<strong>{{ $errors->first('expire') }}</strong>
</span>
@endif
</div>
<div class="form-group col-sm-3 @if ($errors->has('pastePassword')) has-error @endif">
<label for="privacy">{{ __('edpaste.paste.privacy') }}</label>
<select class="form-control" name="privacy" id="privacy" onchange='checkvalue(this.value)'>
<option value="link">{{ __('edpaste.paste.option.privacy.link') }}</option>
<option value="internal">{{ __('edpaste.paste.option.privacy.internal') }}</option>
<option value="password" @if ($errors->has('pastePassword')) selected="selected" @endif>{{ __('edpaste.paste.option.privacy.password') }}</option>
@if (cas()->isAuthenticated())
<option value="private">{{ __('edpaste.paste.option.privacy.private') }}</option>
@endif
</select>
</div>
{{-- Ce truc n'apparait que si "Password-protected" est séléctionné plus haut --}}
<div class="form-group col-sm-2 @if ($errors->has('pastePassword')) has-error @endif" id="passwordInput" @if (!$errors->has('pastePassword')) style="display:none;" @endif>
<label for="pastePassword">{{ __('edpaste.password.title') }}</label>
<input type="password" class="form-control" name="pastePassword" id="pastePassword" placeholder="{{ __('edpaste.password.field.placeholder') }}" maxlength="40">
@if ($errors->has('pastePassword'))
<span class="help-block">
<strong>{{ $errors->first('pastePassword') }}</strong>
</span>
@endif
</div>
</div>
<div class="row">
<div class="form-group text-center">
<script>
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
</script>
{{-- La tooltip n'apparaît que pour les users non-id et le btn devient danger si y'a des erreurs --}}
<div class="checkbox">
<label><input type="checkbox" name="syntaxHl" @if ($syntaxHl) checked @endif>{{ __('edpaste.paste.option.enable.syntax') }}</label>
</div>
<button type="submit" id="submit" class="btn @if (count($errors) > 0) btn-danger @else btn-outline-success @endif btn-lg" @if (!cas()->isAuthenticated()) data-toggle="tooltip" data-placement="top" title="Registered users have access to other privacy tools" @endif>{{ __('edpaste.paste.submit') }}</button>
</div>
</div>

</div>
</div>
</form>
</div>
@endsection
67 changes: 29 additions & 38 deletions resources/views/paste/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
@extends('default')

@section('pagetitle') Home - EdPaste @endsection
@section('pagetitle') {{ __('edpaste.page.title.home') }} - {{ config('app.name', 'EdPaste') }} @endsection

@section('navbar')
<li class="nav-item active"><a href="#" class="nav-link">Home</a></li>
@if (Auth::check())
<li class="nav-item"><a href="/users/dashboard" class="nav-link">Dashboard</a></li>
<li class="nav-item"><a href="/users/account" class="nav-link">My Account</a></li>
<li class="nav-item"><a href=" /logout" class="nav-link">Logout <i>({{ Auth::user()->name }})</i></a></li>
<li class="nav-item active"><a href="#" class="nav-link">{{ __('edpaste.menu.home') }}</a></li>
@if (cas()->isAuthenticated())
<li class="nav-item"><a href="/users/dashboard" class="nav-link">{{ __('edpaste.menu.dashboard') }}</a></li>
{{-- <li class="nav-item"><a href="/users/account" class="nav-link">My Account</a></li> --}}
<li class="nav-item"><a href=" /logout" class="nav-link">{{ __('edpaste.menu.logout') }} <i>({{ cas()->getCurrentUser() }})</i></a></li>
@else
<li class="nav-item"><a href="/login" class="nav-link">Login</a></li>
<li class="nav-item"><a href="/register" class="nav-link">Register</a></li>
@endif
@endsection

@@ -36,8 +35,8 @@ function checkvalue(value)
<input style="display:none" type="password" name="fakepasswordremembered"/>
<div class="row">
<div class="form-group col-xs-12 @if ($errors->has('pasteTitle')) has-error @endif">
<label for="pasteTitle">Title</label>
<input type="text" class="form-control" name="pasteTitle" id="pasteTitle" placeholder="Title (optional)" maxlength="70" value="{{ old('pasteTitle') }}">
<label for="pasteTitle">{{ __('edpaste.paste.title') }}</label>
<input type="text" class="form-control" name="pasteTitle" id="pasteTitle" placeholder="{{ __('edpaste.paste.title.placeholder') }}" maxlength="70" value="{{ old('pasteTitle') }}">
@if ($errors->has('pasteTitle'))
<span class="help-block">
<strong>{{ $errors->first('pasteTitle') }}</strong>
@@ -47,13 +46,13 @@ function checkvalue(value)
</div>
<div class="row">
<div class="form-group col-xs-12 @if ($errors->has('pasteContent')) has-error @endif">
<label for="pasteContent">Content</label>
<label for="pasteContent">{{ __('edpaste.paste.content') }}</label>
<script type="text/javascript">
$(document).ready(function(){
$("#pasteContent").autoGrow();
});
</script>
<textarea class="form-control input-sm" name="pasteContent" id="pasteContent" rows="15" placeholder="Paste your text here...">{{ old('pasteContent') }}</textarea>
<textarea class="form-control input-sm" name="pasteContent" id="pasteContent" rows="15" placeholder="{{ __('edpaste.paste.content.placeholder') }}" style="font-family: monospace;">{{ old('pasteContent') }}</textarea>
@if ($errors->has('pasteContent'))
<span class="help-block">
<strong>{{ $errors->first('pasteContent') }}</strong>
@@ -63,47 +62,39 @@ function checkvalue(value)
</div>
<div class="row">
<div class="form-group col-sm-3">
<label for="expire">Paste expiration</label>
<label for="expire">{{ __('edpaste.paste.expiration') }}</label>
<select class="form-control" name="expire" id="expire">
<option value="never" selected="selected">Never</option>
<option value="burn">Burn after reading</option>
<option value="10m">10 minutes</option>
<option value="1h">1 hour</option>
<option value="1d">1 day</option>
<option value="1w">1 week</option>
<option value="never" selected="selected">{{ __('edpaste.paste.option.expiration.never') }}</option>
<option value="burn">{{ __('edpaste.paste.option.expiration.burn_after_reading') }}</option>
<option value="10m">{{ __('edpaste.paste.option.expiration.10min') }}</option>
<option value="1h">{{ __('edpaste.paste.option.expiration.1h') }}</option>
<option value="1d">{{ __('edpaste.paste.option.expiration.1d') }}</option>
<option value="1w">{{ __('edpaste.paste.option.expiration.1w') }}</option>
<option value="1m">{{ __('edpaste.paste.option.expiration.1m') }}</option>
<option value="3m">{{ __('edpaste.paste.option.expiration.3m') }}</option>
</select>
</div>
<div class="form-group col-sm-3 @if ($errors->has('pastePassword')) has-error @endif">
<label for="privacy">Privacy</label>
<label for="privacy">{{ __('edpaste.paste.privacy') }}</label>
<select class="form-control" name="privacy" id="privacy" onchange='checkvalue(this.value)'>
<option value="link">Unlisted, access with link</option>
<option value="password" @if ($errors->has('pastePassword')) selected="selected" @endif>Password-protected</option>
@if (Auth::check())
<option value="private">Private, only me</option>
<option value="link">{{ __('edpaste.paste.option.privacy.link') }}</option>
<option value="internal">{{ __('edpaste.paste.option.privacy.internal') }}</option>
<option value="password" @if ($errors->has('pastePassword')) selected="selected" @endif>{{ __('edpaste.paste.option.privacy.password') }}</option>
@if (cas()->isAuthenticated())
<option value="private">{{ __('edpaste.paste.option.privacy.private') }}</option>
@endif
</select>
</div>
{{-- Ce truc n'apparait que si "Password-protected" est séléctionné plus haut --}}
<div class="form-group col-sm-2 @if ($errors->has('pastePassword')) has-error @endif" id="passwordInput" @if (!$errors->has('pastePassword')) style="display:none;" @endif>
<label for="pastePassword">Password</label>
<input type="password" class="form-control" name="pastePassword" id="pastePassword" placeholder="Enter a password..." maxlength="40">
<label for="pastePassword">{{ __('edpaste.password.title') }}</label>
<input type="password" class="form-control" name="pastePassword" id="pastePassword" placeholder="{{ __('edpaste.password.field.placeholder') }}" maxlength="40">
@if ($errors->has('pastePassword'))
<span class="help-block">
<strong>{{ $errors->first('pastePassword') }}</strong>
</span>
@endif
</div>
{{-- Le captcha n'aparaît que pour les users non-id --}}
@if (!Auth::check())
<div class="form-group col-sm-3 @if ($errors->has('g-recaptcha-response')) has-error @endif">
{!! app('captcha')->display(); !!}
@if ($errors->has('g-recaptcha-response'))
<span class="help-block">
<strong>{{ $errors->first('g-recaptcha-response') }}</strong>
</span>
@endif
</div>
@endif
</div>
<div class="row">
<div class="form-group text-center">
@@ -114,9 +105,9 @@ function checkvalue(value)
</script>
{{-- La tooltip n'apparaît que pour les users non-id et le btn devient danger si y'a des erreurs --}}
<div class="checkbox">
<label><input type="checkbox" name="noSyntax">Disable syntax highlighting</label>
<label><input type="checkbox" name="syntaxHl">{{ __('edpaste.paste.option.enable.syntax') }}</label>
</div>
<button type="submit" id="submit" class="btn @if (count($errors) > 0) btn-danger @else btn-outline-success @endif btn-lg" @if (!Auth::check()) data-toggle="tooltip" data-placement="top" title="Registered users have access to other privacy tools and can bypass captchas" @endif>Submit</button>
<button type="submit" id="submit" class="btn @if (count($errors) > 0) btn-danger @else btn-outline-success @endif btn-lg" @if (!cas()->isAuthenticated()) data-toggle="tooltip" data-placement="top" title="{{ __('edpaste.paste.submit.tooltip') }}" @endif>{{ __('edpaste.paste.submit') }}</button>
</div>
</div>

16 changes: 9 additions & 7 deletions resources/views/paste/password.blade.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
@extends('default')

@section('pagetitle') Password prompt - EdPaste @endsection
@section('pagetitle') {{ __('edpaste.page.title.password.prompt') }} - {{ config('app.name', 'EdPaste') }} @endsection

@section('navbar')
<li class="nav-item"><a href="/" class="nav-link">Home</a></li>
@if (Auth::check())
<li class="nav-item"><a href="/users/dashboard" class="nav-link">Dashboard</a></li>
<li class="nav-item"><a href="/" class="nav-link">{{ __('edpaste.menu.home') }}</a></li>
{{--
@if (cas()->isAuthenticated())
<li class="nav-item"><a href="/users/dashboard" class="nav-link">{{ __('edpaste.menu.dashboard') }}</a></li>
<li class="nav-item"><a href="/users/account" class="nav-link">My Account</a></li>
<li class="nav-item"><a href=" /logout" class="nav-link">Logout <i>({{ Auth::user()->name }})</i></a></li>
<li class="nav-item"><a href=" /logout" class="nav-link">Logout <i>({{ User::getCurrentUser()->name }})</i></a></li>
@else
<li class="nav-item"><a href="/login" class="nav-link">Login</a></li>
<li class="nav-item"><a href="/register" class="nav-link">Register</a></li>
@endif
--}}
@endsection

@section('content')
@@ -25,8 +27,8 @@
<input style="display:none" type="password" name="fakepasswordremembered"/>

<div class="form-group @if (isset($wrongPassword)) has-error @endif" id="passwordInput">
<input type="password" class="form-control" name="pastePassword" id="pastePassword" placeholder="Enter paste password" maxlength="40" autofocus="true">
<button type="submit" id="submit" class="btn @if (isset($wrongPassword)) btn-danger @else btn-outline-success @endif">Submit</button>
<input type="password" class="form-control" name="pastePassword" id="pastePassword" placeholder="{{ __('edpaste.password.field.placeholder') }}" maxlength="40" autofocus="true">
<button type="submit" id="submit" class="btn @if (isset($wrongPassword)) btn-danger @else btn-outline-success @endif">{{ __('edpaste.password.submit') }}</button>
</div>
</form>
</div>
72 changes: 30 additions & 42 deletions resources/views/paste/view.blade.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@

@extends('default')

@section('pagetitle') {{ $title }} - EdPaste @endsection
@section('pagetitle') {{ $title }} - {{ config('app.name', 'EdPaste') }} @endsection

@section('navbar')
<li class="nav-item"><a href="/" class="nav-link">Home</a></li>
@if (Auth::check())
<li class="nav-item"><a href="/users/dashboard" class="nav-link">Dashboard</a></li>
<li class="nav-item"><a href="/" class="nav-link">{{ __('edpaste.menu.home') }}</a></li>
@if (cas()->isAuthenticated())
<li class="nav-item"><a href="/users/dashboard" class="nav-link">{{ __('edpaste.menu.dashboard') }}</a></li>
{{--
<li class="nav-item"><a href="/users/account" class="nav-link">My Account</a></li>
<li class="nav-item"><a href=" /logout" class="nav-link">Logout <i>({{ Auth::user()->name }})</i></a></li>
--}}
<li class="nav-item"><a href=" /logout" class="nav-link">{{ __('edpaste.menu.logout') }} <i>({{ cas()->getCurrentUser() }})</i></a></li>
@else
{{--
<li class="nav-item"><a href="/login" class="nav-link">Login</a></li>
<li class="nav-item"><a href="/register" class="nav-link">Register</a></li>
--}}
@endif
@endsection

@section('style')
<link rel="stylesheet" href="/highlight_styles/tomorrow.css">
<style>
@if ($noSyntax == false)
@if ($syntaxHl == true)
pre {
overflow: auto;
word-wrap: normal;
@@ -51,7 +55,7 @@
@endsection

@section('script')
@if ($noSyntax == false)
@if ($syntaxHl == true)
<script src="highlight.pack.js"></script>
<script src="highlightjs-line-numbers.min.js"></script>
<script>
@@ -66,17 +70,17 @@
@if ($expiration == "Expired")
<div class="alert alert-info" role="alert">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<i>This paste has expired, however since you've wrote it you may view it whenever you want.</i>
<i>{{ __('edpaste.paste.msg.expired.viewable') }}</i>
</div>
@elseif ($expiration == "Burn after reading (next time)")
<div class="alert alert-warning" role="alert">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<i>This paste is in burn after reading. From now, it could be viewed only one time.</i>
<i>{{ __('edpaste.paste.msg.burnafter.viewable') }}</i>
</div>
@elseif ($expiration == "Burn after reading")
<div class="alert alert-danger" role="alert">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<i><strong>Be careful!</strong> This paste is in burn after reading mode and you won't be able to see it again.</i>
<i>@lang('edpaste.paste.msg.burnafter.last.view')</i>
</div>
@endif
<div class="row">
@@ -95,12 +99,12 @@
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="preview" style="word-wrap: break-word;">Delete "<i>{{ $title }}</i>" ?</h4>
<h4 class="modal-title" id="preview" style="word-wrap: break-word;">@lang('edpaste.paste.confirm.delete.title', ['pastename' => $title])</h4>
</div>
<div class="modal-body">Are you sure ? You <b>cannot</b> undo this !</div>
<div class="modal-body">@lang('edpaste.paste.confirm.delete')</div>
<div class="modal-footer">
<a class="btn btn-danger btn-sm" href="/users/delete/{{ $link }}" role="button">Yes</a>
<button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">No</button>
<a class="btn btn-danger btn-sm" href="/users/delete/{{ $link }}" role="button">{{ __('edpaste.button.yes') }}</a>
<button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">{{ __('edpaste.button.no') }}</button>
</div>
</div>
</div>
@@ -115,42 +119,26 @@
$('[data-toggle="tooltip"]').tooltip()
})
</script>
<li><i class="fa fa-user" data-toggle="tooltip" data-placement="bottom" title="Username"></i> <i>{{ $username }}</i></li>
<li><i class="fa fa-calendar" data-toggle="tooltip" data-placement="bottom" title="Date of creation"></i> <i data-toggle="tooltip" data-placement="bottom" title="{{ $fulldate }}">{{ $date }}</i></li>
<li><i class="fa fa-eye" data-toggle="tooltip" data-placement="bottom" title="Times viewed"></i> <i>{{ $views }} view(s)</i></li>
<li><i class="fa fa-user" data-toggle="tooltip" data-placement="bottom" title="{{ __('edpaste.paste.username') }}"></i> <i class="username">{{ $username }}</i></li>
<li><i class="fa fa-calendar" data-toggle="tooltip" data-placement="bottom" title="{{ __('edpaste.paste.creation') }}"></i> <i class="date" data-toggle="tooltip" data-placement="bottom" title="{{ $fulldate }}">{{ $date }}</i></li>
<li><i class="fa fa-eye" data-toggle="tooltip" data-placement="bottom" title="{{ __('edpaste.paste.view_count') }}"></i> <i>{{ trans_choice('edpaste.paste.views', $views, ['count' => $views]) }}</i></li>
{{-- Expiration cachée si xs --}}
@if ($expiration == "Never")
<li class="hidden-xs"><i class="fa fa-clock-o" data-toggle="tooltip" data-placement="bottom" title="Expiration"></i> <i>{{ $expiration }}</i></li>
@else
<li><i class="fa fa-clock-o" data-toggle="tooltip" data-placement="bottom" title="Expiration"></i> <i>{{ $expiration }}</i></li>
@endif

<li @if ($expiration == "Never") class="hidden-xs" @endif><i class="fa fa-clock-o" data-toggle="tooltip" data-placement="bottom" title="{{ __('edpaste.paste.expiration') }}"></i> <i>@if ($expiration == "Never") {{ __('edpaste.paste.option.expiration.never') }} @else {{ $expiration }} @endif</i></li>

{{-- Privacy cachée si xs --}}
@if ($privacy == "Public")
<li class="hidden-xs"><i class="fa fa-lock" data-toggle="tooltip" data-placement="bottom" title="Privacy"></i> <i>{{ $privacy }}</i></li>
@else
<li><i class="fa fa-lock" data-toggle="tooltip" data-placement="bottom" title="Privacy"></i> <i>{{ $privacy }}</i></li>
@endif
<li @if ($privacy == "Public") class="hidden-xs" @endif><i class="fa fa-lock" data-toggle="tooltip" data-placement="bottom" title="{{ __('edpaste.paste.privacy') }}"></i> <i>{{ $privacy }}</i></li>
</ul>
</div>
</div>

{{-- N'est formaté que si le SH est activé --}}
<div class="row" @if ($noSyntax == true) style="margin-bottom:20px;" @endif>
<div class="col-sm-12">
<label for="paste"><i>@if ($noSyntax == false) Syntax-highlighted @else Plain-text @endif</i></label>@if ($privacy != "Password-protected") <i class="pull-right"><a href="/{{ $link }}/raw">Raw paste</a> @endif </i>
<pre id="paste"><code>@if ($noSyntax == true)<i>@endif{{ $content }} @if ($noSyntax == true)</i>@endif</code></pre>
</div>
</div>

{{-- N'apparaît que si le SH est activé --}}
@if ($noSyntax == false)
<div class="row" style="margin-bottom:20px;">
<div class="row" @if ($syntaxHl == true) style="margin-bottom:20px;" @endif>
<div class="col-sm-12">
<label for="noFormatPaste"><i>Plain-text</i></label>
<i><textarea class="form-control input-sm" id="noFormatPaste" rows="25" readonly="true">{{ $content }}</textarea></i>
<label for="paste"><i>@if ($syntaxHl == true) {{ __('edpaste.paste.syntax-highlighted') }} @else {{ __('edpaste.paste.plain-text') }} @endif</i></label>
@if ($privacy != "Password-protected") <i class="pull-right"><a href="/raw/{{ $link }}">{{ __('edpaste.paste.raw') }}</a> @endif </i>
@if ($sameUser) <i class="pull-right" style="margin-right: 10px;"><a href="/edit/{{ $link }}">{{ __('edpaste.paste.edit') }}</a> @endif </i>
<pre id="paste"><code class="code">@if ($syntaxHl == false)<i>@endif{{ $content }} @if ($syntaxHl == false)</i>@endif</code></pre>
</div>
</div>
@endif
</div>
@endsection
6 changes: 3 additions & 3 deletions routes/api.php
Original file line number Diff line number Diff line change
@@ -13,6 +13,6 @@
|
*/

Route::get('/user', function (Request $request) {
return $request->user();
})->middleware('auth:api');
//Route::get('/user', function (Request $request) {
// return $request->user();
//})->middleware('auth:api');
10 changes: 6 additions & 4 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -12,16 +12,18 @@
*/

Auth::routes();
// post workaround for logout
Route::get('/logout', 'Auth\LoginController@logout');
Route::get('/logout', 'Auth\LoginController@casLogout');

Route::get('/', 'PasteController@index');
Route::post('/', 'PasteController@submit');
Route::get('/retryAfterAuth', 'PasteController@retryAfterAuth');
Route::get('/{link}', 'PasteController@view')->where('link', '[a-zA-Z0-9]+');
Route::post('/{link}', 'PasteController@view')->where('link', '[a-zA-Z0-9]+');
Route::get('/{link}/raw', 'PasteController@raw')->where('link', '[a-zA-Z0-9]+');
Route::get('/edit/{link}', 'EditPasteController@index')->where('link', '[a-zA-Z0-9]+');
Route::post('/edit/{link}', 'EditPasteController@edit')->where('link', '[a-zA-Z0-9]+');
Route::get('/raw/{link}', 'PasteController@raw')->where('link', '[a-zA-Z0-9]+');
// Route::post('/{link}', 'PasteController@password')->where('link', '[a-zA-Z0-9]+');
Route::get('users/dashboard', 'UserController@dashboard');
Route::get('users/account', 'UserController@account');
Route::get('/users/delete/{link}', 'UserController@delete')->where('link', '[a-zA-Z0-9]+');
Route::post('users/account', 'UserController@editAccount');
Route::post('users/account', 'UserController@editAccount');