Skip to content

Commit

Permalink
Merge pull request #39 from nthmedia/master
Browse files Browse the repository at this point in the history
Enable env variable for username setting
  • Loading branch information
kringkaste authored Feb 16, 2021
2 parents ec37928 + cf8f599 commit bd4a386
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Instagram Feed Changelog

## Unreleased
### Added
- Enable environment variables for setting username

### Changed
- Fixed background color of icon
- Adding rel noopener and noreferrer properties to links (thanks to @JayBox325)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"require": {
"craftcms/cms": "^3.0.0",
"ext-json": "*",
"php": "7.0"
"php": "^7.0"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 7 additions & 0 deletions src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace codemonauts\instagramfeed\models;

use codemonauts\instagramfeed\InstagramFeed;
use Craft;
use craft\base\Model;

class Settings extends Model
Expand Down Expand Up @@ -54,4 +56,9 @@ public function rules()
[['userAgent', 'proxyKey'], 'string'],
];
}

public function getAccount()
{
return Craft::parseEnv(trim(InstagramFeed::getInstance()->getSettings()->instagramUser));
}
}
2 changes: 1 addition & 1 deletion src/services/InstagramService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class InstagramService extends Component
public function getFeed(string $accountOrTag = null): array
{
if ($accountOrTag === null) {
$accountOrTag = trim(InstagramFeed::getInstance()->getSettings()->instagramUser);
$accountOrTag = InstagramFeed::getInstance()->getSettings()->getAccount();
if (empty($accountOrTag)) {
Craft::warning('No Instagram account configured.', __METHOD__);

Expand Down
3 changes: 2 additions & 1 deletion src/templates/settings.twig
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{% import "_includes/forms" as forms %}

{{ forms.textField({
{{ forms.autosuggestField({
label: "Username"|t("instagramfeed"),
id: 'instagramUser',
name: 'instagramUser',
instructions: "Please, enter your Instagram username."|t("instagramfeed"),
value: settings.instagramUser,
suggestEnvVars: true,
type: 'text',
required: true
}) }}
Expand Down
2 changes: 1 addition & 1 deletion src/variables/InstagramFeedVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function getFeed($account = null)

public function getAccount()
{
return InstagramFeed::getInstance()->getSettings()->instagramUser;
return InstagramFeed::getInstance()->getSettings()->getAccount();
}
}

0 comments on commit bd4a386

Please sign in to comment.