-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.txt
79 lines (55 loc) · 2.71 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
-------------------------------------------------------------------------------
CDN OR LOCAL
load a ressource from CDNJS or from own domain (if it exist)
With this you can
- load a library from CDNJS or from your own domain (if it exist)
- an admin web gui can search libraries on CDNJS and download several
versions of it
I want to use it in my php apps to link cdnjs for smaller download size
and give the possibility to run without internet connection too.
And: I wanted to have a tool to check the versions of libraries I use.
Licence GPL 3.0
author: Axel Hahn
DOCS: https://www.axel-hahn.de/docs/cdnorlocal/index.htm
SOURCE: https://github.com/axelhahn/cdnorlocal
-------------------------------------------------------------------------------
USAGE:
(1) In your webapp - load css or js fromcdnjs
You only need the single file "cdnorlocal.class.php"
The structure of all libraries is
[name of the lib]/ [version] / [path+filename]
require_once('[PATH]/cdnorlocal.class.php');
$oCdn = new axelhahn\cdnorlocal();
echo $oCdn->getHtmlInclude("jquery/3.6.4/jquery.min.js")
It returns:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js" (...)></script>
(2) Include a non CSS or JS file ... or customize the <script> or <link> tag.
Use the method getFullUrl() to get the url only.
$oCdn = new axelhahn\cdnorlocal();
echo '<script src="'.$oCdn->getFullUrl("jquery/3.6.4/jquery.min.js").'" (...)></script>'
(3) In a webapp - load css or js fromcdnjs or own domain
It requires to have a local directory where the libraries are.
Default is the url "/vendor" and "[webroot]/vendor".
You need to initialize the class with that vendor directory and url if
it differs.
$oCdn = new axelhahn\cdnorlocal(array(
'vendordir' => __DIR__ . '/../vendor',
'vendorurl' => '../vendor'
));
(4) Admin webgui
In the develop environment open the admin in your browser
i.e. http://localhost/cdnorlocal/admin/
Remark:
On the public website you don't need the admin subdir or the cdnorlocal-admin.class.php
You only need the single file "cdnorlocal.class.php"
In the admin webgui you can
- search for a library on cdnjs and show details
- download a library to the local vendor directory (*)
- check if all the local versions are still up to date
Maybe you want to use it as tool for download and version check for external
libraries.
(*) The download is a file by file download and is quite inefficient. For more
than 100 files you get a warning below the download button.
It will work if you have javascript enaled but takes its time. If a
download aborts, you can continue downloading the missing files later.
-------------------------------------------------------------------------------