Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Commit

Permalink
permettre de regler la visibilite par defaut des messages, et au cas …
Browse files Browse the repository at this point in the history
…par cas dans le formulaire pouetter() (mais pas sur chaque article)
  • Loading branch information
Cerdic committed Sep 20, 2017
1 parent 1cd0201 commit bb584c4
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 4 deletions.
16 changes: 16 additions & 0 deletions formulaires/configurer_mastodon.html
@@ -1,5 +1,6 @@
<!-- nom=microblog --> <!-- nom=microblog -->
#CACHE{0} #CACHE{0}
#SET{fl,mastodon}
<div class="formulaire_spip formulaire_editer formulaire_cfg"> <div class="formulaire_spip formulaire_editer formulaire_cfg">
<h3 class="titrem"><:mastodon:titre_configurer_mastodon_app:></h3> <h3 class="titrem"><:mastodon:titre_configurer_mastodon_app:></h3>
[<p class='reponse_formulaire reponse_formulaire_erreur'>(#ENV*{message_erreur})</p>] [<p class='reponse_formulaire reponse_formulaire_erreur'>(#ENV*{message_erreur})</p>]
Expand Down Expand Up @@ -67,6 +68,21 @@ <h3 class="titrem"><:mastodon:titre_configurer_mastodon_app:></h3>
<legend><:mastodon:notifications:></legend> <legend><:mastodon:notifications:></legend>
<p class="explication"><:mastodon:elements_signaler:></p> <p class="explication"><:mastodon:elements_signaler:></p>
<ul> <ul>
#SET{name,default_visibility}#SET{obli,''}#SET{defaut,#CONFIG{mastodon/default_visibility,public}}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
<li class="editer editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">
<label for="#GET{name}"><:mastodon:label_default_visibility:></label>[
<span class='erreur_message'>(#GET{erreurs})</span>
]<select name="#GET{name}" class="select" id="#GET{name}">
#SET{val,public}
<option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]>[(#GET{fl}|concat{':label_visibility','_',#GET{val}}|_T)]</option>
#SET{val,unlisted}
<option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]>[(#GET{fl}|concat{':label_visibility','_',#GET{val}}|_T)]</option>
#SET{val,private}
<option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]>[(#GET{fl}|concat{':label_visibility','_',#GET{val}}|_T)]</option>
#SET{val,direct}
<option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]>[(#GET{fl}|concat{':label_visibility','_',#GET{val}}|_T)]</option>
</select>
</li>
<li class="editer_notifications"> <li class="editer_notifications">
<label><:mastodon:notifications_publiques:></label> <label><:mastodon:notifications_publiques:></label>
<div> <div>
Expand Down
15 changes: 15 additions & 0 deletions formulaires/pouetter.html
Expand Up @@ -19,6 +19,21 @@
]<label for="#GET{name}">[(#GET{fl}|concat{':label_',#GET{name}}|_T)] <em>[(#ENV{_max_len}|moins{#ENV{status}|strlen})]</em></label> ]<label for="#GET{name}">[(#GET{fl}|concat{':label_',#GET{name}}|_T)] <em>[(#ENV{_max_len}|moins{#ENV{status}|strlen})]</em></label>
<textarea name="#GET{name}" id="#GET{name}" rows="10" cols="25">#ENV{status}</textarea> <textarea name="#GET{name}" id="#GET{name}" rows="10" cols="25">#ENV{status}</textarea>
</li> </li>
#SET{name,visibility}#SET{obli,''}#SET{defaut,#CONFIG{mastodon/default_visibility,public}}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
<li class="editer editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">
<label for="#GET{name}">[(#GET{fl}|concat{':label_',#GET{name}}|_T)]</label>[
<span class='erreur_message'>(#GET{erreurs})</span>
]<select name="#GET{name}" class="select" id="#GET{name}">
#SET{val,public}
<option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]>[(#GET{fl}|concat{':label_',#GET{name},'_',#GET{val}}|_T)]</option>
#SET{val,unlisted}
<option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]>[(#GET{fl}|concat{':label_',#GET{name},'_',#GET{val}}|_T)]</option>
#SET{val,private}
<option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]>[(#GET{fl}|concat{':label_',#GET{name},'_',#GET{val}}|_T)]</option>
#SET{val,direct}
<option value="#GET{val}"[(#ENV{#GET{name},#GET{defaut}}|=={#GET{val}}|oui)selected="selected"]>[(#GET{fl}|concat{':label_',#GET{name},'_',#GET{val}}|_T)]</option>
</select>
</li>
</ul> </ul>
[(#REM) ajouter les saisies supplementaires : extra et autre, a cet endroit ] [(#REM) ajouter les saisies supplementaires : extra et autre, a cet endroit ]
<!--extra--> <!--extra-->
Expand Down
7 changes: 6 additions & 1 deletion formulaires/pouetter.php
Expand Up @@ -19,6 +19,7 @@ function formulaires_pouetter_charger_dist(){
$valeurs = $valeurs =
array( array(
'status' => '', 'status' => '',
'visibility' => '',
'_max_len' => 500, '_max_len' => 500,
); );
include_spip("inc/mastodon"); include_spip("inc/mastodon");
Expand Down Expand Up @@ -62,7 +63,11 @@ function formulaires_pouetter_traiter_dist(){


if ($status = _request('status')){ if ($status = _request('status')){
include_spip('inc/mastodon'); include_spip('inc/mastodon');
$retour = pouet($status); $options = array();
if ($visibility = _request('visibility')) {
$options['visibility'] = $visibility;
}
$retour = pouet($status, $options);


if($retour and isset($retour['id']) and $retour['id']){ if($retour and isset($retour['id']) and $retour['id']){
if (isset($retour['content'])) { if (isset($retour['content'])) {
Expand Down
6 changes: 5 additions & 1 deletion inc/mastodon.php
Expand Up @@ -167,9 +167,13 @@ function pouet($status, $options = array()){
$default_options = array( $default_options = array(
'user_name' => '', 'user_name' => '',
'max_len' => 500, 'max_len' => 500,
'visibility' => 'public', 'visibility' => lire_config('mastodon/default_visibility','public'),
); );
$options = array_merge($default_options, $options); $options = array_merge($default_options, $options);
// si option visibilite foireuse, on met unlisted (pour pas trop polluer)
if (!in_array($options['visibility'], array('public','unlisted','private','direct'))) {
$options['visibility'] = 'unlisted';
}


// si pas d'api utilisable on sort // si pas d'api utilisable on sort
if (!$user = mastodon_oauth_user_token($options['user_name']) if (!$user = mastodon_oauth_user_token($options['user_name'])
Expand Down
8 changes: 7 additions & 1 deletion lang/mastodon_en.php
Expand Up @@ -34,11 +34,17 @@


// L // L
'label_associer_compte_mastodon' => 'Link your mastodon account to this site', 'label_associer_compte_mastodon' => 'Link your mastodon account to this site',
'label_aucun_compte_mastodon' => 'Aucun compte Mastodon enregistré.', 'label_aucun_compte_mastodon' => 'Aucun compte Mastodon enregistré.',
'label_default_visibility' => 'Default visibility',
'label_dissocier_compte_mastodon' => 'Delete this account', 'label_dissocier_compte_mastodon' => 'Delete this account',
'label_status' => 'What\'s in your mind ?', 'label_status' => 'What\'s in your mind ?',
'label_pouet'=> 'Edit the toot', 'label_pouet'=> 'Edit the toot',
'label_username' => 'User name', 'label_username' => 'User name',
'label_visibility' => 'Visibility',
'label_visibility_public' => 'Public (post to public timelines)',
'label_visibility_unlisted' => 'Unlisted (do not post to public timelines)',
'label_visibility_private' => 'Followers-only (post to followers only)',
'label_visibility_direct' => 'Direct (post to mentioned users only)',
'legend_api_mastodon' => 'Mastodon Application', 'legend_api_mastodon' => 'Mastodon Application',
'legend_comptes_mastodon' => 'Mastodon Accounts', 'legend_comptes_mastodon' => 'Mastodon Accounts',
'lien_documentation' => 'View documentation', 'lien_documentation' => 'View documentation',
Expand Down
6 changes: 6 additions & 0 deletions lang/mastodon_fr.php
Expand Up @@ -35,11 +35,17 @@
// L // L
'label_associer_compte_mastodon' => 'Ajouter un compte', 'label_associer_compte_mastodon' => 'Ajouter un compte',
'label_aucun_compte_mastodon' => 'Aucun compte Mastodon enregistré.', 'label_aucun_compte_mastodon' => 'Aucun compte Mastodon enregistré.',
'label_default_visibility' => 'Visibilité par défaut',
'label_dissocier_compte_mastodon' => 'Supprimer ce compte', 'label_dissocier_compte_mastodon' => 'Supprimer ce compte',
'label_host_ajouter' => 'Instance Mastodon', 'label_host_ajouter' => 'Instance Mastodon',
'label_status' => 'Qu\'avez-vous en tête ?', 'label_status' => 'Qu\'avez-vous en tête ?',
'label_pouet'=> 'Modifier le pouet', 'label_pouet'=> 'Modifier le pouet',
'label_username' => 'Nom d\'utilisateur', 'label_username' => 'Nom d\'utilisateur',
'label_visibility' => 'Visibilité',
'label_visibility_public' => 'Public (afficher dans les fils publics)',
'label_visibility_unlisted' => 'Non listé (ne pas afficher dans les fils publics)',
'label_visibility_private' => 'Privé (n\'afficher que pour vos abonné•e•s)',
'label_visibility_direct' => 'Direct (n\'afficher que pour les personnes mentionnées)',
'legend_api_mastodon' => 'Application Mastodon', 'legend_api_mastodon' => 'Application Mastodon',
'legend_comptes_mastodon' => 'Comptes Mastodon', 'legend_comptes_mastodon' => 'Comptes Mastodon',
'lien_documentation' => 'Cf. documentation', 'lien_documentation' => 'Cf. documentation',
Expand Down
2 changes: 1 addition & 1 deletion paquet.xml
@@ -1,7 +1,7 @@
<paquet <paquet
prefix="mastodon" prefix="mastodon"
categorie="communication" categorie="communication"
version="1.0.0" version="1.1.0"
etat="test" etat="test"
compatibilite="[3.0.0;3.2.*]" compatibilite="[3.0.0;3.2.*]"
schema="1.0.0" schema="1.0.0"
Expand Down

0 comments on commit bb584c4

Please sign in to comment.