Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link Suggestions/Management #348

Draft
wants to merge 161 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
161 commits
Select commit Hold shift + click to select a range
68b6ded
WIP
JohnathonKoster Sep 11, 2024
4965ca9
Merge branch 'master' into content-linking
JohnathonKoster Sep 11, 2024
3a0444e
Improve context retrieval
JohnathonKoster Sep 14, 2024
9ca1246
Be smarter about how data is updated
JohnathonKoster Sep 14, 2024
cf935ac
Use correct entry id
JohnathonKoster Sep 14, 2024
d144ab7
Be smart about detecting added/removed links
JohnathonKoster Sep 14, 2024
1f3b2af
Create InternalLinksUpdated.php
JohnathonKoster Sep 14, 2024
8964e51
Check for internal changes when updating
JohnathonKoster Sep 14, 2024
297e9d2
Add cached_uri to list of fields searched
JohnathonKoster Sep 14, 2024
6f50816
Adds support for inserting links into Bard fields 😮‍💨
JohnathonKoster Sep 14, 2024
5f29eb8
Wire some stuff up!
JohnathonKoster Sep 14, 2024
2869f04
Tidy up a bit
JohnathonKoster Sep 14, 2024
cabd1e5
Remove for now
JohnathonKoster Sep 15, 2024
f12394f
Ability to disable the text linking stuff
JohnathonKoster Sep 15, 2024
803cf5b
Dramatically improves success rate of suggestion linkability
JohnathonKoster Sep 15, 2024
0dbf070
Adds support for automatically inserting "global auto" links into con…
JohnathonKoster Sep 15, 2024
8529300
Inject current site, if available
JohnathonKoster Sep 15, 2024
6a45891
Related content tag
JohnathonKoster Sep 16, 2024
7e8b72b
Reset this for anyone who might pull it down to experiment
JohnathonKoster Sep 16, 2024
76c0f54
Add filter presets to UI
JohnathonKoster Sep 16, 2024
fc10552
Adds a quick way to mark an entry as "not related"
JohnathonKoster Sep 16, 2024
a5fc1c6
Prevent fatal errors if an entry isn't available
JohnathonKoster Sep 16, 2024
b9c9f3e
Improve smartness of locating related entries.
JohnathonKoster Sep 16, 2024
72fb551
Provide a quick way to edit related entries
JohnathonKoster Sep 16, 2024
0be9e78
Link to related content suggestions instead
JohnathonKoster Sep 16, 2024
830bd14
Consistency
JohnathonKoster Sep 16, 2024
3467b29
Consistent linking here, too.
JohnathonKoster Sep 16, 2024
8b1fe3e
Correct removed offset.
JohnathonKoster Sep 16, 2024
8151a4d
Merge branch 'master' into content-linking
JohnathonKoster Sep 17, 2024
5b8b84b
🍻
JohnathonKoster Sep 17, 2024
8e3124d
Stop the failed test spam for the day 😅
JohnathonKoster Sep 17, 2024
e511c9e
Make method easier to read
JohnathonKoster Sep 17, 2024
71e7e6b
Update ScanEntryLinks.php
JohnathonKoster Sep 17, 2024
13aeb1b
Update ServiceProvider.php
JohnathonKoster Sep 17, 2024
f6f79bb
Update index.blade.php
JohnathonKoster Sep 17, 2024
7581c34
Correct issue with wrapping
JohnathonKoster Sep 17, 2024
7512fb2
Delete hot
JohnathonKoster Sep 17, 2024
107825e
line endings
JohnathonKoster Sep 17, 2024
66521ea
Correct an issue when match appears at the end of the suggestion's ph…
JohnathonKoster Sep 17, 2024
f6d6cfa
Cleanup a bit
JohnathonKoster Sep 17, 2024
fdbaa1d
Consolidate some URL generation
JohnathonKoster Sep 21, 2024
3a9d0a3
Cleanup/refactor
JohnathonKoster Sep 21, 2024
4b388d7
Don't force-cast here to also allow "."
JohnathonKoster Sep 21, 2024
68a48d6
Group fieldtype support
JohnathonKoster Sep 21, 2024
7fe8d22
Update AbstractFieldMapper.php
JohnathonKoster Sep 21, 2024
6534a32
Refactoring/cleanup
JohnathonKoster Sep 21, 2024
04404f7
Sneaky little guy
JohnathonKoster Sep 21, 2024
7a7b94b
More cleanup
JohnathonKoster Sep 21, 2024
ccc08e1
Update ContentMapper.php
JohnathonKoster Sep 21, 2024
44b9a5b
Update ContentMapper.php
JohnathonKoster Sep 21, 2024
0c62513
Update ContentMapper.php
JohnathonKoster Sep 21, 2024
102a184
Always use fresh mappings to account for potentially stale cache
JohnathonKoster Sep 21, 2024
d08ab0d
Refactor how nested field names are retrieved
JohnathonKoster Sep 21, 2024
463ec34
More cleanup
JohnathonKoster Sep 21, 2024
42097b3
Dont return non-replaceable suggestions if we have a suggestion that …
JohnathonKoster Sep 21, 2024
74c4884
Update ServiceProvider.php
JohnathonKoster Sep 21, 2024
dcd667f
Update LinkRepository.php
JohnathonKoster Sep 21, 2024
0d11832
Add support for preventing circular links when suggesting related con…
JohnathonKoster Sep 21, 2024
b10b4be
Update seo-pro.php
JohnathonKoster Sep 21, 2024
7f0389f
"linking" sounds less confusing that "text_analysis"
JohnathonKoster Sep 22, 2024
8966de0
Consistency with other links
JohnathonKoster Sep 22, 2024
68b58eb
Move "Content" namespace to root
JohnathonKoster Sep 22, 2024
8f79404
Update ContentMapper.php
JohnathonKoster Sep 22, 2024
aaa66ab
Namespace move
JohnathonKoster Sep 22, 2024
2b6503e
More moves
JohnathonKoster Sep 22, 2024
d1d6d15
New queries namespace
JohnathonKoster Sep 22, 2024
09d6c10
Make IDE happy, formatting of long query method chain
JohnathonKoster Sep 22, 2024
dbcb040
Remove internal weighting to simplify
JohnathonKoster Sep 22, 2024
a798ee5
Update KeywordsRepository.php
JohnathonKoster Sep 22, 2024
fab5888
Some breathing room
JohnathonKoster Sep 22, 2024
5493d0a
Update ReportBuilder.php
JohnathonKoster Sep 22, 2024
544935d
Update ReportBuilder.php
JohnathonKoster Sep 22, 2024
ac6c98e
Squiggly be gone
JohnathonKoster Sep 22, 2024
4f1c834
Make related/result limits fine-tuneable
JohnathonKoster Sep 22, 2024
9539cd1
squigglies
JohnathonKoster Sep 22, 2024
653589d
Cleanup/make chunk size not hard-coded
JohnathonKoster Sep 22, 2024
a1b9228
Chunksize/return types
JohnathonKoster Sep 22, 2024
ff80104
Cleanup
JohnathonKoster Sep 22, 2024
011beeb
Reducio 🪄
JohnathonKoster Sep 22, 2024
7eba0d3
Update ResolvesSimilarItems.php
JohnathonKoster Sep 22, 2024
b80a13e
help make future diffs less nasty
JohnathonKoster Sep 22, 2024
c23c5b3
Get outa here 🥾
JohnathonKoster Sep 22, 2024
605e95d
Update ReportBuilder.php
JohnathonKoster Sep 22, 2024
3c2a3bd
Get rid of a nesting level
JohnathonKoster Sep 22, 2024
216d41e
And another one
JohnathonKoster Sep 22, 2024
584f937
clarity.
JohnathonKoster Sep 22, 2024
6d64f05
More cleanup
JohnathonKoster Sep 22, 2024
29df5a9
That feels better
JohnathonKoster Sep 22, 2024
f3013b9
new 🏠
JohnathonKoster Sep 22, 2024
d791a58
he can go live with his friends, too
JohnathonKoster Sep 22, 2024
36d487a
Update KeywordsRepository.php
JohnathonKoster Sep 22, 2024
3bd6cf5
Update LinkCrawler.php
JohnathonKoster Sep 22, 2024
13dd960
Prevent sneaky directory traversal/arbitrary code inclusion
JohnathonKoster Sep 22, 2024
8fd6f0b
Merge branch 'master' into content-linking
JohnathonKoster Nov 24, 2024
a9893fd
Refactor condition to be easier to reason about
JohnathonKoster Nov 24, 2024
de652e7
Makes additional config values environment-driven
JohnathonKoster Nov 24, 2024
71671eb
Update to match new config namespace
JohnathonKoster Nov 24, 2024
5547267
Refactor content retrieval
JohnathonKoster Nov 24, 2024
cfa8143
Simplify stuff
JohnathonKoster Nov 24, 2024
6b0ca72
Don't run job if the entry lacks a URL
JohnathonKoster Nov 24, 2024
6da4c71
Removes some ahrd-coded jankiness
JohnathonKoster Nov 27, 2024
7fe5e6c
More WIP
JohnathonKoster Nov 27, 2024
a95b8d0
Move it move it
JohnathonKoster Nov 27, 2024
8ffd18b
Some better default sorting behavior
JohnathonKoster Nov 27, 2024
7608f22
Prevent implicit conversions, which causes warnings
JohnathonKoster Nov 27, 2024
c3ddf31
More UI tweaks
JohnathonKoster Nov 27, 2024
3d85bdd
Move some stuff around
JohnathonKoster Nov 27, 2024
35d5b17
Refactor/remove unused method.
JohnathonKoster Nov 27, 2024
6f8b2fe
Shift where this is set.
JohnathonKoster Nov 27, 2024
25e8761
More collection/site visibility adjustments
JohnathonKoster Nov 28, 2024
78375a7
More adjustments
JohnathonKoster Nov 28, 2024
1179f4b
Only register routes if enabled.
JohnathonKoster Nov 28, 2024
53c9e38
More UI permissions updates
JohnathonKoster Nov 28, 2024
b21fa7b
Better name is better
JohnathonKoster Nov 28, 2024
afd152b
Register permission conditionally
JohnathonKoster Nov 28, 2024
0200acc
Remove from listing
JohnathonKoster Nov 28, 2024
efb4ab8
Cleanup cleanup
JohnathonKoster Nov 28, 2024
5a38a53
Even more permissions
JohnathonKoster Nov 28, 2024
43cf59a
Update ContentRetriever.php
JohnathonKoster Nov 28, 2024
aed31e0
Refactor
JohnathonKoster Nov 28, 2024
d1955c5
More WIP
JohnathonKoster Nov 29, 2024
7c98572
Even more!
JohnathonKoster Nov 29, 2024
d1d2520
Consistency
JohnathonKoster Nov 29, 2024
7481f58
Some translation strings
JohnathonKoster Nov 29, 2024
c6a2520
Controller translation strings
JohnathonKoster Nov 29, 2024
051003e
Move it movie it
JohnathonKoster Nov 29, 2024
663c840
More translation strings
JohnathonKoster Nov 29, 2024
c74bcb7
String tweaks
JohnathonKoster Nov 29, 2024
bcebbc3
Even MORE translation strings
JohnathonKoster Nov 29, 2024
6f47440
Consistency.
JohnathonKoster Nov 29, 2024
eaff86d
Update AutomaticLinksListing.vue
JohnathonKoster Nov 29, 2024
914f9d3
Update ExternalLinkListing.vue
JohnathonKoster Nov 29, 2024
a282072
Update RelatedContent.vue
JohnathonKoster Nov 29, 2024
075582c
Update SuggestionsListing.vue
JohnathonKoster Nov 29, 2024
d908da6
Add some success messages 💅
JohnathonKoster Nov 29, 2024
75066d8
Remove temporary stuff.
JohnathonKoster Nov 29, 2024
f628cf2
Update messages.php
JohnathonKoster Nov 29, 2024
0fed600
Automatic global link permissions
JohnathonKoster Nov 29, 2024
87e98f7
Give it a better name 😊
JohnathonKoster Nov 30, 2024
8e7b6e0
"Linking" sounds less spooky than "TextProcessing"
JohnathonKoster Nov 30, 2024
6982394
Adjust linking group
JohnathonKoster Nov 30, 2024
10b169d
Make migrations targetable
JohnathonKoster Nov 30, 2024
f89a7b9
Make it env controllable
JohnathonKoster Nov 30, 2024
fefffa7
Start of guided install command/assistant
JohnathonKoster Nov 30, 2024
728a961
Little more polish, consistent variable names.
JohnathonKoster Dec 7, 2024
a28f223
Subtle tweaks, making things a bit less brittle
JohnathonKoster Dec 8, 2024
0d5c9bb
Update replaceValue
JohnathonKoster Dec 8, 2024
56380ef
Update ConfigurationRepository.php
JohnathonKoster Dec 8, 2024
9d7e33a
Utilize config internally
JohnathonKoster Dec 8, 2024
2a10ffe
Update config key
JohnathonKoster Dec 8, 2024
66d42ea
Check all disabled collections
JohnathonKoster Dec 8, 2024
c3381b4
Provide a simple way to sync entry title/uris from flat-file changes
JohnathonKoster Dec 8, 2024
d638027
Prevent loading screen on every interaction
JohnathonKoster Dec 9, 2024
f2398f3
Prevent constant errors if someone is just switching/unlinking entries
JohnathonKoster Dec 9, 2024
5716af8
Ensure ignored site phrases are saved correctly
JohnathonKoster Dec 9, 2024
8b278c7
Hide for now
JohnathonKoster Dec 14, 2024
0b15ef2
Adjust the groups yay
JohnathonKoster Dec 14, 2024
a8bfed5
Rename for consistency before its too annoying to change it
JohnathonKoster Dec 15, 2024
949ddea
Provide an option to skip field config
JohnathonKoster Dec 15, 2024
87b6ea3
Make it make sense!
JohnathonKoster Dec 15, 2024
e7e6ea8
Merge branch 'master' into content-linking
JohnathonKoster Dec 15, 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
Prev Previous commit
Next Next commit
Start of guided install command/assistant
  • Loading branch information
JohnathonKoster committed Nov 30, 2024
commit fefffa7f1700229cced23fa874eb5b7285a583eb
67 changes: 67 additions & 0 deletions src/Commands/InstallLinksCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace Statamic\SeoPro\Commands;

use Illuminate\Console\Command;
use Statamic\Console\RunsInPlease;
use Statamic\SeoPro\Config\EnvWriter;

class InstallLinksCommand extends Command
{
use RunsInPlease;

protected $signature = 'statamic:seo-pro:links-install';

protected $description = 'Assists with installing and configuration content linking features.';

public function handle()
{
$this->info('Linking Installation');

if (! $this->confirm('Do you have a database connection configured?')) {
$this->error('Please configure a database in order to use content linking.');
exit;
}

if ($this->confirm('Would you like to publish and run the content linking migrations?', true)) {
$this->call('vendor:publish', [
'--tag' => 'seo-pro-migrations',
'--force' => true,
]);
$this->call('migrate');
}

$writer = new EnvWriter;

if ($this->confirm('Would you like to configure your OpenAI API access?', true)) {
$writer->open(base_path('.env'));
if ($this->confirm('Will you be using a third-party, OpenAI compatible API?')) {
$writer->setValue(
'SEO_PRO_OPENAI_BASE_URI',
$this->ask('What is the base URL for the API you will be using?'),
'statamic.seo-pro.linking.openai.base_uri',
);
}

$writer->setValue(
'SEO_PRO_OPENAI_API_KEY',
$this->ask('Please enter the API key to make requests'),
'statamic.seo-pro.linking.openai.api_key'
)->setValue(
'SEO_PRO_OPENAI_MODEL',
$this->ask('What AI model would you like to use?', 'text-embedding-3-small'),
'statamic.seo-pro.linking.openai.model',
);
}

if ($this->confirm('Would you like to enable content linking?', true)) {
$writer->setValue(
'SEO_PRO_LINKING_ENABLED',
'true',
'statamic.seo-pro.linking.enabled',
);
}

$writer->save();
}
}
65 changes: 65 additions & 0 deletions src/Config/EnvWriter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace Statamic\SeoPro\Config;

use Exception;

class EnvWriter
{
protected string $contents = '';
protected ?string $path = null;

public function open(string $path): void
{
$this->path = $path;
$this->contents = file_get_contents($path);
}

public function setValue(string $key, string $value, string $configKey): static
{
$pattern = $this->getReplacementPattern($key, $value, $configKey);

if ($this->keyExists($key)) {
$this->replaceValue($pattern, "{$key}={$value}");
} else {
$this->appendValue($key, $value);
}

return $this;
}

protected function appendValue(string $key, string $value): void
{
$this->contents .= "\n{$key}={$value}";
}

protected function replaceValue(string $pattern, string $newValue): void
{
preg_replace(
$this->contents,
$pattern,
$newValue
);
}

protected function keyExists(string $key): bool
{
return preg_match('/^'.$key.'=/m', $this->contents);
}

protected function getReplacementPattern(string $key, string $value, string $configKey): string
{
$escaped = preg_quote('='.config($configKey), '/');

return "/^{$key}{$escaped}/m";
}

public function save(): void
{
if (! $this->path) {
throw new Exception('No environment file has been opened.');
}

file_put_contents($this->path, $this->contents);
}
}
1 change: 1 addition & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ protected function bootAddonCommands()
SeoPro\Commands\GenerateKeywordsCommand::class,
SeoPro\Commands\ScanLinksCommand::class,
SeoPro\Commands\AnalyzeContentCommand::class,
SeoPro\Commands\InstallLinksCommand::class,
]);

return $this;
Expand Down