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

Added support for environmental settings #547

Open
wants to merge 1 commit into
base: 5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions src/models/FeedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace craft\feedme\models;

use Cake\Utility\Hash;
use Craft;
use craft\base\Model;
use craft\feedme\base\Element;
use craft\feedme\base\ElementInterface;
Expand Down Expand Up @@ -51,6 +52,11 @@ public function __toString()
return Craft::t('feed-me', $this->name);
}

public function getFeedUrl(): string
{
return Craft::parseEnv($this->feedUrl);
}

public function getDuplicateHandleFriendly()
{
return DuplicateHelper::getFrieldly($this->duplicateHandle);
Expand Down
4 changes: 2 additions & 2 deletions src/services/DataTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ public function getRawData($url, $feedId = null)

public function getFeedData($feedModel, $usePrimaryElement = true)
{
$feedDataResponse = $feedModel->getDataType()->getFeed($feedModel->feedUrl, $feedModel, $usePrimaryElement);
$feedDataResponse = $feedModel->getDataType()->getFeed($feedModel->getFeedUrl(), $feedModel, $usePrimaryElement);

$event = new FeedDataEvent([
'url' => $feedModel->feedUrl,
'url' => $feedModel->getFeedUrl(),
'response' => $feedDataResponse,
]);

Expand Down
4 changes: 3 additions & 1 deletion src/templates/feeds/_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@
required: true,
}) }}

{{ forms.textField({
{{ forms.autosuggestField({
label: "Feed URL" | t('feed-me'),
instructions: "Can be a file on the local file system or from a website url (http://...)." | t('feed-me'),
id: 'feedUrl',
name: 'feedUrl',
value: feed.feedUrl,
errors: feed.getErrors('feedUrl'),
required: true,
suggestEnvVars: true,
suggestAliases: true,
}) }}

{{ forms.selectField({
Expand Down
10 changes: 5 additions & 5 deletions src/templates/feeds/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@
<a href="{{ url('feed-me/feeds/' ~ feed.id) }}">{{ feed.name | t('feed-me') }}</a>

<span class="index-url">
{% if feed.feedUrl | length > 40 %}
{{ feed.feedUrl | slice(0, 40) }}&hellip;
{% if feed.getFeedUrl() | length > 40 %}
{{ feed.getFeedUrl() | slice(0, 40) }}&hellip;
{% else %}
{{ feed.feedUrl }}
{{ feed.getFeedUrl() }}
{% endif %}
</span>
</th>

<td>{{ feed.dataType.name ?? 'Unknown datatype' }}</td>

<td>
{% if feed.element %}
{{ feed.element.name }}
Expand All @@ -64,7 +64,7 @@
</td>

<td>{{ feed.duplicateHandleFriendly }}</td>

<td><a href="{{ url('feed-me/feeds/run/' ~ feed.id) }}">{{ 'Run Feed' | t('feed-me') }}</a></td>

<td class="thin action">
Expand Down