Re: [Feature Suggestion] FileLibrary that serves from disk (A mix of WAFileMetadataFileLibrary and WAExternalFileLibrary)

Johan Brichau <[email protected]> Sun, 5 May 2024 15:09:57 +0200
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <[email protected]>
--===============0997176695293919761==
Content-Type: multipart/alternative;
	boundary="Apple-Mail=_5C49E493-FDFD-428E-9951-D044FD69F0A4"


--Apple-Mail=_5C49E493-FDFD-428E-9951-D044FD69F0A4
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

Hi Jupiter,

Maybe not what you are looking for (since it=E2=80=99s also similar to =
WAExternalFileLibrary).

In Pharo, there is also the ability to serve all the files from disk =
through the Zinc server, instead of serving the files from a =
WAFileLibrary method.
The ZnZincStaticServerAdaptor tries to resolve all paths that Seaside =
does not resolve by =E2=80=9Cresolving" them on disk.

Then, use the `resourceUrl` application setting to set the root path for =
all external resources and use the `resourceUrl:` method to designate a =
specific external resource.
For example, my application has the `resourceUrl` setting set to =
=E2=80=98resources=E2=80=99. In my Seaside code, I then use =
`resourceUrl:` to point to a specific file:

updateRoot: aRoot
	...
	aRoot javascript resourceUrl: =E2=80=98/js/commons.bundle.js'.
	=E2=80=A6

This means Seaside will generate a script header with its src attribute =
set to `/resources/js/commons.bundle.js`.
On disk, that file is in `<MyProjectRepo>/resources/js` folder, so I =
configure the ZnZincStaticServerAdaptor adaptor to use that location on =
disk to serve files from.=20
E.g. (Assuming you have only one adaptor and it=E2=80=99s a =
ZnZincStaticServerAdaptor instance):

WAAdmin defaultServerManager adaptors first defaultDelegate =
serveFilesFrom: =E2=80=98<MyProjectRepo>=E2=80=99.

In production, I have an nginx server matching all paths that begin with =
=E2=80=98resources=E2=80=99  (i.e. the =E2=80=98resourceUrl=E2=80=99 =
setting value) to be served directly from disk.
For me, that means all code works identically in production and =
development, with Zinc doing the file serving in development and Nginx =
in production.=20

Obviously, this works almost identical to the `WAExternalFileLibrary`. =
It does not have a the functionality of adding a WAFileLibrary to your =
project and have Seaside include the javascript and css per default.
Which makes me think if we should actually rework WAExternalFileLibrary =
to do just that (and possibly make it use the ZnZincStaticServerAdaptor =
to serve the files instead).

Johan


> On 5 May 2024, at 07:10, Jupiter Jones <[email protected]> wrote:
>=20
> My project repo has a directory structure that includes...
>=20
> <MyProjectRepo>/web_root/files/MyFileLibrary
> =20
> =E2=80=A6 that stores all the files (images / scripts / etc) that are =
used in my Seaside app.
>=20
> In production, the web server serves files from the web_root directory =
so all the WAFileMetadataLibrary urls (ie. /files/MyFileLibrary/*) work =
as expected.
>=20
> In development, my subclasses of WAFileMetadataLibrary serve files =
from the seaside file library handler...
>=20
> /files/MyFileLibrary
>=20
> This all works perfectly, since the developers don=E2=80=99t have a =
web server so need to get all files via the image, and both development =
and production urls are the same. It=E2=80=99s an ideal solution for web =
apps without a lot of assets.
>=20
> The biggest issue is that as our applications grow, all the files are =
on disk, are also in the image, and also end up in the source directory =
in a single text document MyFileLibrary.class.st =
<http://myfilelibrary.class.st/> which ends up huge, slow, and should be =
unnecessary.
>=20
> Ideally, in development, it would be nice to have a FileLibrary that =
works identically to a WAFileMetadataLibrary (ie. stores meta data and =
generates url's), except it doesn=E2=80=99t store the file contents in =
the image. Rather it streams them from disk via zinc when requested.
>=20
> I know there=E2=80=99s a WAExternalFileLibrary, however, AFAIK it =
can=E2=80=99t be served via /files/MyExternalFileLibrary, and doesn=E2=80=99=
t take advantage of the close integration of an application and its file =
libraries. Ie. myApplication addLibrary: MyFileLibrary.
>=20
> So the question=E2=80=A6 does anyone have anything like this? Or is =
there anyone else with growing applications that would rather not have =
multiple copies of all your web application assets, including a copy =
inside the image?
>=20
> Any thoughts?
>=20
> Cheers,
>=20
> Jupiter
> _______________________________________________
> seaside mailing list -- [email protected]
> To unsubscribe send an email to =
[email protected]


--Apple-Mail=_5C49E493-FDFD-428E-9951-D044FD69F0A4
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"overflow-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;">Hi =
Jupiter,<div><br></div><div>Maybe not what you are looking for (since =
it=E2=80=99s also similar to =
WAExternalFileLibrary).<br><div><br></div><div>In Pharo, there is also =
the ability to serve all the files from disk through the Zinc server, =
instead of serving the files from a WAFileLibrary method.</div><div>The =
ZnZincStaticServerAdaptor tries to resolve all paths that Seaside does =
not resolve by =E2=80=9Cresolving" them on =
disk.</div><div><br></div><div>Then, use the `resourceUrl` application =
setting to set the root path for all external resources and use the =
`resourceUrl:` method to designate a specific external =
resource.</div><div>For example, my application has the `resourceUrl` =
setting set to =E2=80=98resources=E2=80=99. In my Seaside code, I then =
use `resourceUrl:` to point to a specific =
file:</div><div><br></div><div>updateRoot: aRoot</div><div><span =
class=3D"Apple-tab-span" style=3D"white-space:pre">	=
</span>...</div><div><span class=3D"Apple-tab-span" =
style=3D"white-space:pre">	</span>aRoot javascript resourceUrl: =
=E2=80=98/js/commons.bundle.js'.</div><div><span class=3D"Apple-tab-span" =
style=3D"white-space:pre">	</span>=E2=80=A6</div><div><br></div><div>=
This means Seaside will generate a script header with its src attribute =
set to `/resources/js/commons.bundle.js`.</div><div>On disk, that file =
is in `&lt;MyProjectRepo&gt;/resources/js` folder, so I configure the =
ZnZincStaticServerAdaptor adaptor to use that location on disk to serve =
files from.&nbsp;</div><div>E.g. (Assuming you have only one adaptor and =
it=E2=80=99s a ZnZincStaticServerAdaptor =
instance):</div><div><br></div><div>WAAdmin defaultServerManager =
adaptors first defaultDelegate serveFilesFrom: =
=E2=80=98&lt;MyProjectRepo&gt;=E2=80=99.</div><div><br></div><div>In =
production, I have an nginx server matching all paths that begin with =
=E2=80=98resources=E2=80=99 &nbsp;(i.e. the =E2=80=98resourceUrl=E2=80=99 =
setting value) to be served directly from disk.</div><div>For me, that =
means all code works identically in production and development, with =
Zinc doing the file serving in development and Nginx in =
production.&nbsp;</div><div><br></div><div>Obviously, this works almost =
identical to the `WAExternalFileLibrary`. It does not have a the =
functionality of adding a WAFileLibrary to your project and have Seaside =
include the javascript and css per default.</div><div>Which makes me =
think if we should actually rework WAExternalFileLibrary to do just that =
(and possibly make it use the ZnZincStaticServerAdaptor to serve the =
files =
instead).</div><div><br></div><div>Johan</div><div><br></div><div><div><br=
><blockquote type=3D"cite"><div>On 5 May 2024, at 07:10, Jupiter Jones =
&lt;[email protected]&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><div><meta http-equiv=3D"content-type"=
 content=3D"text/html; charset=3Dutf-8"><div style=3D"overflow-wrap: =
break-word; -webkit-nbsp-mode: space; line-break: =
after-white-space;"><div>My project repo has a directory structure that =
includes...</div><div><br></div><div>&lt;MyProjectRepo&gt;/web_root/files/=
MyFileLibrary</div><div>&nbsp;</div><div>=E2=80=A6 that stores all the =
files (images / scripts / etc) that are used in my Seaside =
app.</div><div><br></div><div>In production, the web server serves files =
from the web_root directory so all the&nbsp;<span style=3D"caret-color: =
rgb(0, 0, 0);">WAFileMetadataLibrary</span>&nbsp;urls (ie. =
/files/MyFileLibrary/*) work as expected.</div><div><br></div>In =
development, my subclasses of WAFileMetadataLibrary serve files from the =
seaside file library =
handler...<div><br></div><div>/files/MyFileLibrary</div><div><br></div><di=
v>This all works perfectly, since the developers don=E2=80=99t have a =
web server so need to get all files via the image, and both development =
and production urls are the same. It=E2=80=99s an ideal solution for web =
apps without a lot of assets.</div><div><br></div><div>The biggest issue =
is that as our applications grow, all the files are on disk, are also in =
the image, and also end up in the source directory in a single text =
document <a =
href=3D"http://myfilelibrary.class.st/">MyFileLibrary.class.st</a>&nbsp;wh=
ich ends up huge, slow, and should be =
unnecessary.</div><div><br></div><div>Ideally, in development, it would =
be nice to have a FileLibrary that works identically to a =
WAFileMetadataLibrary (ie. stores meta data and generates url's), except =
it doesn=E2=80=99t store the file contents in the image. Rather it =
streams them from disk via zinc when =
requested.</div><div><br></div><div>I know there=E2=80=99s a =
WAExternalFileLibrary, however, AFAIK it can=E2=80=99t be served via =
/files/MyExternalFileLibrary, and doesn=E2=80=99t take advantage of the =
close integration of an application and its file libraries. Ie. =
myApplication addLibrary: MyFileLibrary.</div><div><br></div><div>So the =
question=E2=80=A6 does anyone have anything like this? Or is there =
anyone else with growing applications that would rather not have =
multiple copies of all your web application assets, including a copy =
inside the image?</div><div><br></div><div>Any =
thoughts?</div><div><br></div><div>Cheers,</div><div><br></div><div>Jupite=
r</div></div>_______________________________________________<br>seaside =
mailing list -- [email protected]<br>To unsubscribe =
send an email to =
[email protected]<br></div></blockquote></div><br><=
/div></div></body></html>=

--Apple-Mail=_5C49E493-FDFD-428E-9951-D044FD69F0A4--

--===============0997176695293919761==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
seaside mailing list -- [email protected]
To unsubscribe send an email to [email protected]

--===============0997176695293919761==--