From f649ba7a5a2dacd3484f072caf81ca469c027db2 Mon Sep 17 00:00:00 2001 From: jalel Date: Sun, 14 Dec 2025 21:26:25 +0000 Subject: [PATCH] Add Slug Generator tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Convert text to URL-friendly slugs - Separator options: hyphen, underscore, dot, none - Case options: lowercase, uppercase, preserve - Transliterate accented characters (é → e, ñ → n) - Option to remove numbers - Optional length limit - URL preview with generated slug - Example texts for quick testing - Client-side only implementation --- app/Http/Controllers/ToolController.php | 11 + resources/views/home.blade.php | 5 + .../views/tools/slug-generator.blade.php | 328 ++++++++++++++++++ routes/web.php | 2 + tests/Feature/WebRoutesTest.php | 32 +- 5 files changed, 373 insertions(+), 5 deletions(-) create mode 100644 resources/views/tools/slug-generator.blade.php diff --git a/app/Http/Controllers/ToolController.php b/app/Http/Controllers/ToolController.php index 13d83e9..190e431 100644 --- a/app/Http/Controllers/ToolController.php +++ b/app/Http/Controllers/ToolController.php @@ -75,6 +75,12 @@ public function index(): View 'route' => 'tools.regex', 'icon' => 'regex', ], + [ + 'name' => 'Slug Generator', + 'description' => 'Convert text to URL-friendly slugs', + 'route' => 'tools.slug-generator', + 'icon' => 'slug', + ], ]; return view('home', compact('tools')); @@ -134,4 +140,9 @@ public function regex(): View { return view('tools.regex'); } + + public function slugGenerator(): View + { + return view('tools.slug-generator'); + } } diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index c2600f0..1177aa2 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -90,6 +90,11 @@ @break + @case('slug') + + + + @break @endswitch
diff --git a/resources/views/tools/slug-generator.blade.php b/resources/views/tools/slug-generator.blade.php new file mode 100644 index 0000000..9e07b15 --- /dev/null +++ b/resources/views/tools/slug-generator.blade.php @@ -0,0 +1,328 @@ +@extends('layouts.app') + +@section('title', 'Slug Generator - Create URL-Friendly Slugs | Dev Tools') +@section('meta_description', 'Free online slug generator. Convert text to URL-friendly slugs. Customize separators, case, and transliteration options.') +@section('meta_keywords', 'slug generator, url slug, seo slug, friendly url, text to slug, slug maker, url generator, permalink generator') + +@push('schema') + +@endpush + +@section('content') +
+
+
+

Slug Generator

+

Convert text to URL-friendly slugs

+
+ ← Back +
+ +
+ +
+
+ + +

+ characters +

+
+ + +
+ + +
+ +
+ +
+ + + + +
+
+ + +
+ +
+ + + +
+
+ + +
+ + + +
+ + characters +
+
+
+
+
+ + +
+
+ +
+ + +
+

+ characters +

+
+ + +
+ +
+ https://example.com/ +
+
+ + +
+ +
+ + + +
+
+ + +
+

What is a Slug?

+

+ A slug is a URL-friendly version of a string, typically used in permalinks. It contains only lowercase letters, numbers, and hyphens, making URLs more readable and SEO-friendly. +

+
+
+
+
+@endsection + +@push('scripts') + +@endpush diff --git a/routes/web.php b/routes/web.php index 7c8961e..87e5560 100644 --- a/routes/web.php +++ b/routes/web.php @@ -17,6 +17,7 @@ Route::get('/url', [ToolController::class, 'url'])->name('url'); Route::get('/code-editor', [ToolController::class, 'codeEditor'])->name('code-editor'); Route::get('/regex', [ToolController::class, 'regex'])->name('regex'); + Route::get('/slug-generator', [ToolController::class, 'slugGenerator'])->name('slug-generator'); }); // Static Pages @@ -38,6 +39,7 @@ ['loc' => route('tools.url'), 'priority' => '0.8', 'changefreq' => 'monthly'], ['loc' => route('tools.code-editor'), 'priority' => '0.9', 'changefreq' => 'monthly'], ['loc' => route('tools.regex'), 'priority' => '0.8', 'changefreq' => 'monthly'], + ['loc' => route('tools.slug-generator'), 'priority' => '0.8', 'changefreq' => 'monthly'], ['loc' => route('about'), 'priority' => '0.5', 'changefreq' => 'monthly'], ['loc' => route('privacy'), 'priority' => '0.3', 'changefreq' => 'yearly'], ]; diff --git a/tests/Feature/WebRoutesTest.php b/tests/Feature/WebRoutesTest.php index 71c4bf8..8212ad9 100644 --- a/tests/Feature/WebRoutesTest.php +++ b/tests/Feature/WebRoutesTest.php @@ -29,6 +29,7 @@ public function test_home_page_displays_all_tools(): void $response->assertSee('URL Encoder'); $response->assertSee('Code Editor'); $response->assertSee('Regex Tester'); + $response->assertSee('Slug Generator'); } public function test_home_page_has_tool_links(): void @@ -46,6 +47,7 @@ public function test_home_page_has_tool_links(): void $response->assertSee('href="' . route('tools.url') . '"', false); $response->assertSee('href="' . route('tools.code-editor') . '"', false); $response->assertSee('href="' . route('tools.regex') . '"', false); + $response->assertSee('href="' . route('tools.slug-generator') . '"', false); } public function test_csv_tool_page_loads(): void @@ -252,9 +254,29 @@ public function test_regex_tool_has_required_elements(): void $response->assertSee('Match Details'); } + public function test_slug_generator_page_loads(): void + { + $response = $this->get('/tools/slug-generator'); + + $response->assertStatus(200); + $response->assertSee('Slug Generator'); + $response->assertSee('Convert text to URL-friendly slugs'); + } + + public function test_slug_generator_has_required_elements(): void + { + $response = $this->get('/tools/slug-generator'); + + $response->assertStatus(200); + $response->assertSee('Input Text'); + $response->assertSee('Generated Slug'); + $response->assertSee('Separator'); + $response->assertSee('Hyphen'); + } + public function test_all_pages_have_navigation(): void { - $pages = ['/', '/tools/csv', '/tools/yaml', '/tools/markdown', '/tools/sql', '/tools/base64', '/tools/uuid', '/tools/hash', '/tools/url', '/tools/code-editor', '/tools/regex']; + $pages = ['/', '/tools/csv', '/tools/yaml', '/tools/markdown', '/tools/sql', '/tools/base64', '/tools/uuid', '/tools/hash', '/tools/url', '/tools/code-editor', '/tools/regex', '/tools/slug-generator']; foreach ($pages as $page) { $response = $this->get($page); @@ -266,7 +288,7 @@ public function test_all_pages_have_navigation(): void public function test_all_pages_have_theme_toggle(): void { - $pages = ['/', '/tools/csv', '/tools/yaml', '/tools/markdown', '/tools/sql', '/tools/base64', '/tools/uuid', '/tools/hash', '/tools/url', '/tools/code-editor', '/tools/regex']; + $pages = ['/', '/tools/csv', '/tools/yaml', '/tools/markdown', '/tools/sql', '/tools/base64', '/tools/uuid', '/tools/hash', '/tools/url', '/tools/code-editor', '/tools/regex', '/tools/slug-generator']; foreach ($pages as $page) { $response = $this->get($page); @@ -279,7 +301,7 @@ public function test_all_pages_have_theme_toggle(): void public function test_all_pages_load_vite_assets(): void { // Code editor uses standalone template without Vite - $pages = ['/', '/tools/csv', '/tools/yaml', '/tools/markdown', '/tools/sql', '/tools/base64', '/tools/uuid', '/tools/hash', '/tools/url', '/tools/regex']; + $pages = ['/', '/tools/csv', '/tools/yaml', '/tools/markdown', '/tools/sql', '/tools/base64', '/tools/uuid', '/tools/hash', '/tools/url', '/tools/regex', '/tools/slug-generator']; foreach ($pages as $page) { $response = $this->get($page); @@ -292,7 +314,7 @@ public function test_all_pages_load_vite_assets(): void public function test_all_tool_pages_have_back_link(): void { // Code editor uses standalone template with home link instead of back - $toolPages = ['/tools/csv', '/tools/yaml', '/tools/markdown', '/tools/sql', '/tools/base64', '/tools/uuid', '/tools/hash', '/tools/url', '/tools/regex']; + $toolPages = ['/tools/csv', '/tools/yaml', '/tools/markdown', '/tools/sql', '/tools/base64', '/tools/uuid', '/tools/hash', '/tools/url', '/tools/regex', '/tools/slug-generator']; foreach ($toolPages as $page) { $response = $this->get($page); @@ -345,7 +367,7 @@ public function test_api_routes_reject_get_requests(): void public function test_pages_have_csrf_token(): void { - $pages = ['/tools/csv', '/tools/yaml', '/tools/markdown', '/tools/sql', '/tools/base64', '/tools/uuid', '/tools/hash', '/tools/url', '/tools/code-editor']; + $pages = ['/tools/csv', '/tools/yaml', '/tools/markdown', '/tools/sql', '/tools/base64', '/tools/uuid', '/tools/hash', '/tools/url', '/tools/code-editor', '/tools/slug-generator']; foreach ($pages as $page) { $response = $this->get($page);