ajout de tous les snippets dans un seul repo + lien doc visual

This commit is contained in:
Christophe 2019-06-14 10:56:47 +02:00
parent e7688aa700
commit dcf70808ff
7 changed files with 428 additions and 1 deletions

View file

@ -1 +1,3 @@
#Snippets SPIP pour vscodium
#Snippets SPIP pour vscodium
https://code.visualstudio.com/docs/editor/userdefinedsnippets

49
package.json Normal file
View file

@ -0,0 +1,49 @@
{
"name": "spip-html",
"displayName": "SPIP codes for html (snippets)",
"description": "Just snippet for create SPIP codes in html",
"version": "0.0.1",
"publisher": "gamuza",
"engines": {
"vscode": "^1.0.0"
},
"categories": [
"Snippets"
],
"contributes": {
"snippets": [
{
"language": "html",
"path": "./snippets/spip-html.json"
},
{
"language": "scss",
"path": "./snippets/spip-scss.json"
},
{
"language": "css",
"path": "./snippets/spip-scss.json"
},
{
"language": "js",
"path": "./snippets/spip-js.json"
},
{
"language": "html",
"path": "./snippets/spip-js.json"
},
{
"language": "xml",
"path": "./snippets/spip-xml.json"
},
{
"language": "php",
"path": "./snippets/spip-php.json"
}
]
},
"repository": {
"type": "git",
"url": "https://git.gamuza.fr/snippet/vscodium"
}
}

210
snippets/spip-html.json Normal file
View file

@ -0,0 +1,210 @@
{
"b": {
"prefix": "b",
"body": [
"<BOUCLE_${1:nom}(${2/(.*)/${1:/upcase}/g}){${3:critere}}${4}>",
"$0",
"</BOUCLE_$1>"
],
"description": "SPIP <BOUCLE_>"
},
"bb": {
"prefix": "bb",
"body": [
"<B_$1>",
"${5}",
"<BOUCLE_${1:nom}(${2/(.*)/${1:/upcase}/g}){${3:critere}}${4}>",
"$0",
"</BOUCLE_$1>",
"${6}",
"</B_$1>"
],
"description": "SPIP <B_>"
},
"id_rub": {
"prefix": "id_rub",
"body": "#ID_RUBRIQUE${0}",
"description": "SPIP #ID_RUBRIQUE"
},
"id_mot": {
"prefix": "id_mot",
"body": "#ID_MOT",
"description": "SPIP #ID_MOT"
},
"http_header": {
"prefix": "http_header",
"body": "#HTTP_HEADER{Content-Type: text/plain; charset=#CHARSET}",
"description": "SPIP #HTTP_HEADER{}"
},
"autoriser": {
"prefix": "autoriser",
"body": "[(#AUTORISER{${1:action},${2:objet}}|oui)${3}]",
"description": "SPIP [(#AUTORISER{"
},
"rem": {
"prefix": "rem",
"body": "[(#REM)\n\t1\n]\n${0}"
},
"edit": {
"prefix": "edit",
"body": "#EDIT{1}${0}",
"description": "SPIP #EDIT{ VISUAL }"
},
"env**": {
"prefix": "env**",
"body": "[<pre>(#ENV**|unserialize|print_r{1})</pre>]\n${0}",
"description": "SPIP tout l'env"
},
"env": {
"prefix": "env",
"body": "#ENV{${1}}${0}",
"description": "SPIP #ENV{}"
},
"set": {
"prefix": "set",
"body": "#SET{${1},$2}${0}",
"description": "SPIP #SET{}"
},
"get": {
"prefix": "get",
"body": "#GET{${1}}${0}",
"description": "SPIP #GET{}"
},
"chemin": {
"prefix": "chemin",
"body": "[(#CHEMIN{${1}})]${0}",
"description": "SPIP #CHEMIN{}"
},
"cache": {
"prefix": "cache",
"body": "#CACHE{0}\n${0}",
"description": "SPIP #CACHE{0}"
},
"url_page": {
"prefix": "url_page",
"body": "[(#URL_PAGE{1}${0})]",
"description": "SPIP #URL_PAGE{}"
},
"action": {
"prefix": "action",
"body": "[(#URL_ACTION_AUTEUR{${1:name},${2:var1/var2},${3:#SELF}})]${0}",
"description": "SPIP #URL_ACTION_AUTEUR{name,var1/var2,#SELF}"
},
"foreachSpip": {
"prefix": "foreachSpip",
"body": "[(${1}|foreach)]\n${0}",
"description": "SPIP foreach"
},
"config": {
"prefix": "config",
"body": "#CONFIG{${1}}${0}",
"description": "SPIP #CONFIG{}"
},
"setenv": {
"prefix": "setenv",
"body": "[(#${1:balise}|setenv{${2:nom_env}})]${0}",
"description": "SPIP [(#BALISE|setenv{nom_env})]"
},
"formulaire": {
"prefix": "formulaire",
"body": "`!p t[1] = t[1].upper()`\n[(#FORMULAIRE_${1}{${2}})]${0}",
"description": "SPIP #FORMULAIRE_"
},
"use": {
"prefix": "use",
"body": "<svg class=\"${2:$1}\" width=\"${3}\" height=\"${4}\" alt=\"${5}\">\n\t${6:<title></title>}\n\t<use xlink:href=\"#${1:${VISUAL:id}}\" />\n</svg>",
"description": "SPIP SVG use"
},
"cptboucle": {
"prefix": "cptboucle",
"body": "#COMPTEUR_BOUCLE${0}",
"description": "SPIP #COMPTEUR_BOUCLE"
},
"totboucle": {
"prefix": "totboucle",
"body": "#TOTAL_BOUCLE${0}",
"description": "SPIP #TOTAL_BOUCLE"
},
"cvt": {
"prefix": "cvt",
"body": "<div class=\"formulaire_spip formulaire_#FORM\">\n\n[<p class=\"reponse_formulaire reponse_formulaire_erreur\">(#ENV*{message_erreur})</p>]\n[<p class=\"reponse_formulaire reponse_formulaire_ok\">(#ENV*{message_ok})</p>]\n\n[(#ENV{editable}|oui) ]\n\t<form name=\"formulaire_#FORM\" action=\"#ENV{action}\" method=\"post\"><div>\n\t\t#ACTION_FORMULAIRE{#ENV{action}}\n\t\t<div class=\"editer_groupe\">\n\n\t\t\t${1}\n\n\t\t</div>\n\t<p class=\"boutons\"><input type=\"submit\" class=\"submit\" value=\"Envoyer\" ></p>\n\t</div></form>\n\n</div>",
"description": "SPIP formulaire CVT"
},
"cvttext": {
"prefix": "cvttext",
"body": "<div class=\"editer_groupe\">\n\t#SET{name,${1}}\n\t#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}\n\t#SET{obli,\"obligatoire\"}\n\t<div class=\"editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]\">\n\t\t<label for=\"#GET{name}\">${2}</label>\n\t\t[<span class=\"erreur_message\">(#GET{erreurs})</span>]\n\t\t<input type=\"text\" class=\"text ${3:$1}\" name=\"#GET{name}\" id=\"#GET{name}\" value=\"#ENV{#GET{name}}\" >\n\t</div>\n</div>\n${0}",
"description": "SPIP <input type='text'"
},
"cvttextarea": {
"prefix": "cvttextarea",
"body": "<div class=\"editer_groupe\">\n\t#SET{name,${1}}\n\t#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}\n\t#SET{obli,\"obligatoire\"}\n\t<div class=\"editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]\">\n\t\t<label for=\"#GET{name}\">${2}</label>\n\t\t[<span class=\"erreur_message\">(#GET{erreurs})</span>]\n\t\t<textarea class=\"textarea ${3:$1}\" name=\"#GET{name}\" id=\"#GET{name}\">#ENV{#GET{name}}</textarea>\n\t</div>\n</div>\n${0}",
"description": "SPIP <textarea ...> "
},
"cvtcheckbox": {
"prefix": "cvtcheckbox",
"body": "<div class=\"editer_groupe\">\n\t#SET{name,${1}}\n\t#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}\n\t#SET{obli,\"obligatoire\"}\n\t<div class=\"editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]\">\n\t\t<div class=\"choix\">\n\t\t\t<input type=\"checkbox\" class=\"checkbox\" name=\"#GET{name}[]\" id=\"#GET{name}_1\"[ (#GET{name}|in_array{#ENV{#GET{name}}}|oui) checked=\"checked\"})] >\n\t\t\t<label for=\"#GET{name}_1\">${2}</label>\n\t\t</div>\n\t</div>\n</div>\n${0}",
"description": "SPIP <input type='checkbox'>"
},
"cvtradio": {
"prefix": "cvtradio",
"body": "<div class=\"editer_groupe\">\n\t#SET{name,${1}}\n\t#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}\n\t#SET{obli,\"obligatoire\"}\n\t<div class=\"editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]\">\n\t\t<div class=\"choix\">\n\t\t\t<input type=\"radio\" class=\"radio\" name=\"#GET{name}\" value=\"non\" id=\"#GET{name}_non\"[ (#ENV{#GET{name}}|=={non}|?{checked=\"checked\"})] >\n\t\t\t<label for=\"#GET{name}_non\">${2}</label>\n\t\t</div>\n\t\t<div class=\"choix\">\n\t\t\t<input type=\"radio\" class=\"radio\" name=\"#GET{name}\" value=\"oui\" id=\"#GET{name}_oui\"[ (#ENV{#GET{name}}|=={oui}|?{checked=\"checked\"})] >\n\t\t\t<label for=\"#GET{name}_oui\">${3}</label>\n\t\t</div>\n\t</div>\n</div>\n${0}",
"description": "SPIP <input type='radio'>"
},
"cvtselect": {
"prefix": "cvtselect",
"body": "<div class=\"editer_groupe\">\n\t#SET{name,${1}}\n\t#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}\n\t#SET{obli,\"obligatoire\"}\n\t<div class=\"editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]\">\n\t\t<label for=\"#GET{name}\">${2}</label>\n\t\t<select id=\"#GET{name}\" name=\"#GET{name}\" class=\"#GET{name}\">\n\t\t\t<option value=\"${3}\">${4}</option>\n\t\t\t${0}\n\t\t</select>\n\t</div>\n</div>",
"description": "SPIP <select>"
},
"saisie": {
"prefix": "saisie",
"body": "[(#SAISIE{${1:type},${2:nom}}\n\t{label=\"${3}\"}\n\t${0}\n)]",
"description": "SPIP #SAISIE{}"
},
"saisiedata": {
"prefix": "saisiedata",
"body": "[(#SAISIE{${1:type},${2:nom}}\n\t{label=\"${3}\"}\n\t{defaut=${4}}\n\t{datas=${5}}\n)]\n${0}",
"description": "SPIP #SAISIE{datas}"
},
"br": {
"prefix": "br",
"body": "<br>\n${0}",
"description": "<br>"
},
"hr": {
"prefix": "hr",
"body": "<hr>\n${0}",
"description": "<hr>"
},
"nbs": {
"prefix": "nbs",
"body": "&nbsp;${0}",
"description": "&nbs;"
},
"html": {
"prefix": "html",
"body": "<html>\n\n${0}\n\n</html>",
"description": "<html>"
},
"script": {
"prefix": "script",
"body": "<script type=\"text/javascript\">\n\n\t${0}\n\n</script>"
},
"scriptsrc": {
"prefix": "scriptsrc",
"body": "<script src=\"[(#CHEMIN{${1}})]\" type=\"text/javascript\"></script>\n${0}"
},
"style": {
"prefix": "style",
"body": "<style type=\"text/css\" media=\"${1:screen}\">\n\t${2}\n</style>"
},
"confirm": {
"prefix": "confirm",
"body": "onClick=\"return confirm('${1:Confirmer cette action}');\"",
"description": "Onclick='ruturn confirm'"
},
"action_url": {
"prefix": "action_url",
"body": "var url_${1:nom} = \"[(#VAL{$1}|generer_url_action{\"\", 1})]\";\n${0}",
"description": "SPIP url => action spip"
}
}

5
snippets/spip-js.json Normal file
View file

@ -0,0 +1,5 @@
snippet necessite "SPIP <necessite ...>"
<necessite nom="${1}" compatibilite="[${2};[" />
${0}
endsnippet

153
snippets/spip-php.json Normal file
View file

@ -0,0 +1,153 @@
{
"bigint": {
"prefix": "bigint",
"body": "'bigint(${1:21}) NOT NULL',${0}",
"description": "SQL bigint(21)"
},
"float": {
"prefix": "float",
"body": "'float NOT NULL',${0}",
"description": "SQL float"
},
"tinyint": {
"prefix": "tinyint",
"body": "'tinyint(4) NOT NULL',${0}",
"description": "SQL tinyint(4)"
},
"decimal": {
"prefix": "decimal",
"body": "'decimal(10,2) DEFAULT \"0\" NOT NULL',${0}",
"description": "SQL decimal(10,2)"
},
"text": {
"prefix": "text",
"body": "'text NOT NULL DEFAULT \"\"',${0}",
"description": "SQL text NOT NULL"
},
"varchar": {
"prefix": "varchar",
"body": "'varchar(${1:255}) NOT NULL DEFAULT \"\"',${0}",
"description": "SQL varchar(25)"
},
"datetime": {
"prefix": "datetime",
"body": "'datetime NOT NULL DEFAULT \"0000-00-00 00:00:00\"',${0}",
"description": "SQL datetime"
},
"php": {
"prefix": "php",
"body": "<?php\n\n${0}"
},
"php2": {
"prefix": "php2",
"body": "<?php\nif (!defined('_ECRIRE_INC_VERSION')) return;\n\n\n${0}",
"description": "SPIP php"
},
"testauto": {
"prefix": "testauto",
"body": "include_spip('inc/autoriser');\nif (! autoriser(\"${1:action}\",\"${2:objet}\")) {\n\treturn false;\n}\n${0}",
"description": "SPIP"
},
"id_auteur_session": {
"prefix": "id_auteur_session",
"body": "$GLOBALS['visiteur_session']['id_auteur']${0}",
"description": "$GLOBALS['visiteur_session']['id_auteur']"
},
"cvt": {
"prefix": "cvt",
"body": "<?php\nif (!defined('_ECRIRE_INC_VERSION')) return;\n\nfunction formulaires_${TM_FILENAME_BASE}_charger_dist($${1:variables}){\n\t$valeurs = array(\n\t\t\"${2:nom_du_champ}\" => ${3:\"\"},\n\t);\n\t${0}\n\treturn $valeurs;\n}\n\nfunction formulaires_${TM_FILENAME_BASE}_verifier_dist($$1){\n\t$$2 = _request('$2');\n\n\t$erreurs = array();\n\t//champs obligatoire\n\tforeach (array ('$2') as $obligatoire) {\n\t\tif (!_request($obligatoire)) $erreurs[$obligatoire] = 'Ce champs est obligatoire';\n\t}\n\n\t//autres erreurs\n\t$erreurs['$2'] = \"Ce champ ne convient pas.\";\n\n\t//Il y a des erreurs\n\tif (count($erreurs)) {\n\t\t$erreurs['message_erreur'] = 'Votre saisie contient des erreurs !';\n\t}\n\n\treturn $erreurs;\n}\n\nfunction formulaires_${TM_FILENAME_BASE}_traiter_dist($$1){\n\t$$2 = _request('$2');\n\n\t$retour = array();\n\t$retour['message_ok'] = \"bravo\";\n\t$retour['redirect'] = \"spip.php?page=perdu\";\n\t$retour['editable'] = true;\n\n\treturn $retour;\n}",
"description": "SPIP"
},
"action2": {
"prefix": "action2",
"body": "<?php\nif (!defined('_ECRIRE_INC_VERSION')) return;\n\nfunction action_${TM_FILENAME_BASE}_dist($arg=null){\n\n\tif (is_null($arg)) {\n\t\t// DEMI sécurité : s'il y a un hash, on teste la sécurité\n\t\tif (_request('hash')) {\n\t\t\t$securiser_action = charger_fonction('securiser_action', 'inc');\n\t\t\t$arg = $securiser_action();\n\t\t}\n\t\t// Sinon, on prend l'arg direct\n\t\telse {\n\t\t\t$arg = _request('arg');\n\t\t}\n\t}\n\t$${1:var} = $arg;\n\t${0}\n\n\t// on renvoit le test en variable js\n\t$js = \"var $1=$$1;\";\n\theader('Content-Type: text/javascript; charset=' . $GLOBALS['meta']['charset']);\n\techo $js;\n}",
"description": "SPIP action ajax à la mano"
},
"action": {
"prefix": "action",
"body": "<?php\nif (!defined('_ECRIRE_INC_VERSION')) return;\n\nfunction action_${TM_FILENAME_BASE}_dist(){\n\t$securiser_action = charger_fonction('securiser_action', 'inc');\n\t$arg = $securiser_action();\n\t$$1 = $arg;\n\tlist($${1:var1},$${2:var2}) = preg_split(',[^0-9],',$arg);\n\t${0}\n\n\t// Cache\n\tinclude_spip('inc/invalideur');\n\tsuivre_invalideur(\"id='$1/$$1'\");\n\n\t// redirection sur la création d'un rapport\n\t//$retour = \"spip.php?page=\";\n\t//include_spip('inc/headers');\n\t//redirige_par_entete($retour);\n}",
"description": "SPIP action declenchee dans un lien"
},
"date_php": {
"prefix": "date_php",
"body": "date(\"Y-m-d H:i:s\")${0}",
"description": "SPIP date('Y-m-d H:i:s')"
},
"api_objet": {
"prefix": "api_objet",
"body": "// utilisation API editer_objet pour l'insertion en BDD'\n// http://www.spip.net/fr_article5526.html\ninclude_spip('action/editer_objet');\n$objet = \"${1:article}\";\n\n$set = array (\n\t'${1:champs1}' => $${2:valeur_champs1},\n\t'${3:champs2}' => $${4:valeur_champs2},\n);\n$id_objet = objet_inserer($objet, $id_parent);\n//ou $id_objet=$ma_variable;\n\nobjet_modifier($objet, $id_objet, $set);",
"description": "SPIP API Objet"
},
"api_lien": {
"prefix": "api_lien",
"body": "// utilisation API editier_liens\n// http://www.spip.net/fr_article5477.html\ninclude_spip('action/editer_liens');\n\n$objets_source = array(\"${1:auteur}\"=>${2:id_auteur ou array});\n$objets_lies = array(\"${3:article}\"=>${:id_article ou array});\n${0}\n\nobjet_associer($objets_source, $objets_lies);",
"description": "SPIP API Lien"
},
"cache": {
"prefix": "cache",
"body": "include_spip('inc/invalideur');\nsuivre_invalideur(\"id='${1:id_objet}/1'\");\n${0}",
"description": "SPIP invalide cache"
},
"req": {
"prefix": "req",
"body": "_request('${1}')${0}",
"description": "SPIP _request()"
},
"array": {
"prefix": "array",
"body": "array(\n\t'${1}' => ${2},${0}\n\t);",
"description": "SPIP Array( X lignes)"
},
"array_ligne": {
"prefix": "array_ligne",
"body": "'${1:var}' => $$1,${0}",
"description": "SPIP Une ligne d'array"
},
"vd": {
"prefix": "vd",
"body": "var_dump($${1:var});\n${0}",
"description": "var_dump()"
},
"ec": {
"prefix": "ec",
"body": "echo ${1};\n${0}",
"description": "Echo"
},
"pre": {
"prefix": "pre",
"body": "echo \"<pre>\";\n\tprint_r($${1});\necho \"</pre>\";\n${0}",
"description": "<pre> print_r"
},
"include": {
"prefix": "include",
"body": "include_spip('${1:fichier}');\n${0}",
"description": "SPIP include_spip"
},
"pipeline": {
"prefix": "pipeline",
"body": "/**\n * Charger des styles CSS\n *\n * @pipeline insert_head_css\n * @param string $flux Code html des styles CSS à charger\n * @return string Code html complété\n **/\nfunction ${1:prefix}_insert_head_css($flux){\n\t$flux .= '<link rel=\"stylesheet\" href=\"' . produire_fond_statique('css/vignettes.css') . '\" type=\"text/css\" />' . \"\\n\";\n\t$flux .= '<link rel=\"stylesheet\" href=\"' . timestamp(find_in_path('css/bigup.css')) . '\" type=\"text/css\" />' . \"\\n\";\n\treturn $flux;\n}\n${0}\n/**\n * Charger des scripts jquery\n *\n * @pipeline jqueryui_plugins\n * @param array $scripts Liste à charger\n * @return array Liste complétée\n **/\nfunction $1_jquery_plugins($scripts){\n\t$scripts[] = \"aa\";\n\t$scripts[] = produire_fond_statique('javascript/bigup.js');\n\treturn $scripts;\n}\n\n/**\n * Charger des scripts jquery ui\n *\n * @pipeline jqueryui_plugins\n * @param array $scripts Liste à charger\n * @return array Liste complétée\n **/\nfunction $1_jqueryui_plugins($scripts){\n\t$scripts[] = \"aa\";\n\treturn $scripts;\n}",
"description": "SPIP Les pipelines de base"
},
"debugspip": {
"prefix": "debugspip",
"body": "function debug_spip(){\n\tdefine('_DEBUG_SLOW_QUERIES', true);\n\tdefine('_BOUCLE_PROFILER', 5000);\n\tdefine('_LOG_FILTRE_GRAVITE', 8);\n\tdefine('_LOG_FILELINE',true);\n\tdefine('_DEBUG_AUTORISER', true);\n\tdefine('_MAX_LOG', 500000);\n\n\terror_reporting(E_ALL^E_NOTICE);\n\tini_set (\"display_errors\", \"On\");\n\tini_set(\"html_errors\", \"On\");\n\tini_set(\"allow_url_fopen\", \"On\");\n\tdefine('SPIP_ERREUR_REPORT',E_ALL^E_NOTICE);\n\tdefine('SPIP_ERREUR_REPORT_INCLUDE_PLUGINS',E_ALL^E_NOTICE);\n\n\n\tdefine('_NO_CACHE', -1);\n\tdefine('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);\n}\n\nif ( $_SERVER['SERVER_ADDR'] === \"127.0.0.1\") {\n\tdebug_spip();\n}\n\nif ( substr($_SERVER['SERVER_ADDR'],0,7) === \"192.168\") {\n\tdebug_spip();\n}",
"description": "SPIP define de debug"
},
"/*": {
"prefix": "/*",
"body": "/**\n * ${0}\n **/"
},
"doc": {
"prefix": "doc",
"body": "/**\n * ${1:function non documente}\n *\n * @param ${2}\n * @return ${0}\n * @author tofulm\n **/"
},
"fdoc": {
"prefix": "fdoc",
"body": "/**\n * ${4:fonction non documente}\n *\n * @param ${5}\n * @return ${3}\n * @author tofulm\n **/\nfunction ${1}(${2}){\n\t${6}\n }"
},
"spip_log": {
"prefix": "spip_log",
"body": "spip_log(${1},${2:\"gamuza\"});\n${0}",
"description": "SPIP fctn spip_log()"
}
}

1
snippets/spip-scss.json Normal file
View file

@ -0,0 +1 @@
{}

7
snippets/spip-xml.json Normal file
View file

@ -0,0 +1,7 @@
{
"necessite": {
"prefix": "necessite",
"body": "<necessite nom=\"${1}\" compatibilite=\"[${2};[\" />\n${0}",
"description": "SPIP <necessite ...>"
}
}