
Recherche avancée
Autres articles (51)
-
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...) -
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)
Sur d’autres sites (6956)
-
How to add new pages and menu items to Piwik – Introducing the Piwik Platform
11 septembre 2014, par Thomas Steur — DevelopmentThis is the next post of our blog series where we introduce the capabilities of the Piwik platform (our previous post was How to create a widget). This time you’ll learn how to extend Piwik by adding new pages and menu items. For this tutorial you will need to have basic knowledge of PHP and optionally of Twig which is the template engine we use.
What can be displayed in a page ?
To make it short : You can display any corporate related content, key metrics, news, help pages, custom reports, contact details, information about your server, forms to manage any data and anything else.
Getting started
In this series of posts, we assume that you have already set up your development environment. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik.
To summarize the things you have to do to get setup :
- Install Piwik (for instance via git).
- Activate the developer mode :
./console development:enable --full
. - Generate a plugin :
./console generate:plugin --name="MyControllerPlugin"
. There should now be a folderplugins/MyControllerPlugin
. - And activate the created plugin under Settings => Plugins.
Let’s start creating a page
We start by using the Piwik Console to create a new page :
./console generate:controller
The command will ask you to enter the name of the plugin the controller should belong to. I will simply use the above chosen plugin name “MyControllerPlugin”. There should now be two files
plugins/MyControllerPlugin/Controller.php
andplugins/MyControllerPlugin/templates/index.twig
which both already contain an example to get you started easily :Controller.php
- class Controller extends \Piwik\Plugin\Controller
- {
- public function index()
- {
- 'answerToLife' => 42
- ));
- }
- }
and templates/index.twig
- {% extends 'dashboard.twig' %}
- {% block content %}
- <strong>Hello world!</strong>
- <br/>
- The answer to life is {{ answerToLife }}
- {% endblock %}
Note : If you are generating the Controller before Piwik 2.7.0 the example will look slightly different.
The controller action
index
assigns the view variableanswerToLife
to the view and renders the Twig templatetemplates/index.twig
. Any variable assigned this way can then be used in the view using for example{{ answerToLife }}
.Using a Twig template to generate the content of your page is actually optional : instead feel free to generate any content as desired and return a string in your controller action.
As the above template
index.twig
is extending the dashboard template the Logo as well as the top menu will automatically appear on top of your content which is defined within the blockcontent
.How to display the page within the admin
If you would like to add the admin menu on the left you have to modify the following parts :
- Extend
\Piwik\Plugin\ControllerAdmin
instead of\Piwik\Plugin\Controller
in the fileController.php
. In a future version of Piwik this step will be no longer neccessary, see #6151 - Extend the template
admin.twig
instead ofdashboard.twig
- Define a headline using an H2-element
- {% extends 'admin.twig' %}
- {% block content %}
- <h2>Hello world!</h2>
- <br/>
- The answer to life is {{ answerToLife }}
- {% endblock %}
Note : Often one needs to add a page to the admin to make a plugin configurable. We have a unified solution for this using the Settings API.
How to display a blank page
If you would like to generate a blank page that shows only your content the template should contain only your markup as follows :
- <strong>Hello world!</strong>
- <br/>
- The answer to life is {{ answerToLife }}
Predefined variables, UI components, security and accessing query parameters
In this blog post we only cover the basics to get you started. We highly recommend to read the MVC guide on our developer pages which covers some of those advanced topics. For instance you might be wondering how to securely access
$_GET
or$_POST
parameters, you might want to restrict the content of your page depending on a user role, and much more.If you would like to know how to make use of JavaScript, CSS and Less have a look at our Working with Piwik’s UI guide.
Note : How to include existing UI components such as a site selector or a date selector will be covered in a future blog post. Also, there are default variables assigned to the view depending on the context. A list of those variables that may or may not be defined is unfortunately not available yet but we will catch up on this.
Let’s add a menu item to make the page accessible
So far you have created a page but you can still not access it. Therefore we need to add a menu item to one of the Piwik menus. We start by using the Piwik Console to create a menu template :
./console generate:menu
The command will ask you to enter the name of the plugin the menu should belong to. I will use again the above chosen plugin name “MyControllerPlugin”. There should now be a file
plugins/MyControllerPlugin/Menu.php
which contains an example to get you started easily :Menu.php
- class Menu extends \Piwik\Plugin\Menu
- {
- public function configureUserMenu(MenuUser $menu)
- {
- // reuse an existing category.
- $menu->addManageItem('My User Item', $this->urlForAction('showList'));
- // or create a custom category
- $menu->addItem('My Custom Category', 'My User Item', $this->urlForDefaultAction());
- }
- }
This is only a part of the generated template since all the examples of the different menus are similar. You can add items to four menus :
configureReportingMenu
To add a new item to the reporting menu which includes all the reports like “Actions” and “Visitors”.configureAdminMenu
To add a new item to the admin menu which includes items like “User settings” and “Websites”.configureTopMenu
To add a new item to the top menu which includes items like “All Websites” and “Logout”.configureUserMenu
To add a new item to the user menu which is accessible when clicking on the username on the top right.
In this blog post we will add a new item to the user menu and to do so we adjust the generated template like this :
- class Menu extends \Piwik\Plugin\Menu
- {
- public function configureUserMenu(MenuUser $menu)
- {
- $menu->addManageItem('My User Item', $this->urlForAction($method = 'index'), $orderId = 30);
- }
- }
That’s it. This will add a menu item named “My User Item” to the “Manage” section of the user menu. When a user chooses the menu item, the “index” method of your controller will be executed and your previously created page will be first rendered and then displayed. Optionally, you can define an order to influence the position of the menu item within the manage section. Following this example you can add an item to any menu for any action. I think you get the point !
Note : In Piwik 2.6.0 and before the above example would look like this :
- class Menu extends \Piwik\Plugin\Menu
- {
- public function configureUserMenu(MenuUser $menu)
- {
- $menu->addManageItem('My User Item', array($module = 'MyControllerPlugin', $action = 'index'), $orderId = 30);
- }
- }
How to test a page
After you have created your page you are surely wondering how to test it. A controller should be usually very simple as it is only the connector between model and view. Therefore, we do usually not create unit or integration test for controllers and for the view less than ever. Instead we would create a UI test that takes a screenshot of your page and compares it with an expected screenshot. Luckily, there is already a section UI tests in our Automated tests guide.
Publishing your Plugin on the Marketplace
In case you want to share your page with other Piwik users you can do this by pushing your plugin to a public GitHub repository and creating a tag. Easy as that. Read more about how to distribute a plugin.
Advanced features
Isn’t it easy to create a page ? We never even created a file ! Of course, based on our API design principle “The complexity of our API should never exceed the complexity of your use case.” you can accomplish more if you want : You can make use of Vanilla JavaScript, jQuery, AngularJS, Less and CSS, you can reuse UI components, you can access query parameters and much more.
Would you like to know more about this ? Go to our MVC (Model-View-Controller) and Working with Piwik’s UI guides in the Piwik Developer Zone.
If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.
-
Nomenclature #4626 (Nouveau) : Renommer le menu "Squelettes"
13 janvier 2021, par RastaPopoulos ♥Un petit pavé en début d’année, comme ça peut-être qu’en décembre on aura un début d’idée de quoi faire. :D
Constat : dans mon expérience, 100% des gens à qui on apprend à utiliser éditorialement SPIP, admins et rédacs donc, n’ont strictement aucune fichue idée de ce que veut dire "Suqelettes", ni quel est le rapport avec le contenu qu’il y a à l’intérieur. Passer du temps à devoir expliquer un terme qui n’aura jamais aucun sens dans leurs activités quotidiennes est une perte de temps pour tout le monde, et 3 mois plus tard illes l’auront oublié vu que ça n’a de rapport avec rien dans leur vie d’admins/rédacs.
Le fait de faire une référence à l’histoire technique de SPIP, ça ne parle qu’aux devs/intégrateurices : fort peu de gens par rapport à la masse des admins et rédacs qui vont l’utiliser au quotidien.
Quand on se retire, en tant que devs/ingégrateurices, alors en gros 99% des utilisateurices de l’interface d’admin sont des gens qui ne savent rien du tout de comment c’est techniquement derrière, et même pour beaucoup qui n’ont jamais choisi spécialement ce CMS, et même allons plus loin : assez souvent qui ne savent même pas quel est le CMS utilisé !
Et point important : ces gens ne devraient avoir aucune obligation de le savoir pour utiliser pourtant comme il faut l’interface.
Si on leur apprend, parce que nous on aime SPIP et qu’on est enthousiaste à raconter son histoire et comment il marche, c’est super. Mais ça ne doit PAS être une obligation pour comprendre l’interface du premier coup.
Mon idée (toute relative, c’est pour démarrer quoi) : revenir à des choses simples et couramment utilisées. Il n’y a aucun intérêt spécial à vouloir être original quand on parle quand même du menu principal d’admin.
Le fait de changer l’intitulé, va forcément changer légèrement le sens, donc quelques plugins qui s’insèrent dedans devront possiblement être déplacés ailleurs. Mais il me semble que ça restera très à la marge, et que la majorité ça correspond toujours. Ça ne doit pas bloquer pour changer. Donc :
- Mise en page
- Présentation
- …Dans WP il y a une entrée principale "Apparence", mais ce n’est justement pas notre cas : il faut un terme plus large, qui couvre à la fois les choix graphiques (changer ou configurer un thème, choisir la boite modale…) et les choix de structuration générale, de navigation (Compositions, Menus…).
Dans ma tête "Mise en page" est pour le moment le terme le plus vaste qui me vient à l’esprit, et qui regroupe plusieurs notions à la fois, pas juste l’apparence graphique. S’il y a mieux tant mieux, du moment que ça regroupe bien ces différentes notions. L’autre jour sur spip-dev Laurent (c-real) disait surcharger avec ce terme aussi pour ses utilisateurices.
On ne trouvera sûrement jamais le mot parfait à 100%, mais ça sera toujours 1000 fois mieux que "Squelettes" qui vraiment, après 10 ans à devoir l’expliquer en permanence, ne signifie rien pour personne à part nous.
-
Batch file to add separate audio file to MP4 file [closed]
30 janvier 2021, par MrRosoI have a couple of video files (MP4) with audio in France.
Video1.mp4, Video2.mp4, Video3.mp4, ……
In the same directory, I have the same couple of audio files in English (m4a).
Audio1.m4a, Audio2.m4a, Audio3.m4a, ……


The command


ffmpeg -i "Video1.mp4" -i "Audio1m4a" -map 0 -map 1:a -c copy "Out.mp4"



to add the audio file to the Video file works fine, but I need to do this for each video and audio file manually.


I want to do this in a batch file, like this :


@Echo off
for %%i in (*.MP4) %%j in (*.m4a) do ffmpeg -i "%%i" -i "%%j" -map 0 -map 1:a -codec copy "/new/%%~nI.mp4"



But I get the follow error message :
"% j" cannot be processed syntactically at this point.


Also the new batch file ends in an error :


@Echo off
for /F tokens=i,j %%i in (*.MP4) %%j in (*.m4a) do ffmpeg -i "%%i" -i "%%j" -map 0 -map 1:a -codec copy "/new/%%~nI.mp4"



Error Message :
"i" cannot be processed syntactically at this point.


Has someone a batch file for me, which is working ?


Best regards