Re: [Feature Suggestion] FileLibrary that serves from disk (A mix of WAFileMetadataFileLibrary and WAExternalFileLibrary)
Jupiter Jones <[email protected]> Mon, 6 May 2024 00:19:26 +1000
| Newsgroups | gmane.comp.lang.smalltalk.squeak.seaside |
|---|---|
| Message-ID | <[email protected]> |
--===============3174069859467711639== Content-Type: multipart/alternative; boundary="Apple-Mail=_21C437EA-5E37-4351-81CD-7201BA45C8C7" --Apple-Mail=_21C437EA-5E37-4351-81CD-7201BA45C8C7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi Johan, Thanks for the reply. That=E2=80=99s a good solution, and a rework of WAExternalFileLibrary to = add automatic serving of files like WAFileLibrary, and using Zinc to = serve them would be absolutely ideal :) One of the things I like about FileLibrary is inheritance and = overriding. I provide a framework with a FileLibrary, and users can = subclass that FileLibrary and extend or override with their own = resources. It=E2=80=99s really nice to be able to apply some OO = principles to assets like that. It would be nice for that to work with WAExternalFileLibrary too. Ie. If = a subclass doesn=E2=80=99t have the file in its directory, walk up = through the supers to see if the file exists in their corresponding = directories. That was my thinking with the Metadata. It lets developers = see what=E2=80=99s available without searching through files, and = creates a formal interface for overrides. Metadata might also form the = basis of a GToolkit view of file libraries. As an aside, it would also be cool to be able to specify files in the = form of=E2=80=A6 MyExternalFileLibrary / =E2=80=98images/icons/groovyIcon.png=E2=80=99 =E2=80=A6as well as=E2=80=A6 MyExternalFileLibrary / #=E2=80=99imagesiconsgroovyiconPng' This is just thinking out loud, and you may have better thought out = ideas on the best way to achieve this kind of workflow. Cheers, JJ > On 5 May 2024, at 11:09=E2=80=AFPM, Johan Brichau <[email protected]> = wrote: >=20 > Hi Jupiter, >=20 > Maybe not what you are looking for (since it=E2=80=99s also similar to = WAExternalFileLibrary). >=20 > 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. >=20 > 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: >=20 > updateRoot: aRoot > ... > aRoot javascript resourceUrl: =E2=80=98/js/commons.bundle.js'. > =E2=80=A6 >=20 > 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): >=20 > WAAdmin defaultServerManager adaptors first defaultDelegate = serveFilesFrom: =E2=80=98<MyProjectRepo>=E2=80=99. >=20 > 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 >=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). >=20 > Johan >=20 >=20 >> 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] >=20 > _______________________________________________ > seaside mailing list -- [email protected] > To unsubscribe send an email to = [email protected] --Apple-Mail=_21C437EA-5E37-4351-81CD-7201BA45C8C7 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 = Johan,<div><br></div><div>Thanks for the = reply.</div><div><br></div><div>That=E2=80=99s a good solution, and a = rework of WAExternalFileLibrary to add automatic serving of files like = WAFileLibrary, and using Zinc to serve them would be absolutely ideal = :)</div><div><br></div><div>One of the things I like about FileLibrary = is inheritance and overriding. I provide a framework with a FileLibrary, = and users can subclass that FileLibrary and extend or override with = their own resources. It=E2=80=99s really nice to be able to apply some = OO principles to assets like that.</div><div><br></div><div>It would be = nice for that to work with WAExternalFileLibrary too. Ie. If a subclass = doesn=E2=80=99t have the file in its directory, walk up through the = supers to see if the file exists in their corresponding directories. = That was my thinking with the Metadata. It lets developers see what=E2=80=99= s available without searching through files, and creates a formal = interface for overrides. Metadata might also form the basis of a = GToolkit view of file libraries.</div><div><br></div><div>As an aside, = it would also be cool to be able to specify files in the form = of=E2=80=A6</div><div><br></div><div>MyExternalFileLibrary / = =E2=80=98images/icons/groovyIcon.png=E2=80=99</div><div>=E2=80=A6as well = as=E2=80=A6</div><div>MyExternalFileLibrary / = #=E2=80=99imagesiconsgroovyiconPng'<br = id=3D"lineBreakAtBeginningOfMessage"><div><br></div><div>This is just = thinking out loud, and you may have better thought out ideas on the best = way to achieve this kind of = workflow.</div><div><br></div><div>Cheers,</div><div><br></div><div>JJ</di= v><div><br><blockquote type=3D"cite"><div>On 5 May 2024, at 11:09=E2=80=AF= PM, Johan Brichau <[email protected]> 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;">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 `<MyProjectRepo>/resources/js` folder, so I configure the = ZnZincStaticServerAdaptor adaptor to use that location on disk to serve = files from. </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<MyProjectRepo>=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 (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. </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 = <[email protected]> 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><MyProjectRepo>/web_root/files/= MyFileLibrary</div><div> </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 <span style=3D"caret-color: = rgb(0, 0, 0);">WAFileMetadataLibrary</span> 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> 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></div>_______________________________________________<br>seasid= e mailing list -- [email protected]<br>To unsubscribe = send an email to = [email protected]<br></div></blockquote></div><br><= /div></body></html>= --Apple-Mail=_21C437EA-5E37-4351-81CD-7201BA45C8C7-- --===============3174069859467711639== 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] --===============3174069859467711639==--