<excludeFolder url="file://$MODULE_DIR$/vendor/http-interop/http-factory-guzzle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/itsgoingd/clockwork" />
<excludeFolder url="file://$MODULE_DIR$/vendor/jean85/pretty-package-versions" />
+ <excludeFolder url="file://$MODULE_DIR$/vendor/judev/php-htmltruncator" />
<excludeFolder url="file://$MODULE_DIR$/vendor/justinrainbow/json-schema" />
<excludeFolder url="file://$MODULE_DIR$/vendor/kriswallsmith/buzz" />
<excludeFolder url="file://$MODULE_DIR$/vendor/kub-at/php-simple-html-dom-parser" />
<excludeFolder url="file://$MODULE_DIR$/vendor/mailgun/mailgun-php" />
<excludeFolder url="file://$MODULE_DIR$/vendor/markbaker/complex" />
<excludeFolder url="file://$MODULE_DIR$/vendor/markbaker/matrix" />
+ <excludeFolder url="file://$MODULE_DIR$/vendor/masterminds/html5" />
<excludeFolder url="file://$MODULE_DIR$/vendor/maximebf/debugbar" />
<excludeFolder url="file://$MODULE_DIR$/vendor/moneyphp/money" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nyholm/psr7" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php70" />
<path value="$PROJECT_DIR$/vendor/league/mime-type-detection" />
<path value="$PROJECT_DIR$/vendor/maennchen/zipstream-php" />
+ <path value="$PROJECT_DIR$/vendor/masterminds/html5" />
+ <path value="$PROJECT_DIR$/vendor/judev/php-htmltruncator" />
</include_path>
</component>
<component name="PhpInterpreters">
<interpreters>
<interpreter id="8d15c044-128d-49a1-8834-43ff64d38bcb" name="Ubuntu" home="wsl://DATA" debugger_id="php.debugger.XDebug">
- <remote_data DISTRIBUTION_ID="UBUNTU" INTERPRETER_PATH="/usr/bin/php" HELPERS_PATH="/opt/.phpstorm_helpers" INITIALIZED="false" VALID="true" RUN_AS_ROOT_VIA_SUDO="false" />
+ <remote_data INTERPRETER_PATH="/usr/bin/php" HELPERS_PATH="/opt/.phpstorm_helpers" INITIALIZED="false" VALID="true" RUN_AS_ROOT_VIA_SUDO="false" DISTRIBUTION_ID="UBUNTU" />
</interpreter>
</interpreters>
</component>
--- /dev/null
+<?php
+
+
+namespace App\Models;
+
+use App\User;
+use HtmlTruncator\InvalidHtmlException;
+use HtmlTruncator\Truncator;
+
+/**
+ * Trait HasSubscriberOnlyContent
+ * @package App\Models
+ * @property bool $subscriber_only
+ */
+trait HasSubscriberOnlyContent
+{
+
+ /**
+ * @return string
+ * @throws InvalidHtmlException
+ */
+ public function getTruncatedContent(): string
+ {
+ return Truncator::truncate($this->content, 100);
+ }
+
+ /**
+ * @param User|null $user
+ * @return bool
+ */
+ public function isVisibleByUser(User $user = null)
+ {
+ $user ??= \Auth::user();
+
+ return !$this->subscriber_only ||
+ ($user !== null && $user->hasValidSubscription());
+
+ }
+
+}
use A17\Twill\Models\Behaviors\Sortable;
use A17\Twill\Models\Model;
+/**
+ * Class SocialArticle
+ * @package App\Models
+ * @property string $content
+ * @property string $title
+ * @property string $chapo
+ * @property int $count
+ */
class SocialArticle extends Model
{
- use HasSlug, HasMedias;
+ use HasSlug, HasMedias, HasSubscriberOnlyContent;
protected $fillable = [
'published',
'content',
+ 'chapo',
'title',
+ 'subscriber_only'
];
'title',
];
+ public $casts = [
+ 'subscriber_only' => 'bool'
+ ];
+
/**
* Increments view count
*/
public function hasValidSubscription(): bool
{
- return $this->orgIsSubscribed();
+ return $this->orgIsSubscribed() || $this->subscribed();
}
/**
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"itsgoingd/clockwork": "^4.1",
+ "judev/php-htmltruncator": "^1.2",
"kriswallsmith/buzz": "^1.1",
"kub-at/php-simple-html-dom-parser": "^1.9",
"laravel/cashier": "^11.2",
"league/glide-laravel": "^1.0",
"league/html-to-markdown": "^4.9",
"mailgun/mailgun-php": "^3.0",
+ "masterminds/html5": "^2.7",
"nyholm/psr7": "^1.2",
+ "psq/psq-theme": "*",
"pusher/pusher-php-server": "~4.0",
"sentry/sentry-laravel": "1.7.1",
"spatie/pdf-to-image": "^2.0",
"spatie/pdf-to-text": "^1.3",
- "vaites/php-apache-tika": "^0.9.1",
- "psq/psq-theme": "*"
+ "vaites/php-apache-tika": "^0.9.1"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"@php artisan key:generate --ansi"
]
}
-}
\ No newline at end of file
+}
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "8acd1f5a7163e1ac73fdd7ea056333ab",
+ "content-hash": "247a233609ac91be13638bd635f24b12",
"packages": [
{
"name": "algolia/algoliasearch-client-php",
"version": "6.1.4",
"source": {
"type": "git",
- "url": "https://github.com/caouecs/Laravel-lang.git",
+ "url": "https://github.com/caouecs/lang.git",
"reference": "18a7845e813e737a56a7f164301d5014b536950c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/caouecs/Laravel-lang/zipball/18a7845e813e737a56a7f164301d5014b536950c",
+ "url": "https://api.github.com/repos/caouecs/lang/zipball/18a7845e813e737a56a7f164301d5014b536950c",
"reference": "18a7845e813e737a56a7f164301d5014b536950c",
"shasum": ""
},
"laravel",
"lpm"
],
+ "abandoned": "https://github.com/Laravel-Lang/lang",
"time": "2020-07-13T14:35:32+00:00"
},
{
],
"time": "2020-06-23T06:23:06+00:00"
},
+ {
+ "name": "judev/php-htmltruncator",
+ "version": "1.2.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/judev/php-htmltruncator.git",
+ "reference": "92121c36dc0fc44f3b6932344fae1d7a0abb0b76"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/judev/php-htmltruncator/zipball/92121c36dc0fc44f3b6932344fae1d7a0abb0b76",
+ "reference": "92121c36dc0fc44f3b6932344fae1d7a0abb0b76",
+ "shasum": ""
+ },
+ "require": {
+ "masterminds/html5": "^2.0",
+ "php": ">=5.6.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "4.4.*"
+ },
+ "suggest": {
+ "ext-intl": "*",
+ "ext-mbstring": "*"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "HtmlTruncator": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jude Venn",
+ "homepage": "https://github.com/judev",
+ "role": "Developer"
+ }
+ ],
+ "description": "HTML Truncation library, ported from the html_truncator rubygem",
+ "homepage": "https://github.com/judev/php-htmltruncator",
+ "keywords": [
+ "html",
+ "php"
+ ],
+ "time": "2019-11-19T10:31:52+00:00"
+ },
{
"name": "kriswallsmith/buzz",
"version": "1.1.0",
],
"time": "2020-08-28T19:41:55+00:00"
},
+ {
+ "name": "masterminds/html5",
+ "version": "2.7.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Masterminds/html5-php.git",
+ "reference": "aad73dbfefd71d46072138109ce1288d96c329cc"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/aad73dbfefd71d46072138109ce1288d96c329cc",
+ "reference": "aad73dbfefd71d46072138109ce1288d96c329cc",
+ "shasum": ""
+ },
+ "require": {
+ "ext-ctype": "*",
+ "ext-dom": "*",
+ "ext-libxml": "*",
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.8.35",
+ "sami/sami": "~2.0",
+ "satooshi/php-coveralls": "1.0.*"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.7-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Masterminds\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Matt Butcher",
+ "email": "technosophos@gmail.com"
+ },
+ {
+ "name": "Matt Farina",
+ "email": "matt@mattfarina.com"
+ },
+ {
+ "name": "Asmir Mustafic",
+ "email": "goetas@gmail.com"
+ }
+ ],
+ "description": "An HTML5 parser and serializer.",
+ "homepage": "http://masterminds.github.io/html5-php",
+ "keywords": [
+ "HTML5",
+ "dom",
+ "html",
+ "parser",
+ "querypath",
+ "serializer",
+ "xml"
+ ],
+ "time": "2020-07-05T07:53:37+00:00"
+ },
{
"name": "matthewbdaly/laravel-azure-storage",
"version": "1.3.8",
--- /dev/null
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddChapoColToSocialArticlesTable extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('social_articles', function (Blueprint $table) {
+ $table->text('chapo')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('social_articles', function (Blueprint $table) {
+ $table->dropColumn('chapo');
+ });
+ }
+}
--- /dev/null
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddSubscriberOnlyColToSocialArticlesTable extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('social_articles', function (Blueprint $table) {
+ $table->boolean('subscriber_only')->default(0);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('social_articles', function (Blueprint $table) {
+ $table->dropColumn('subscriber_only');
+ });
+ }
+}
font-size: 17px;
line-height: 1.6;
}
+.ck-content-custom .chapo, .ck-content .chapo, .ck-editor .chapo {
+ text-transform: uppercase;
+ font-size: large;
+}
@font-face {
font-family: "Avenir Next";
editorConfig: {}
};
},
+ computed: {
+ headlines: function headlines() {
+ this.$root.publishState.file.headlines.reduce(function (result, headline) {
+ return "\n <h2>".concat(headline.headline, "</h2>\n <p>").concat(headline.content, "</p>\n\n ");
+ }, "<p>A la une aujourd'hui</p>");
+ }
+ },
watch: {
email: {
deep: true,
line-height: 1.6;
}
+.ck-content-custom .chapo,
+.ck-content .chapo,
+article .chapo,
+.ck-editor .chapo {
+ text-transform: uppercase;
+ font-size: large;
+}
+
/*!
* Bootstrap v4.4.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors
line-height: 1.6;
}
+.ck-content-custom .chapo,
+.ck-content .chapo,
+article .chapo,
+.ck-editor .chapo {
+ text-transform: uppercase;
+ font-size: large;
+}
+
body {
margin-bottom: 4rem;
}
font-size: small;
}
-.chapo {
- font-style: italic;
- font-size: large;
-}
-
.simple-preview .chapo {
font-size: small;
}
margin-bottom: 0;
}
+article .truncated {
+ mask-image: linear-gradient(to bottom, black 75%, transparent 99%);
+ -webkit-mask-image: linear-gradient(to bottom, black 75%, transparent 99%);
+}
+
article h2 {
font-size: 22px;
text-align: center;
editorConfig: {}
};
},
+ computed: {
+ headlines: function headlines() {
+ this.$root.publishState.file.headlines.reduce(function (result, headline) {
+ return "\n <h2>".concat(headline.headline, "</h2>\n <p>").concat(headline.content, "</p>\n\n ");
+ }, "<p>A la une aujourd'hui</p>");
+ }
+ },
watch: {
email: {
deep: true,
publishState: {
file: {
title: "",
- slug: ""
+ slug: "",
+ headlines: []
},
email: {
subject: "",
file: {
title: "",
slug: "",
+ headlines: []
},
email:{
}
}
},
+ computed: {
+ headlines: function() {
+ this.$root.publishState.file.headlines.reduce(function(result, headline) {
+ return `
+ <h2>${headline.headline}</h2>
+ <p>${headline.content}</p>
+
+ `;
+
+ }, "<p>A la une aujourd'hui</p>")
+ }
+
+ },
watch: {
email: {
}
+ .chapo {
+ text-transform: uppercase;
+ font-size: large;
+ }
+
}
}
-.chapo {
- font-style: italic;
- font-size: large;
-}
-
.simple-preview{
.chapo {
font-size: small;
article {
+ .truncated {
+ mask-image: linear-gradient(to bottom, black 75%, transparent 99%);
+ -webkit-mask-image: linear-gradient(to bottom, black 75%, transparent 99%);
+ }
+
@extend .ck-content;
h2 {
font-size: 22px;
font-size: 18px;
color: #074e9c;
text-transform: uppercase;
-
}
}
.error-403 {
@extends('twill::layouts.form')
@section('contentFields')
+ @formField('wysiwyg', [
+ 'name' => 'chapo',
+ 'label' => 'Chapô',
+ ])
+ @formField('radios', [
+ 'name' => 'subscriber_only',
+ 'label' => 'Article réservé aux abonnés',
+ 'default' => false,
+ 'inline' => true,
+ 'options' => [
+ [
+ 'value' => false,
+ 'label' => 'Non'
+ ],
+ [
+ 'value' => true,
+ 'label' => 'Oui'
+ ],
+ ]
+ ])
@formField('ckeditor', [
'name' => 'content',
'label' => 'Article complet',
</div>
<div class="col-sm-8">
<h2>{{$article->title}}</h2>
+ <div class="chapo">{!! $article->chapo !!}</div>
<div class="content ck-content">
- {!! $article->content !!}
+
+ @if($article->isVisibleByUser())
+ {!! $article->content !!}
+ @else
+ <div class="truncated">
+ {!! $article->getTruncatedContent() !!}
+ </div>
+ <div class="alert alert-warning">
+ Cet article est réservé aux abonnés ! Pour y accéder merci de vous connecter, ou
+ <a href="{{route('not-registered')}}" >cliquez ici pour découvrir nos formules d'abonnement.</a>
+ </div>
+ @endif
+
</div>
</div>