diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2018-11-08 10:31:28 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2018-11-08 10:31:28 +0000 |
| commit | ac0306d69b12d7be910c0ec27093ec506d6349ce (patch) | |
| tree | 9f4ecb9abeb65be7dc582ee5b8a45894e9e35241 | |
| parent | cleanup (diff) | |
| download | mmm-ac0306d69b12d7be910c0ec27093ec506d6349ce.tar.gz mmm-ac0306d69b12d7be910c0ec27093ec506d6349ce.zip | |
rename properties to facets
| -rw-r--r-- | bundle_fileder.moon | 18 | ||||
| -rw-r--r-- | mmm/mmmfs/browser.moon | 35 | ||||
| -rw-r--r-- | mmm/mmmfs/fileder.moon | 40 | ||||
| -rw-r--r-- | root/articles/mmmfs/gallery/link_to_image/URL -> image$png (renamed from root/articles/mmmfs/gallery/image_1/URL -> image$png) | 0 | ||||
| -rw-r--r-- | root/articles/mmmfs/gallery/link_to_image/preview: URL -> image$png (renamed from root/articles/mmmfs/gallery/image_1/preview: URL -> image$png) | 0 | ||||
| -rw-r--r-- | root/articles/mmmfs/text$moonscript -> fn -> mmm$dom.moon | 82 |
6 files changed, 105 insertions, 70 deletions
diff --git a/bundle_fileder.moon b/bundle_fileder.moon index 9ef2381..01aa0a4 100644 --- a/bundle_fileder.moon +++ b/bundle_fileder.moon @@ -29,12 +29,12 @@ readfile = (name) -> with file\read '*all' file\close! --- load a fs file as a fileder property -load_property = (path, filename) -> +-- load a fs file as a fileder facet +load_facet = (filename) -> key = (filename\match '(.*)%.%w+') or filename key = Key key\gsub '%$', '/' - value = readfile path .. filename + value = readfile filename key, value @@ -42,9 +42,9 @@ load_property = (path, filename) -> escape = (str) -> string.format '%q', tostring str -- compile a moonscript facet to lua -compile = (old, new, val) -> "-- this property has been transpiled from '#{old}' +compile = (old, new, val) -> "-- this facet has been transpiled from '#{old}' -- to '#{new}' for execution in the browser. --- refer to the original property as the source. +-- refer to the original facet as the source. #{to_lua val}" -- dump a fileder subtree as Lua source @@ -52,7 +52,7 @@ dump_fileder = do _dump = (fileder, root=false) -> code = "Fileder {" - for key, val in pairs fileder.props + for key, val in pairs fileder.facets if key.original key = "fromcache(#{escape key}, #{escape key.original})" else @@ -87,13 +87,13 @@ with io.open '$bundle.lua', 'w' if facet == '$order' order = [line for line in io.lines facet] continue - key, value = load_property '', facet - .props[key] = value + key, value = load_facet facet + .facets[key] = value if key.type\match '^text/moonscript %->' new_key = Key key.name, key.type\gsub '^text/moonscript %-> (.*)', 'text/lua -> %1' new_key.original = key - .props[new_key] = compile key, new_key, value + .facets[new_key] = compile key, new_key, value for child in *children_bundles -- @BUG: child bundles are malformed due to Tup bug ($ symbol) diff --git a/mmm/mmmfs/browser.moon b/mmm/mmmfs/browser.moon index 62212df..ca0d709 100644 --- a/mmm/mmmfs/browser.moon +++ b/mmm/mmmfs/browser.moon @@ -40,12 +40,11 @@ class Browser -- (re)set every time @path changes @active = @path\map @root\walk - -- currently active property + -- currently active facet -- (re)set to default when @active changes - @prop = @active\map (fileder) -> + @facet = @active\map (fileder) -> return unless fileder - last = @prop and @prop\get! - -- (fileder\find 'mmm/dom') or next fileder.props + last = @facet and @facet\get! Key if last then last.type else 'mmm/dom' -- whether inspect tab is active @@ -82,17 +81,17 @@ class Browser \append '/' \append path_segment name, href - \append span 'view property:', style: { 'margin-right': '0' } + \append span 'view facet:', style: { 'margin-right': '0' } \append @active\map (fileder) -> onchange = (_, e) -> - { :type } = @prop\get! - @prop\set Key name: e.target.value, :type + { :type } = @facet\get! + @facet\set Key name: e.target.value, :type - current = @prop\get! + current = @facet\get! current = current and current.name with select :onchange, disabled: not fileder if fileder - for i, value in ipairs fileder\get_prop_names! + for i, value in ipairs fileder\get_facets! label = if value == '' then '(main)' else value \append option label, :value, selected: value == current \append @inspect\map (enabled) -> @@ -101,11 +100,11 @@ class Browser -- append or patch #browser-content main\append with get_or_create 'div', 'browser-content', class: 'content' - \append (@prop\map (p) -> @get_content p), (rehydrate and .node.lastChild) + \append (@facet\map (p) -> @get_content p), (rehydrate and .node.lastChild) if rehydrate -- force one rerender to set onclick handlers etc - @prop\set @prop\get! + @facet\set @facet\get! inspector = @inspect\map (enabled) -> if enabled then @get_inspector! @@ -123,13 +122,13 @@ class Browser active = @active\get! return disp_error "fileder not found!" unless active - return disp_error "property not found!" unless prop + return disp_error "facet not found!" unless prop ok, res, trace = xpcall convert, err_and_trace, active, prop if ok res or disp_error "[no conversion path to #{prop.type}]" - elseif res\match '%[nossr%]$' + elseif res and res.match and res\match '%[nossr%]$' warn '(SSR disabled)' div! else @@ -137,9 +136,9 @@ class Browser disp_error "error: #{res}\n#{trace}" get_inspector: => - -- active property in inspect tab - -- (re)set to match when @prop changes - @inspect_prop = @prop\map (prop) -> + -- active facet in inspect tab + -- (re)set to match when @facet changes + @inspect_prop = @facet\map (prop) -> active = @active\get! key = active\find prop key = key.original if key and key.original @@ -153,12 +152,12 @@ class Browser fileder = @active\get! onchange = (_, e) -> - { :name } = @prop\get! + { :name } = @facet\get! @inspect_prop\set Key e.target.value with select :onchange if fileder - for key, _ in pairs fileder.props + for key, _ in pairs fileder.facets value = key\tostring! \append option value, :value, selected: value == current @inspect\map (enabled) -> diff --git a/mmm/mmmfs/fileder.moon b/mmm/mmmfs/fileder.moon index 63fc9f8..d08d80c 100644 --- a/mmm/mmmfs/fileder.moon +++ b/mmm/mmmfs/fileder.moon @@ -1,7 +1,7 @@ require = relative ..., 1 import get_conversions, apply_conversions from require '.conversion' --- Key of a Fileder Property +-- Key of a Fileder Facet -- contains: -- * @name - key name or '' for main content -- * @type - type string (type -> type -> type) @@ -34,16 +34,16 @@ class Key -- Fileder itself -- contains: --- * @props - Property Map (Key to Value) +-- * @facets - Facet Map (Key to Value) -- * @children - Children Array class Fileder - -- instantiate from props and children tables - -- or mix in one table (numeric keys are children, remainder props) - -- prop-keys are passed to Key constructor - new: (props, children) => + -- instantiate from facets and children tables + -- or mix in one table (numeric keys are children, remainder facets) + -- facet-keys are passed to Key constructor + new: (facets, children) => if not children - children = for i, child in ipairs props - props[i] = nil + children = for i, child in ipairs facets + facets[i] = nil child -- automatically mount children on insert @@ -59,13 +59,13 @@ class Fileder @children[i] = child -- automatically reify string keys on insert - @props = setmetatable {}, __newindex: (t, key, v) -> + @facets = setmetatable {}, __newindex: (t, key, v) -> rawset t, key, nil -- fix for fengari.io rawset t, (Key key), v - -- copy props - for k, v in pairs props - @props[k] = v + -- copy facets + for k, v in pairs facets + @facets[k] = v -- recursively walk to and return the fileder with @path == path -- * path - the path to walk to @@ -107,21 +107,21 @@ class Fileder for child in *@children child\iterate depth - 1 - -- get all unique names associated with properties (list) - get_prop_names: => + -- get all facet names (list) + get_facets: => names = {} - for key in pairs @props + for key in pairs @facets names[key.name] = true [name for name in pairs names] - -- find property key according to criteria, nil if no value or conversion path + -- find facet and type according to criteria, nil if no value or conversion path -- * ... - arguments like Key find: (...) => want = Key ... - -- filter props by name - matching = [ key for key in pairs @props when key.name == want.name ] + -- filter facets by name + matching = [ key for key in pairs @facets when key.name == want.name ] return unless #matching > 0 -- get shortest conversion path @@ -134,7 +134,7 @@ class Fileder error "couldn't find key after resolution?" - -- get property according to criteria, nil if no value or conversion path + -- get and convert facet according to criteria, nil if no value or conversion path -- * ... - arguments like Key get: (...) => want = Key ... @@ -143,7 +143,7 @@ class Fileder key, conversions = @find want if key - value = apply_conversions conversions, @props[key], @, key + value = apply_conversions conversions, @facets[key], @, key value, key -- like @get, throw if no value or conversion path diff --git a/root/articles/mmmfs/gallery/image_1/URL -> image$png b/root/articles/mmmfs/gallery/link_to_image/URL -> image$png index 7cf76ff..7cf76ff 100644 --- a/root/articles/mmmfs/gallery/image_1/URL -> image$png +++ b/root/articles/mmmfs/gallery/link_to_image/URL -> image$png diff --git a/root/articles/mmmfs/gallery/image_1/preview: URL -> image$png b/root/articles/mmmfs/gallery/link_to_image/preview: URL -> image$png index 2b2233b..2b2233b 100644 --- a/root/articles/mmmfs/gallery/image_1/preview: URL -> image$png +++ b/root/articles/mmmfs/gallery/link_to_image/preview: URL -> image$png diff --git a/root/articles/mmmfs/text$moonscript -> fn -> mmm$dom.moon b/root/articles/mmmfs/text$moonscript -> fn -> mmm$dom.moon index 5619747..635ffea 100644 --- a/root/articles/mmmfs/text$moonscript -> fn -> mmm$dom.moon +++ b/root/articles/mmmfs/text$moonscript -> fn -> mmm$dom.moon @@ -28,12 +28,54 @@ table.insert args, style: { 'list-style': 'none', 'font-size': '0.8em' } ol table.unpack args - append h1 'mmmfs', style: { 'margin-bottom': 0 } -- @TODO: s/filesystem/a way of organizing files/g - append p "a file and operating system to live in", style: { 'margin-top': 0, 'margin-bottom': '1em' } + append h1 'mmmfs', style: { 'margin-bottom': 0 } + append p "a file and operating system to live in", style: { 'margin-top': 0, 'padding-bottom': '0.2em', 'border-bottom': '1px solid black' } + + append h2 "motivation" + append p "Today, computer users are losing more and more control over their data. Between web and cloud + applications holding customer data hostage for providing the services, unappealing and limited mobile file + browsing experiences and the non-interoperable, proprietary file formats holding on to their own data has + become infeasible for many users. mmmfs is an attempt at rethinking file-systems and the computer user + experience to give control back to and empower users." + + append p "mmmfs tries to provide a filesystem that is powerful enough to let you use it as your canvas for thinking, + and working at the computer. mmmfs is made for more than just storing information. Files in mmmfs can interact + and morph to create complex behaviours." + + append p "Let us take as an example the simple task of collecting and arranging a mixed collection of images and texts + in order to brainstorm. To create an assemblage of pictures and text, many might be tempted to open an + Application like Microsoft Word or Adobe Photoshop and create a new document there. Both photoshop files and + word documents are capable of containing texts and images, but when the files are saved, direct access to the + contained data is lost. It is for example a non-trivial and unenjoyable task to edit an image file contained + in a word document in another application and have the changes apply to the document. In the same way, + text contained in a photoshop document cannot be edited in a text editor of your choice." + + append p "mmmfs tries to change all this. In mmmfs, files can contain other files and so the collage document + becomes a container for the collected images and texts just as a regular directory would. This way the individual + files remain accessible and can be modified whenever necessary, while the collage document can be edited to + change the order, sizes and spacial arrangement of it's content if this is wanted, for example." + + append p "The mmmfs file-type system also allows storing types of information that have become impractical to use + with current filesystems simply because noone has cared to make the right applications for them. It is not common + practice for example to store direct links to online content on the disk for example. In mmmfs, a link to a + picture and an actual picture are equivalent as long as you just want to view the picture. The collage file + described above for example wouldn't even know the difference, and you could mix and match between these types + as you wish." -- @TODO: motivation / outline problem + need - -- @TODO: quote http://pchiusano.github.io/2013-05-22/future-of-software.html on Applications + -- * applications don't let users *do* things (http://pchiusano.github.io/2013-05-22/future-of-software.html) + -- * applications are just (collections of) files - most users don't know this (anymore) + -- * users should know their system and how to move around in it + -- * filesystem trees are only *okay* for organizing information: + -- - users sooner or later choose something smarter because: + -- * filesystems work the same in every folder, even though the context can be very different + -- * appliances put their complex, structured data into opaque blocks + -- * the FS should be able to solve the structure issue + -- * the benefit is interoperability: edit the image of your report + -- * in image editor while the document editor automatically refreshes + -- * file formats dont mean much to users, they are meant for applications - let applications take care of converting them + -- * report.doc, report.pdf, report_orignal.pdf, report_old.doc, report2.doc.... append p do fileder = footnote "fileder: file + folder. 'node', 'table' etc. are too general to be used all over." @@ -91,52 +133,46 @@ }, } - append div for child in *@children preview child append h2 "details" -- @TODO s/parts: dimensions, aspects? - -- @TODO: first mention both properties & children; then go into detail + -- @TODO: first mention both facets & children; then go into detail -- @TODO: main content append do name = html.i 'name' type = html.i 'type' - p "Fileders are made up of two main parts. The first is the list of ", (html.i 'properties'), ", + p "Fileders are made up of two main parts. The first is the list of ", (html.i 'facets'), ", which are values identified by a ", name, " and ", type, ". These values are queried using strings like ", (code 'title: text/plain'), " or ", (code 'mmm/dom'), ", which describe both the ", name, - " of a property (", (moon '"title"'), " and ", (moon '""'), ", the unnamed/main property) and the ", type, - " of a property. Property types can be something resembling a MIME-type or a more complex structure - (see ", (html.i "type chains"), " below). A fileder can have multiple properties of different types - set that share a ", name, ". In this case the overlapping properties are considered equivalent and the one + " of a facet (", (moon '"title"'), " and ", (moon '""'), ", the unnamed/main facet) and the ", type, + " of a facet. Facet types can be something resembling a MIME-type or a more complex structure + (see ", (html.i "type chains"), " below). A fileder can have multiple facets of different types + set that share a ", name, ". In this case the overlapping facets are considered equivalent and the one with the most appropriate ", type, " is selected, depending on the query. - The unnamed property is considered a fileder's 'main content', i.e. what you are interested in when viewing it." + The unnamed facet is considered a fileder's 'main content', i.e. what you are interested in when viewing it." append p "The second part of a fileder is the list of it's children, which are fileders itself. The children are stored in an ordered list and currently identified by their ", (code 'name: alpha'), - " property for UI and navigation purposes only (not sure if this is a good idea tbh)." - --- append do --- github = footnote a 's-ol/mmm', href: 'https://github.com/s-ol/mmm/tree/master/app/mmmfs' --- "Oh and also everything is on github and stuff", github, --- " if you care about that." + " facet for UI and navigation purposes only (not sure if this is a good idea tbh)." append do mmmdom = code ('mmm/dom'), footnote span (code 'mmm/dom'), " is a polymorphic content type; on the server it is just an HTML string (like ", (code 'text/html'), "), but on the client it is a JS DOM Element instance." - p "What you are viewing right now is the main property of the root fileder. - The property is queried as ", mmmdom, ", a website fragment (DOM node). This website fragment + p "What you are viewing right now is the main facet of the root fileder. + The facet is queried as ", mmmdom, ", a website fragment (DOM node). This website fragment is then added to the page in the main content area, where you are most likely reading it right now." p "Anyway, this node is set up as a very generic sort of index thing and just lists its children-fileders' alongside this text part you are reading.", br!, "For each child it displays the ", (code 'title: text/plain'), - " and shows the ", (code 'preview: mmm/dom'), " property (if set)." + " and shows the ", (code 'preview: mmm/dom'), " facet (if set)." append h3 "converts" - append p "So far I have always listed properties as they are being queried, but a main feature of mmmfs is + append p "So far I have always listed facets as they are being queried, but a main feature of mmmfs is type conversion. This means that you generally ask for content in whichever format suits your application, and rely on the type resolution mechanism to make that happen." @@ -159,7 +195,7 @@ preview title, content ]] append p "Here the code that renders these previews. You can see it ", (html.i "asks"), " for the - properties ", (code 'title: text/plain'), ' and ', (code 'preview: mmm/dom'), "), but the values don't actually have to + facets ", (code 'title: text/plain'), ' and ', (code 'preview: mmm/dom'), "), but the values don't actually have to be ", (html.i "defined"), " as these types. For example, the markdown child below only provides ", (code 'preview'), " as ", (code 'text/markdown'), ":" @@ -189,7 +225,7 @@ Fileder { ]] append h3 "type chains" - append p "In addition, a property type can be encoded using multiple types in a ", (code 'type chain'), ". + append p "In addition, a facet type can be encoded using multiple types in a ", (code 'type chain'), ". For example the root node you are viewing currently is actually defined as ", (code 'fn -> mmm/dom'), ", meaning it's value is a pre moon function returing a regular ", (code 'mmm/dom'), " value." |
