mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-11 12:09:36 +00:00
Added settings and docs for the generic Web info provider
This commit is contained in:
parent
071f6f8591
commit
722eb7ddab
6 changed files with 86 additions and 5 deletions
|
|
@ -96,6 +96,21 @@ The following providers are currently available and shipped with Part-DB:
|
||||||
|
|
||||||
(All trademarks are property of their respective owners. Part-DB is not affiliated with any of the companies.)
|
(All trademarks are property of their respective owners. Part-DB is not affiliated with any of the companies.)
|
||||||
|
|
||||||
|
### Generic Web URL Provider
|
||||||
|
The Generic Web URL Provider can extract part information from any webpage that contains structured data in the form of
|
||||||
|
[Schema.org](https://schema.org/) format. Many e-commerce websites use this format to provide detailed product information
|
||||||
|
for search engines and other services. Therefore it allows Part-DB to retrieve rudimentary part information (like name, image and price)
|
||||||
|
from a wide range of websites without the need for a dedicated API integration.
|
||||||
|
To use the Generic Web URL Provider, simply enable it in the information provider settings. No additional configuration
|
||||||
|
is required. Afterwards you can enter any product URL in the search field, and Part-DB will attempt to extract the relevant part information
|
||||||
|
from the webpage.
|
||||||
|
|
||||||
|
Please note that if this provider is enabled, Part-DB will make HTTP requests to external websites to fetch product data, which
|
||||||
|
may have privacy and security implications.
|
||||||
|
|
||||||
|
Following env configuration options are available:
|
||||||
|
* `PROVIDER_GENERIC_WEB_ENABLED`: Set this to `1` to enable the Generic Web URL Provider (optional, default: `0`)
|
||||||
|
|
||||||
### Octopart
|
### Octopart
|
||||||
|
|
||||||
The Octopart provider uses the [Octopart / Nexar API](https://nexar.com/api) to search for parts and get information.
|
The Octopart provider uses the [Octopart / Nexar API](https://nexar.com/api) to search for parts and get information.
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ use App\Exceptions\ProviderIDNotSupportedException;
|
||||||
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
|
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
|
||||||
use App\Services\InfoProviderSystem\DTOs\PriceDTO;
|
use App\Services\InfoProviderSystem\DTOs\PriceDTO;
|
||||||
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
|
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
|
||||||
|
use App\Settings\InfoProviderSystem\GenericWebProviderSettings;
|
||||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Price;
|
use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Price;
|
||||||
use Symfony\Component\DomCrawler\Crawler;
|
use Symfony\Component\DomCrawler\Crawler;
|
||||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
|
|
@ -38,7 +39,7 @@ class GenericWebProvider implements InfoProviderInterface
|
||||||
|
|
||||||
private readonly HttpClientInterface $httpClient;
|
private readonly HttpClientInterface $httpClient;
|
||||||
|
|
||||||
public function __construct(HttpClientInterface $httpClient)
|
public function __construct(HttpClientInterface $httpClient, private readonly GenericWebProviderSettings $settings)
|
||||||
{
|
{
|
||||||
$this->httpClient = $httpClient->withOptions(
|
$this->httpClient = $httpClient->withOptions(
|
||||||
[
|
[
|
||||||
|
|
@ -54,9 +55,10 @@ class GenericWebProvider implements InfoProviderInterface
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => 'Generic Web URL',
|
'name' => 'Generic Web URL',
|
||||||
'description' => 'Tries to extract a part from a given product',
|
'description' => 'Tries to extract a part from a given product webpage URL using common metadata standards like JSON-LD and OpenGraph.',
|
||||||
//'url' => 'https://example.com',
|
//'url' => 'https://example.com',
|
||||||
'disabled_help' => 'Enable in settings to use this provider'
|
'disabled_help' => 'Enable in settings to use this provider',
|
||||||
|
'settings_class' => GenericWebProviderSettings::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,7 +69,7 @@ class GenericWebProvider implements InfoProviderInterface
|
||||||
|
|
||||||
public function isActive(): bool
|
public function isActive(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return $this->settings->enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function searchByKeyword(string $keyword): array
|
public function searchByKeyword(string $keyword): array
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 - 2026 Jan Böhmer (https://github.com/jbtronics)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published
|
||||||
|
* by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Settings\InfoProviderSystem;
|
||||||
|
|
||||||
|
use App\Settings\SettingsIcon;
|
||||||
|
use Jbtronics\SettingsBundle\Metadata\EnvVarMode;
|
||||||
|
use Jbtronics\SettingsBundle\Settings\Settings;
|
||||||
|
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
|
||||||
|
use Jbtronics\SettingsBundle\Settings\SettingsTrait;
|
||||||
|
use Symfony\Component\Translation\TranslatableMessage as TM;
|
||||||
|
|
||||||
|
#[Settings(label: new TM("settings.ips.generic_web_provider"), description: new TM("settings.ips.generic_web_provider.description"))]
|
||||||
|
#[SettingsIcon("fa-plug")]
|
||||||
|
class GenericWebProviderSettings
|
||||||
|
{
|
||||||
|
use SettingsTrait;
|
||||||
|
|
||||||
|
#[SettingsParameter(label: new TM("settings.ips.lcsc.enabled"), description: new TM("settings.ips.generic_web_provider.enabled.help"),
|
||||||
|
envVar: "bool:PROVIDER_GENERIC_WEB_ENABLED", envVarMode: EnvVarMode::OVERWRITE
|
||||||
|
)]
|
||||||
|
public bool $enabled = false;
|
||||||
|
}
|
||||||
|
|
@ -37,6 +37,9 @@ class InfoProviderSettings
|
||||||
#[EmbeddedSettings]
|
#[EmbeddedSettings]
|
||||||
public ?InfoProviderGeneralSettings $general = null;
|
public ?InfoProviderGeneralSettings $general = null;
|
||||||
|
|
||||||
|
#[EmbeddedSettings]
|
||||||
|
public ?GenericWebProviderSettings $genericWebProvider = null;
|
||||||
|
|
||||||
#[EmbeddedSettings]
|
#[EmbeddedSettings]
|
||||||
public ?DigikeySettings $digikey = null;
|
public ?DigikeySettings $digikey = null;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
{% block card_content %}
|
{% block card_content %}
|
||||||
<div class="offset-sm-3">
|
<div class="offset-sm-3">
|
||||||
<h3>
|
<h3>
|
||||||
{% if info_provider_info.url %}
|
{% if info_provider_info.url is defined %}
|
||||||
<a href="{{ info_provider_info.url }}" class="link-external" target="_blank" rel="nofollow">{{ info_provider_info.name }}</a>
|
<a href="{{ info_provider_info.url }}" class="link-external" target="_blank" rel="nofollow">{{ info_provider_info.name }}</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ info_provider_info.name }}
|
{{ info_provider_info.name }}
|
||||||
|
|
|
||||||
|
|
@ -14316,5 +14316,23 @@ Buerklin-API Authentication server:
|
||||||
<target>Only includes attachments in the selected languages in the results.</target>
|
<target>Only includes attachments in the selected languages in the results.</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
|
<unit id="PNmvQ.U" name="settings.ips.generic_web_provider">
|
||||||
|
<segment>
|
||||||
|
<source>settings.ips.generic_web_provider</source>
|
||||||
|
<target>Generic Web URL Provider</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
|
<unit id="Vk3BoE_" name="settings.ips.generic_web_provider.description">
|
||||||
|
<segment>
|
||||||
|
<source>settings.ips.generic_web_provider.description</source>
|
||||||
|
<target>This info provider allows to retrieve basic part information from many shop page URLs.</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
|
<unit id="Pu8juaH" name="settings.ips.generic_web_provider.enabled.help">
|
||||||
|
<segment>
|
||||||
|
<source>settings.ips.generic_web_provider.enabled.help</source>
|
||||||
|
<target>When the provider is enabled, users can make requests to arbitary websites on behalf of the Part-DB server. Only enable this, if you are aware of the potential consequences.</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue