Git Product home page Git Product logo

f3-assets's People

Contributors

bigsiter avatar binarygeotech avatar ikkez avatar kumy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

f3-assets's Issues

Assets not compressed

Plugin works, but there is no output in "compressed" folder. My .ini.:

[ASSETS]
;# if this is false, you need to manually put the group markers like
;# <!-- assets-head --> and <!-- assets-footer --> into your template
auto_include = true

;# be greedy and also fetch all <link>, <script> and <style> tags
greedy = true

;# add some filters to the file type renderer
filter.js = minify,combine
filter.css = minify,combine

;# a writable public path, where filters can put files (relative to webroot)
public_path = compressed/

;# add the mtime to the final resource URI, to aid in asset caching
timestamps = true

And index.php

// Asset manager
$f3->config(__DIR__ . '/../app/config/assets.ini');
$assets = \Assets::instance();

// Execute application
$f3->run();

Download External Sources

This might be an odd edge case/work flow, but I'm throwing it out here:

I love using the combine feature of jsdelivr to quickly get a bundle of libs, that you would normally npm install etc.
like
https://cdn.jsdelivr.net/combine/npm/[email protected]/dist/jquery.min.js,npm/[email protected]/dist/js/bootstrap.bundle.min.js,npm/[email protected]/dist/vue.min.js,npm/[email protected]/moment.min.js

now I would consider this bad practice to have that in production, especially if you use jquery@latest and you load breaking changes without knowing or for privacy reasons.

So I wonder if it makes sense to have a switch in config (external = true|false), that would download the js as it is, rewrites the <script src=""> and serves it from local?

I guess you need also a switch in case you have to load external JS but it shouldn't be cached, so cache="true/false" sets that.

<F3:asset src="https://cdn.jsdelivr.net/file.js" priority="10" group="head" type="js" cache="true" />
<F3:asset src="https://google.com/analytics.js" priority="10" group="head" type="js" cache="false" />

Does that make sense?

Duplicate Include Handle

Does this plugin take care of multiple includes of the same files or does it just bundle them twice?

addInline

Es wäre sehr angenehm und konsequent, wenn diese Funktion noch den Parameter $Priority bekommt um die Reihenfolge der Ausgabe bzgl der JS/CSS-Dateien zu bestimmen.
Landet der Content aller addInline-Aufrufe nur in einem Script-Tag z.B. für Javascript/Styles?
(Für Javasript-Schnippsel würde mir ein Skript-Tag for "/body" reichen.)
Dazu steht leider nichts in der Dokumentation.
Ansonsten ist das Plugin wunderbar!

new feature

Ich wünsche mir den Integration der folgenden neue Methoden:

    /**
     * Registers a piece of CSS code.
     * @param string $content the CSS code
     * @param string $group
     */
    public function addCssCode($content,$group='head')
    {
        $this->addInline($content. "\n",'css',$group);
    }

    /**
     * Registers a piece of javascript code.
     * @param string $content the piece of JavaScript code
     * @param string $group
     */
    public function addJsCode($content,$group='footer')
    {
        $this->addInline($content  ."\n",'js',$group);
    }
}

Happy XMas & thanks for your work!

Having master assets not in public directory?

From what I've found, when the f3 UI variable starts with ../ (../app-ui/ in my case), the files are marked as internal, but they are not combined into one file and return non accessible paths.

Let's say I have some assets defined as:

$f3->set('UI', '../app-ui');
$assets->addCss('css/style1.css');
$assets->addCss('css/style2.css');

Actual result:

	<link rel="stylesheet" type="text/css" href="app-ui/css/style1.css"/>
	<link rel="stylesheet" type="text/css" href="app-ui/css/style2.css"/>

Expected result:

	<link rel="stylesheet" type="text/css" href="assets/compressed/26awg81rt5es8.css"/>

I can workaround the issue if I change:
https://github.com/ikkez/f3-assets/blob/master/lib/assets.php#L536

- 				$asset['path']=ltrim($view,'./');
+				$asset['path']=preg_replace('/^\.\//', '', $view,1);

and
https://github.com/bcosca/fatfree-core/blob/e2feb0110640e76e2b8ce704fe87aba1414c4f9e/web.php#L698-L700

 				if (is_file($save=$fw->fixslashes($dir.$file)) &&
-					is_bool(strpos($save,'../')) &&
 					preg_match('/\.(css|js)$/i',$file)) {

@ikkez Am I doing something wrong? Thanks.

Proposing any additional posibilities..

Hi @ikkez ,
This is a very great plugin!
I just want to proposing any possibility if you will for the next release..
Do you have any feature for single inline scripts or style block not to combine when greedy&handle_inline configs is set true?
Maybe your plugin have some ability to recognize specific attr in scripts or styles html like assets=exclude or combine=false so your plugin bypassing/leaving this inline scripts/styles for combining?

Regards,

No external www dir supported... help please

Hi,

I love the idea of your asset management class. However I'm not able to use it right now without your help. I've moved the public www folder from the app folder:

/app
/lib
/www

  • My templates are stored in /app/views/template ... this folder is not public accessible.
  • My Scripts are stored in /www/scripts ... this folder is public accessible.
  • My combined scripts should be stored in /www/scripts/combined ... also public accessible.

The f3 assets php class creates some *.css and *.js inside the /www/scripts/combined folder... but they are empty. It seems the class could not access the files in a path outside of the /app folder... If I move them inside the app folder, they files in combined are still empty (and I get the error:
filemtime(): stat failed for ********/www/scripts/test.js - line 291 )

Could you please help me to support external www folder?

Greetings

new attribut ?

"charset" sollte noch unterstützt werden... manche JQuery Plugins haben sonst Ärger mit ältern Browsern ohne Charset-Angabe bei I18n Files.

F3:asset src="plugin/slick/slick.js" charset="UTF-8"
führt zu...
script src="plugin/slick/slick.js" charset="UTF-8"></script

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.