Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consult page context when resolving asset references #1

Open
WardCunningham opened this issue Mar 9, 2018 · 6 comments
Open

consult page context when resolving asset references #1

WardCunningham opened this issue Mar 9, 2018 · 6 comments

Comments

@WardCunningham
Copy link
Member

This Frame says its subject page can't be found when it is clearly identified in the Assets plugin below.

image
http://wiki.dbbs.co/framed.html

The Frame plugin should use markup that more directly instructs the construction of reference urls. The CORS restrictions and associated security implications need to be thought through carefully. But the success of Frame and Assets will depend on our unique insight into sharing that is not widespread in the general (and possessive) web environment.

Perhaps the markup could use keywords to distinguish intentions

ASSET framed/frame.html

rather than the relative reference used

/assets/framed/frame.html

Once the proper logic has been developed it might make sense to incorporate it into the SiteAdapter API and thus encourage reference consistency across our suite of plugins. Improved asset handling in the Image plugin is right behind Frame in this regard. Please note, @paul90.

@dobbs
Copy link
Member

dobbs commented Mar 10, 2018

There are indeed interesting consequences for the way we share. I edited that item to include the protocol and domain name:

https://wiki.dbbs.co/assets/framed/frame.html

Here's how it looks as an external page: http://ward.asia.wiki.org/wiki.dbbs.co/framed

screen shot 2018-03-09 at 8 01 08 pm

And by contrast, here's how it looks as a local page: https://wiki.dbbs.co/view/framed

screen shot 2018-03-09 at 7 56 27 pm

I further experimented by visiting that page without https: (http://wiki.dbbs.co/view/framed) and learned that firefox enforces cross-origin policies even though both the main page and the framed content are under the same domain name. The protocol puts them in separate origins.

I like your suggested markup. It allows us to smooth over these cross-origin wrinkles.

@WardCunningham
Copy link
Member Author

WardCunningham commented Mar 10, 2018

Here is the code I use to construct the sharing context that controls what assets will be shown by the Assets plugin.

https://github.com/WardCunningham/wiki-plugin-assets/blob/9a642fb06922b803478a21dee5f6c1a7e5b110f6/client/assets.coffee#L7-L18

The Frame plugin could ping each site in context order until it finds the first available version consistent with our sharing semantics. As you point out, there is no guarantee that the browser will grant the chosen file sufficient privilege to run.

I plan to add to Assets some simple click that will copy a remote asset to the origin for logged in users thus elevating the file's privilege. This will be as if the user downloaded the remote file and then uploaded it to their own collected assets. I've been slow to implement this because I haven't decided what the click should be or how progress in the download should be shown.

@dobbs dobbs closed this as completed in c77a203 Mar 21, 2018
@dobbs
Copy link
Member

dobbs commented Mar 21, 2018

Rather than expanding the frame markup with knowledge about assets, I've opted to prevent authors from using site-relative links. I'm not opposed to expanding in that direction, but prefer to fix this immediate behavior more simply for the time being.

@dobbs
Copy link
Member

dobbs commented Mar 3, 2019

Today's work on issues #2 and #4 remind me that frame plugin would still benefit from working better with assets plugin.

@paul90
Copy link
Member

paul90 commented Aug 1, 2021

It was also be nice to be very nice if site-relative links could include plugin paths, such as /plugins/journaltools/test.htm.

This will allow frame based tools to be bundled into a plugin for distribution. Rather that rely on some central source, and all the problem come with that (such as the http / https schism).

@WardCunningham
Copy link
Member Author

I see that our plugin client code is fetched via similar paths.
http://trails.ward.asia.wiki.org/plugins/map/map.js

But about pages don't seem to be qualified other than by page naming convention.
http://trails.ward.asia.wiki.org/about-map-plugin.json

The Datalog plugin extends this routing with a server-side plugin that offers now-relative addressing.
http://found.ward.bay.wiki.org/plugin/datalog/esp8266-datalog/day/0

In this last case logs are written to a plugin and page specific location in the assets folder.
plugins/datalog/esp8266-datalog

These files can be directly addressed through our assets mechanism.
http://found.ward.bay.wiki.org/assets/plugins/datalog/esp8266-datalog/2021-08-01.log

We see a number of different cases here, all related to a plugin one way or another. Paul's suggestion is consistent with all of them while while rightfully segregating plugins, unlike about pages. We might go further and extend an open ended route for related content such as cooperating css and js files.
/plugins/journaltools/assets/test.htm
/plugins/journaltools/assets/test.css

Here assets refers to plugin specific assets installed along with the plugin. Assets would be an additional route in wiki.server that would be restricted to one level and be shipped with cors headers.

dobbs added a commit that referenced this issue Nov 6, 2021
Ward has been experimenting with interactions between html scripts
inside frames and files inside of assets. The experiments reveal cases
where the html script programmer needs information about three
different web contexts:

1) the script itself can be hosted under one domain name,

2) the frame item on a wiki page under another domain name, and

3) the wiki origin holding a lineup of pages under a third domain name.

item #1 can be gotten from window.location
item #2 is in the "site"
item #3 is new and given in the "origin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants