Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
[Added] Added Wikipedia to the Social Media settings & sameAs entit…
Browse files Browse the repository at this point in the history
…y information
  • Loading branch information
Andrew Welch committed Feb 12, 2017
1 parent a6318e1 commit 83a7372
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [Improved] Moved the lattitude/longitude info down below the address information for on the Site Identity & Site Creator settings
* [Improved] Wrapped all `templates->render()` calls in try/catch blocks to more gracefully handle errors
* [Added] Added an `Anonymize IP` toggle for Google Analytics, for compliance with some local laws
* [Added] Added Wikipedia to the Social Media settings & `sameAs` entity information

## 1.1.41 -- 2017.02.10

Expand Down
2 changes: 1 addition & 1 deletion SeomaticPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getVersion()

public function getSchemaVersion()
{
return '1.1.24';
return '1.1.25';
}

public function getDeveloper()
Expand Down
1 change: 1 addition & 0 deletions controllers/SeomaticController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,7 @@ public function actionSaveSocial()
$record->pinterestHandle = craft()->request->getPost('pinterestHandle', $record->pinterestHandle);
$record->githubHandle = craft()->request->getPost('githubHandle', $record->githubHandle);
$record->vimeoHandle = craft()->request->getPost('vimeoHandle', $record->vimeoHandle);
$record->wikipediaUrl = craft()->request->getPost('wikipediaUrl', $record->wikipediaUrl);

if ($record->save())
{
Expand Down
58 changes: 58 additions & 0 deletions migrations/m170212_000000_seomatic_addWikipedia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
namespace Craft;

/**
* The class name is the UTC timestamp in the format of mYYMMDD_HHMMSS_pluginHandle_migrationName
*/
class m170212_000000_seomatic_addWikipedia extends BaseMigration
{
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
// specify columns and AttributeType
$newColumns = array (
'wikipediaUrl' => ColumnType::Varchar
);

$this->_addColumnsAfter("seomatic_settings", $newColumns, "vimeoHandle");
$this->alterColumn('seomatic_settings', 'wikipediaUrl', array(ColumnType::Varchar, 'maxLength' => 100));

// return true and let craft know its done
return true;
}

private function _addColumnsAfter($tableName, $newColumns, $afterColumnHandle)
{

// this is a foreach loop, enough said
foreach ($newColumns as $columnName => $columnType)
{
// check if the column does NOT exist
if (!craft()->db->columnExists($tableName, $columnName))
{
$this->addColumnAfter($tableName, $columnName, array(
'column' => $columnType,
'null' => false,
),
$afterColumnHandle
);

// log that we created the new column
SeomaticPlugin::log("Created the `$columnName` in the `$tableName` table.", LogLevel::Info, true);

}

// if the column already exists in the table
else {

// tell craft that we couldn't create the column as it alredy exists.
SeomaticPlugin::log("Column `$columnName` already exists in the `$tableName` table.", LogLevel::Info, true);

}
}
}
}
1 change: 1 addition & 0 deletions models/Seomatic_SettingsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ protected function defineAttributes()
'pinterestHandle' => array(AttributeType::String, 'default' => ''),
'githubHandle' => array(AttributeType::String, 'default' => ''),
'vimeoHandle' => array(AttributeType::String, 'default' => ''),
'wikipediaUrl' => array(AttributeType::String, 'default' => ''),

/* --------------------------------------------------------------------------------
CEATOR settings
Expand Down
1 change: 1 addition & 0 deletions records/Seomatic_SettingsRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ protected function defineAttributes()
'pinterestHandle' => array(AttributeType::String, 'maxLength' => 50, 'default' => ''),
'githubHandle' => array(AttributeType::String, 'maxLength' => 50, 'default' => ''),
'vimeoHandle' => array(AttributeType::String, 'maxLength' => 50, 'default' => ''),
'wikipediaUrl' => array(AttributeType::String, 'maxLength' => 100, 'default' => ''),


/* --------------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"[Fixed] Fixed a regression that could cause FieldTypes to not save properly",
"[Improved] Moved the lattitude/longitude info down below the address information for on the Site Identity & Site Creator settings",
"[Improved] Wrapped all `templates->render()` calls in try/catch blocks to more gracefully handle errors",
"[Added] Added an `Anonymize IP` toggle for Google Analytics, for compliance with some local laws"
"[Added] Added an `Anonymize IP` toggle for Google Analytics, for compliance with some local laws",
"[Added] Added Wikipedia to the Social Media settings & `sameAs` entity information"
]
},
{
Expand Down
9 changes: 9 additions & 0 deletions services/SeomaticService.php
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ public function setSocialForMeta(&$meta, $siteMeta, $social, $helper, $identity,
array_push($sameAs, $helper['pinterestUrl']);
array_push($sameAs, $helper['githubUrl']);
array_push($sameAs, $helper['vimeoUrl']);
array_push($sameAs, $helper['wikipediaUrl']);
$sameAs = array_filter($sameAs);
$sameAs = array_values($sameAs);
if (!empty($sameAs))
Expand Down Expand Up @@ -1638,6 +1639,7 @@ public function getIdentityJSONLD($identity, $helper, $locale)
array_push($sameAs, $helper['pinterestUrl']);
array_push($sameAs, $helper['githubUrl']);
array_push($sameAs, $helper['vimeoUrl']);
array_push($sameAs, $helper['wikipediaUrl']);
$sameAs = array_filter($sameAs);
$sameAs = array_values($sameAs);
if (!empty($sameAs))
Expand Down Expand Up @@ -1828,6 +1830,7 @@ public function getSocial($locale)
$social['pinterestHandle'] = $settings['pinterestHandle'];
$social['githubHandle'] = $settings['githubHandle'];
$social['vimeoHandle'] = $settings['vimeoHandle'];
$social['wikipediaUrl'] = $settings['wikipediaUrl'];

$result = $social;

Expand Down Expand Up @@ -2736,6 +2739,12 @@ private function addSocialHelpers(&$helper, $social, $identity)
}
else
$helper['vimeoUrl'] = '';
if ($social['wikipediaUrl'])
{
$helper['wikipediaUrl'] = $social['wikipediaUrl'];
}
else
$helper['wikipediaUrl'] = '';
} /* -- addSocialHelpers */

/* --------------------------------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions templates/social/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@
locale: social.locale,
}) }}

{{ forms.textField({
label: "Wikipedia URL"|t,
instructions: ("The full URL to the Wikipedia.com entry that is about this entity. <a href='http://searchengineland.com/leveraging-wikidata-gain-google-knowledge-graph-result-219706' target='_blank'>Learn More</a>") |t |raw,
id: "wikipediaUrl",
class: 'nicetext',
name: "wikipediaUrl",
value: social.wikipediaUrl,
required: false,
locale: social.locale,
}) }}

{{ forms.textField({
label: "LinkedIn Handle"|t,
instructions: ("Your LinkedIn page handle (the part after <code>https://www.linkedin.com/in/</code> or <code>https://www.linkedin.com/company/</code>)") |t |raw,
Expand Down

0 comments on commit 83a7372

Please sign in to comment.