-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from localgovdrupal/62/rename-social-post-module
renames social post module
- Loading branch information
Showing
13 changed files
with
570 additions
and
2 deletions.
There are no files selected for viewing
6 changes: 4 additions & 2 deletions
6
.../localgov_election_reporting_social_post/localgov_election_reporting_social_post.info.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
modules/localgov_elections_reporting_social_post/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# LocalGov Elections Reporting Social Post Integration | ||
|
||
This module provides an integration with the Drupal module [Social API](https://www.drupal.org/project/social_api). We | ||
have provided a Twitter posting integration which you can use to post to Twitter once you have finalised the votes for | ||
an area. | ||
|
||
At present, we only support Twitter. You are free to add your own integrations with social API if that doesn't work for | ||
you. We may add further integrations down the line but that is not planned at present. | ||
|
||
See the [documentation](../../docs/index.md) for details on how to use this when running an election. | ||
|
||
## Configuration | ||
|
||
1. You will need to obtain and API key and secret for Twitter/X and enter them at `/admin/config/social-api/social-post/twitter`. Twitter/X provide details on how to do this at https://developer.twitter.com/en/docs/authentication/oauth-1-0a/api-key-and-secret. | ||
2. You then need to link each user who will be posting to Twitter/X from the site to a Twitter account. | ||
3. Each user needs to login and visit their profile and click 'Add account' in the '`'Social Post Twitter' section. | ||
4. This will take you to a Twitter/X screen to authorise access to the account. | ||
5. Once authorised you will be taken back to the user profile showing the account listed. | ||
|
||
## Default Tweet | ||
|
||
You can edit the default tweet at `/admin/config/elections/social-post-integration/settings` |
1 change: 1 addition & 0 deletions
1
...eporting_social_post/config/install/localgov_elections_reporting_social_post.settings.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
message_template: 'Candidate [node:field_winning_candidate:entity:field_candidate_forenames] [node:field_winning_candidate:entity:field_candidate] won for the [node:field_winning_candidate:entity:field_party] party with [node:field_winning_candidate:entity:field_votes] votes in [node:field_area_name:value]!' |
8 changes: 8 additions & 0 deletions
8
...s_reporting_social_post/config/schema/localgov_elections_reporting_social_post.schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Schema for the configuration files of the Election Social Integration module. | ||
localgov_elections_reporting_social_post.settings: | ||
type: config_object | ||
label: 'Election Social Integration settings' | ||
mapping: | ||
message_template: | ||
type: string | ||
label: 'Message template' |
11 changes: 11 additions & 0 deletions
11
...ocalgov_elections_reporting_social_post/localgov_elections_reporting_social_post.info.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: LocalGov Election Reporting Social Post Integration | ||
description: Social API integration | ||
type: module | ||
package: Localgov Drupal | ||
core_version_requirement: ^9 || ^10 | ||
|
||
dependencies: | ||
- drupal:localgov_elections_reporting | ||
- drupal:social_post | ||
- drupal:social_post_twitter | ||
- drupal:token |
17 changes: 17 additions & 0 deletions
17
...localgov_elections_reporting_social_post/localgov_elections_reporting_social_post.install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* LocalGov Election Reporting Social Post install file. | ||
*/ | ||
|
||
/** | ||
* Implements hook_install(). | ||
*/ | ||
function localgov_elections_reporting_social_post_install() { | ||
// Check if localgov_election_reporting_social_post module is installed. | ||
// If so, uninstall it, so we can use this module instead. | ||
if (\Drupal::moduleHandler()->moduleExists('localgov_election_reporting_social_post')) { | ||
\Drupal::service('module_installer')->uninstall(['localgov_election_reporting_social_post']); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...v_elections_reporting_social_post/localgov_elections_reporting_social_post.links.menu.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
localgov_elections_reporting_social_post.settings: | ||
title: Election Social Integration Settings | ||
parent: social_api.admin_config | ||
route_name: localgov_elections_reporting_social_post.settings | ||
weight: 10 |
36 changes: 36 additions & 0 deletions
36
.../localgov_elections_reporting_social_post/localgov_elections_reporting_social_post.module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* LocalGov Election Reporting Social Post module file. | ||
*/ | ||
|
||
use Drupal\Core\Form\FormStateInterface; | ||
use Drupal\Core\Url; | ||
|
||
/** | ||
* Implements hook_form_BASE_FORM_ID_alter(). | ||
*/ | ||
function localgov_elections_reporting_social_post_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) { | ||
$node = $form_state->getFormObject()->getEntity(); | ||
if ($node->bundle() == "division_vote") { | ||
$form['actions']['save_and_add_areas'] = $form['actions']['submit']; | ||
$form['actions']['save_and_add_areas']['#value'] = t("Save and Tweet"); | ||
$form['actions']['save_and_add_areas']['#submit'][] = "localgov_elections_reporting_social_post_save_and_tweet"; | ||
$form['actions']['save_and_add_areas']['#weight'] = 100; | ||
} | ||
} | ||
|
||
/** | ||
* Save and tweet submit function callback. | ||
*/ | ||
function localgov_elections_reporting_social_post_save_and_tweet($form, FormStateInterface $form_state) { | ||
\Drupal::request()->query->remove('destination'); | ||
if ($node = $form_state->getFormObject()->getEntity()) { | ||
if ($id = $node?->id()) { | ||
$form_state->setRedirectUrl(Url::fromRoute('localgov_elections_reporting_social_post.area_vote_social_post', | ||
['node' => $id]) | ||
); | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
..._elections_reporting_social_post/localgov_elections_reporting_social_post.permissions.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
can access election social posting: | ||
title: 'Can access election social posting' |
21 changes: 21 additions & 0 deletions
21
...lgov_elections_reporting_social_post/localgov_elections_reporting_social_post.routing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
localgov_elections_reporting_social_post.area_vote_social_post: | ||
path: '/node/{node}/social-post' | ||
defaults: | ||
_title: 'Area Vote Social Post' | ||
_form: 'Drupal\localgov_elections_reporting_social_post\Form\AreaVoteSocialPostForm' | ||
requirements: | ||
_permission: 'can access election social posting' | ||
node: \d+ | ||
options: | ||
_node_operation_route: TRUE | ||
parameters: | ||
node: | ||
type: entity:node | ||
|
||
localgov_elections_reporting_social_post.settings: | ||
path: '/admin/config/elections/social-post-integration/settings' | ||
defaults: | ||
_title: 'Settings' | ||
_form: 'Drupal\localgov_elections_reporting_social_post\Form\SettingsForm' | ||
requirements: | ||
_permission: 'administer site configuration' |
11 changes: 11 additions & 0 deletions
11
...les/localgov_elections_reporting_social_post/localgov_elections_reporting_social_post.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: LocalGov Elections Reporting Social Post Integration | ||
description: Social API integration | ||
type: module | ||
package: LocalGov Drupal | ||
core_version_requirement: ^9 || ^10 | ||
|
||
dependencies: | ||
- localgov_elections_reporting:localgov_elections_reporting | ||
- social_post:social_post | ||
- social_post_twitter:social_post_twitter | ||
- drupal:token |
Oops, something went wrong.