Analytical continuum mechanics à  la Hamilton-Piola least action principle for second gradient continua and capillary fluids