Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
6d7cde0
wip
duncanmcclean Jan 30, 2024
00d734a
Cover slug generation in tests
duncanmcclean Jan 31, 2024
afc0b64
Reverse yesterday's JS changes
duncanmcclean Jan 31, 2024
7909882
Add test cases for #2817 & #6985
duncanmcclean Jan 31, 2024
a492019
wip
duncanmcclean Jan 31, 2024
0ea36f4
Change parameter names
duncanmcclean Jan 31, 2024
0eb166c
Refactor slugify helper
duncanmcclean Jan 31, 2024
e7b9d3a
Make the Slugify component work
duncanmcclean Jan 31, 2024
5222823
Change how handles are generated on create forms & add debounce
duncanmcclean Jan 31, 2024
80e651e
Refactor `$slugify` usage in some other places
duncanmcclean Feb 1, 2024
f2736f7
Refactor `$slugify` usage in filter components
duncanmcclean Feb 1, 2024
f317450
Merge branch '4.x' into slugify-on-the-server-side
duncanmcclean Feb 1, 2024
47ce347
Remove speakingurl library
duncanmcclean Feb 1, 2024
d90585e
Silly console logs.
duncanmcclean Feb 1, 2024
da555da
Add Arabic test case
duncanmcclean Feb 1, 2024
9a6c5f8
Merge branch 'master' into slugify-on-the-server-side
jasonvarga Mar 18, 2024
eef126e
Merge branch 'master' into slugify-on-the-server-side
jasonvarga Mar 19, 2024
ad94ef0
Move to more generic place as its not just a fieldtype thing
jasonvarga Mar 19, 2024
1db4b16
should be static
jasonvarga Mar 19, 2024
8d3e93a
tweaks ...
jasonvarga Mar 19, 2024
ec9fedb
fix tpyo
jasonvarga Mar 19, 2024
b0a9b3e
add test for different separator
jasonvarga Mar 19, 2024
4c2485a
data provider keys are allowed to have spaces
jasonvarga Mar 19, 2024
9f323c7
fix when you click the reset button that it doesnt actually change th…
jasonvarga Mar 19, 2024
9f3055c
since slugifying takes a moment now, show some visual feedback when y…
jasonvarga Mar 19, 2024
86e047b
fix syncing behavior. some of it was lost.
jasonvarga Mar 19, 2024
29fa036
debounce the slugify component
jasonvarga Mar 19, 2024
9e84e74
add new $slug api
jasonvarga Mar 19, 2024
3adc21a
apply to a form
jasonvarga Mar 19, 2024
3a14418
Abort previous requests if a new one is triggered.
jasonvarga Mar 20, 2024
692ba1c
fix error/rejection handling. chaining catch onto $slug.create() wasn…
jasonvarga Mar 20, 2024
ab96662
prevent a request when empty string is passed
jasonvarga Mar 20, 2024
2ce9fbd
revert the $slugify plugin to original state
jasonvarga Mar 20, 2024
900dfd7
revert to old $slugify in some places where synchronous behavior is m…
jasonvarga Mar 20, 2024
319d871
apply new style to more forms
jasonvarga Mar 20, 2024
700637d
missed one
jasonvarga Mar 20, 2024
c48ced7
diff
jasonvarga Mar 20, 2024
8170b6f
move existing slugify logic into new class and make async opt in
jasonvarga Mar 20, 2024
72a2a77
prevent submitting while slug be sluggin
jasonvarga Mar 20, 2024
48607e4
emit events in the component so we can track status and apply loading…
jasonvarga Mar 20, 2024
9724a6e
use a spinner instead of dimming
jasonvarga Mar 20, 2024
61ad8ac
not needed
jasonvarga Mar 20, 2024
7a32674
deprecate $slugify, add snake_case and replace and instances
jasonvarga Mar 20, 2024
743d87a
rename
jasonvarga Mar 20, 2024
6d1fcf5
add str_slug global alias
jasonvarga Mar 20, 2024
f70b58c
nitpick
jasonvarga Mar 20, 2024
ee0629b
wip
jasonvarga Mar 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Vue.prototype.$echo = Statamic.$echo;
Vue.prototype.$bard = Statamic.$bard;
Vue.prototype.$keys = Statamic.$keys;
Vue.prototype.$reveal = Statamic.$reveal;
Vue.prototype.$slug = Statamic.$slug;

import Moment from 'moment';
window.moment = Vue.moment = Vue.prototype.$moment = Moment;
Expand Down
2 changes: 1 addition & 1 deletion resources/js/bootstrap/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import LoadingGraphic from '../components/LoadingGraphic.vue';
import DropdownList from '../components/DropdownList.vue';
import DropdownItem from '../components/DropdownItem.vue';
import ValidationErrors from '../components/ValidationErrors.vue';
import Slugify from '../components/Slugify.vue';
import Slugify from '../components/slugs/Slugify.vue';
import ElementContainer from '../components/ElementContainer.vue';
import Avatar from '../components/Avatar.vue';
import Breadcrumb from '../components/Breadcrumb.vue';
Expand Down
10 changes: 9 additions & 1 deletion resources/js/bootstrap/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,12 @@ export function closestVm(el, name) {
if (!name || name === vm.$options.name) return vm;
vm = vm.$parent;
}
}
}

export function str_slug(string) {
return Statamic.$slug.create(string);
}

export function snake_case(string) {
return Statamic.$slug.separatedBy('_').create(string);
}
70 changes: 0 additions & 70 deletions resources/js/components/Slugify.vue

This file was deleted.

6 changes: 6 additions & 0 deletions resources/js/components/Statamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Reveal from './Reveal';
import Components from './Components';
import FieldConditions from './FieldConditions';
import Callbacks from './Callbacks';
import Slugs from './slugs/Manager.js';
const echo = new Echo;
const bard = new Bard;
const keys = new Keys;
Expand All @@ -15,6 +16,7 @@ const reveal = new Reveal;
const components = new Components;
const conditions = new FieldConditions;
const callbacks = new Callbacks;
const slug = new Slugs;

export default new Vue({
data() {
Expand Down Expand Up @@ -63,6 +65,10 @@ export default new Vue({
return keys;
},

$slug() {
return slug;
},

user() {
return this.$config.get('user');
}
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/blueprints/Section.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default {

'editingSection.display': function(display) {
if (this.editingSection && this.handleSyncedWithDisplay) {
this.editingSection.handle = this.$slugify(display, '_');
this.editingSection.handle = snake_case(display);
}
}

Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/blueprints/Sections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default {
display: this.newSectionText,
instructions: null,
icon: null,
handle: this.$slugify(this.newSectionText, '_'),
handle: snake_case(this.newSectionText),
fields: []
};

Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/blueprints/Tab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default {

fieldUpdated(handle, value) {
if (handle === 'display' && this.handleSyncedWithDisplay) {
this.handle = this.$slugify(value, '_');
this.handle = snake_case(value);
}

if (handle === 'handle') {
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/blueprints/Tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export default {
this.tabs.push({
_id: id,
display: this.newTabText,
handle: this.$slugify(this.newTabText, '_'),
handle: snake_case(this.newTabText),
instructions: null,
icon: null,
sections: []
Expand Down
14 changes: 9 additions & 5 deletions resources/js/components/collections/CreateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
</div>
<div class="mb-4">
<label class="font-bold text-base mb-1" for="name">{{ __('Handle') }}</label>
<input type="text" v-model="handle" class="input-text" tabindex="2">
<div class="relative">
<loading-graphic inline text="" v-if="slug.busy" class="absolute top-3 right-3"/>
<input type="text" v-model="handle" class="input-text" tabindex="2">
</div>
<div class="text-2xs text-gray-600 mt-2 flex items-center">
{{ __('messages.collection_configure_handle_instructions') }}
</div>
Expand Down Expand Up @@ -43,19 +46,20 @@ export default {
data() {
return {
title: null,
handle: null
handle: null,
slug: this.$slug.async().separatedBy('_'),
}
},

watch: {
'title': function(val) {
this.handle = this.$slugify(val, '_');
title(title) {
this.slug.create(title).then(slug => this.handle = slug);
}
},

computed: {
canSubmit() {
return Boolean(this.title && this.handle);
return Boolean(this.title && this.handle && !this.slug.busy);
},
},

Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/data-list/FilterPresets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
},

savingPresetSlug() {
return this.$slugify(this.savingPresetName, '_');
return snake_case(this.savingPresetName);
},
},

Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/data-list/Filters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default {
},

savingPresetHandle() {
return this.$slugify(this.savingPresetName, '_');
return snake_case(this.savingPresetName);
},

isUpdatingPreset() {
Expand Down
14 changes: 9 additions & 5 deletions resources/js/components/fieldsets/CreateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
</div>
<div class="mb-4">
<label class="font-bold text-base mb-1" for="name">{{ __('Handle') }}</label>
<input type="text" v-model="handle" class="input-text" tabindex="2">
<div class="relative">
<loading-graphic inline text="" v-if="slug.busy" class="absolute top-3 right-3"/>
<input type="text" v-model="handle" class="input-text" tabindex="2">
</div>
<div class="text-2xs text-gray-600 mt-2 flex items-center">
{{ __('messages.fieldsets_handle_instructions') }}
</div>
Expand Down Expand Up @@ -43,19 +46,20 @@ export default {
data() {
return {
title: null,
handle: null
handle: null,
slug: this.$slug.async().separatedBy('_'),
}
},

watch: {
'title': function(val) {
this.handle = this.$slugify(val, '_');
title(title) {
this.slug.create(title).then(slug => this.handle = slug);
}
},

computed: {
canSubmit() {
return Boolean(this.title && this.handle);
return Boolean(this.title && this.handle && !this.slug.busy);
},
},

Expand Down
8 changes: 6 additions & 2 deletions resources/js/components/fieldtypes/SlugFieldtype.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
:from="source"
:separator="separator"
:language="language"
@slugifying="syncing = true"
@slugified="syncing = false"
v-model="slug"
>
<div>
Expand All @@ -21,7 +23,8 @@
>
<template v-slot:append v-if="config.show_regenerate">
<button class="input-group-append items-center flex" @click="sync" v-tooltip="__('Regenerate from: :field', { 'field': config.from })">
<svg-icon name="light/synchronize" class="w-5 h-5" />
<svg-icon name="light/synchronize" class="w-5 h-5" v-show="!syncing" />
<div class="w-5 h-5" v-show="syncing"><loading-graphic inline text="" class="mt-0.5 ml-0.5" /></div>
</button>
</template>
</text-input>
Expand All @@ -41,7 +44,8 @@ export default {
data() {
return {
slug: this.value,
generate: this.config.generate
generate: this.config.generate,
syncing: false,
}
},

Expand Down
14 changes: 9 additions & 5 deletions resources/js/components/forms/CreateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
</div>
<div class="mb-4">
<label class="font-bold text-base mb-1" for="name">{{ __('Handle') }}</label>
<input type="text" v-model="handle" class="input-text" tabindex="2">
<div class="relative">
<loading-graphic inline text="" v-if="slug.busy" class="absolute top-3 right-3"/>
<input type="text" v-model="handle" class="input-text" tabindex="2">
</div>
<div class="text-2xs text-gray-600 mt-2 flex items-center">
{{ __('messages.form_configure_handle_instructions') }}
</div>
Expand Down Expand Up @@ -43,19 +46,20 @@ export default {
data() {
return {
title: null,
handle: null
handle: null,
slug: this.$slug.async().separatedBy('_'),
}
},

watch: {
'title': function(val) {
this.handle = this.$slugify(val, '_');
title(title) {
this.slug.create(title).then(slug => this.handle = slug);
}
},

computed: {
canSubmit() {
return Boolean(this.title && this.handle);
return Boolean(this.title && this.handle && !this.slug.busy);
},
},

Expand Down
14 changes: 9 additions & 5 deletions resources/js/components/globals/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
</div>
<div class="mb-4">
<label class="font-bold text-base mb-1" for="name">{{ __('Handle') }}</label>
<input type="text" v-model="handle" class="input-text" tabindex="2">
<div class="relative">
<loading-graphic inline text="" v-if="slug.busy" class="absolute top-3 right-3"/>
<input type="text" v-model="handle" class="input-text" tabindex="2">
</div>
<div class="text-2xs text-gray-600 mt-2 flex items-center">
{{ __('messages.globals_configure_handle_instructions') }}
</div>
Expand All @@ -42,19 +45,20 @@ export default {
data() {
return {
title: null,
handle: null
handle: null,
slug: this.$slug.async().separatedBy('_'),
}
},

watch: {
'title': function(val) {
this.handle = this.$slugify(val, '_');
title(title) {
this.slug.create(title).then(slug => this.handle = slug);
}
},

computed: {
canSubmit() {
return Boolean(this.title && this.handle);
return Boolean(this.title && this.handle && !this.slug.busy);
},
},

Expand Down
Loading