public function shortenURL($url)
{
- if ($this->config->linkShortener === 'none' || !Url::isDistant($url)) {
+
+ if (!$this->config->linkShortener || !Url::isDistant($url)) {
return $url;
}
return LinkShortener::shorturl($url, $this->config->linkShortener);
);
$fb = FluidbookPublication::withoutGlobalScopes()->find($fluidbook_id);
- return response()->json(['assets' => $fb->getLinksAssetsDimensions(), 'versions' => LinksData::getLinksVersions($fluidbook_id)]);
+ return response()->json(['assets' => $fb->getLinksAssetsDimensions(), 'versions' => LinksData::getLinksVersions($fluidbook_id), 'shortenedLinks' => $fb->getShortenedLinks()]);
}
protected function generateFont(Request $request, $id)
use Cubist\Util\Json;
use Cubist\Util\Markdown;
use Cubist\Util\Str;
+use Cubist\Util\Url;
use Datetime;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
return true;
}
- protected function _baseReplicate(?array $except=null)
+ protected function _baseReplicate(?array $except = null)
{
$current = $this;
if ($this->syncFromWorkshop()) {
return $new;
}
- public function replicateFull(?array $except=null)
+ public function replicateFull(?array $except = null)
{
$new = $this->_baseReplicate($except);
if (!$this->composition_fluidbook && $this->version >= 3) {
return $new;
}
- public function replicateSettings(?array $except=null)
+ public function replicateSettings(?array $except = null)
{
$new = $this->_baseReplicate(array_merge($except ?? [], ['composition']));
$new->composition = [];
->orderBy('created_at', 'desc')
->pluck('id');
}
+
+ public function getShortenedLinks()
+ {
+ if (!$this->linkShortener) {
+ return [];
+ }
+ $res = [];
+ LinksData::getLinksAndRulers($this->id, $links, $rulers);
+ foreach ($links as $link) {
+ if (Url::isDistant($link['to'])) {
+ $res[$link['to']] = LinkShortener::shorturl($link['to'], $this->linkShortener);
+ }
+ }
+ return $res;
+ }
}
var type = $(link).attr('fb-type');
var form = $("#linkeditor-form-template-" + type).clone(false);
+
+
$(form).attr('id', null);
$(form).data('link', link);
$(form).find('.init-tooltip').removeClass('init-tooltip');
this.updateFormData(form);
+ if (SHORTENED_LINKS[$(form).find('[name="to"]').val()] !== undefined) {
+ $(form).find('[name="to"]').after('<p class="help-block">' + TRANSLATIONS['short_link'] + ': <strong>' + SHORTENED_LINKS[$(form).find('[name="to"]').val()] + '</strong></p>');
+ }
+
container.append(form);
this.linkeditor.initTooltips();
$this.runningAutomaticSaveTimeout = false;
window.ASSETS = data.assets;
+ window.SHORTENED_LINKS = data.shortenedLinks;
$this.linkeditor.versions.setVersions(data.versions);
callback();
},
'fix_offset'=>__('Corriger décalage de page'),
'interactive_links'=>__('Liens interactifs'),
'noninteractive_links'=>__('Liens non-interactifs'),
+ 'short_link'=>__('Lien raccourci'),
];
$rulers=!count($rulers)?'{}':json_encode($rulers);
$settings[$k]=$user->getToolboxSetting('linkeditor_'.$k,$v);
}
$assets=$fluidbook->getLinksAssetsDimensions();
+ $shortenedLinks=$fluidbook->getShortenedLinks();
$alignments=[
'left'=>__('Aligner la sélection à gauche'),
data-tooltip="{{__('Ajout automatique de liens à partir d\'un excel')}}">
<form class="importExcel"
data-save-before-submit="{{__("Sauvegarde avant l'ajout automatique à partir d'un excel")}}"
- action="/fluidbook-publication/{{$fbdata['id']}}/edit/links/import/automatic" method="post"
+ action="/fluidbook-publication/{{$fbdata['id']}}/edit/links/import/automatic"
+ method="post"
enctype="multipart/form-data">
<input type="file"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
var ASSETS = @json($assets);
var CAN_CONTAIN_LINKS = @json($canContainLinks);
var DEPTH = @json($depths);
+ var SHORTENED_LINKS = @json($shortenedLinks);
</script>
<script
src="/packages/linkeditor{{$scriptVersion}}/js/linkeditor.js?v={{filemtime(public_path('packages/linkeditor'.$scriptVersion.'/js/linkeditor.js'))}}"></script>