Code Monkey home page Code Monkey logo

shared-resources's Introduction

shared-resources

An app package with shared resources used by several eXist-db applications

Building

The latest version of shared-resources is included with eXist-db, though this might not be the newest version. You can install a newer or second version of shared-resources by deploying it directly into the database.

To build shared-resourcese from scratch, you should first clone shared-resources into a directory, e.g.:

 git clone git://github.com/eXist-db/shared-resources.git shared-resources
 cd shared-resources
 git submodule update --init --recursive

Next, call ant on the build.xml file in shared-resources:

 ant

You should now find a .xar file in the build directory:

 build/shared-resources-0.8.2.xar

The .xar file is an installable package containing shared-resources. You can install this into any eXist-db instance using the application repository manager in the dashboard.

shared-resources's People

Contributors

adamretter avatar bwbohl avatar christophe-g avatar dizzzz avatar duncdrum avatar jensopetersen avatar joewiz avatar kohsah avatar lguariento avatar line-o avatar ljo avatar martindholmes avatar peterstadler avatar shabanovd avatar tgraham-antenna avatar wolfgangmm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shared-resources's Issues

Prepare new release, bump version to 0.4.1

Shared-resources was last released in July 2014 (0.4.0), and the version in public-repo included an extra copy of the 400K emmet.js file. Since then a number of bug fixes have been submitted and accepted. These should be included in a new release.

Proposed steps:

  • Perform diff of git repo against source in previous released .xar to ensure no uncommitted work is lost
  • Update release notes in repo.xml to note significant changes
  • Bump version
  • Release to GitHub and public-repo

Looking ahead, @wolfgangmm has a branch that requires XQuery 3.1, which allows template functions to accept an arbitrary number of parameters. If that branch is merged into master and released as a new version (as 1.0, perhaps, to indicate the break in compatibility with eXist 2.2), then the present release, 0.4.1, will be the last release of shared-resources that is backward compatible with eXist 2.2.

templating framework's handling of radio inputs

While the templating function templates:form-control seems to handle radio buttons, the result appears to be all options getting the checked attribute, instead of applying the attribute only to the option with the correct value.

problems starting exide

screenshot 2018-10-05 at 12 43 18

after updating to shared-resources via dashboard (and after a reboot) it looks like the ace submodule contents are missing

exist-db 4.4.0
shared-resources 0.8.1

Issues with css

Hello,

this is my .css:

.backg {
    background-image: url("banner.jpg");
    height: 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

This is my page.html:

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title data-template="config:app-title">ct_editions</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" data-template="config:app-meta"/>
        <link rel="stylesheet" type="text/css" href="resources/css/style.css"/>
    </head>
    <body id="body">
        <div id="content" class="container"/>
    </body>
</html>

This is my index.html:

<div xmlns="http://www.w3.org/1999/xhtml" data-template="templates:surround" data-template-with="templates/page.html" data-template-at="content">
  
  <div class="backg"></div>
</div>

The background image just doesn't show up on the browser. In the inspector, though, everything looks fine:

image

If I put <div class="backg"></div> directly in the template (page.html), all works as expected (i.e. I see the background image).

eXist-db 5.0.0 RC4
OSX 10.11.6
Java 1.8.0_191-b12

[BUG] Last-Modified header is set to document date with templating apps

Describe the bug

My application is using the templating framework to generate pages, they differ for every user and depend obviously on the login state. Now my users complained that they see stale pages, for example after a login change, some previously visited pages show the previous login, even if requested from the server, only a forced reload actually produces an updated page.

After investigation, I found that the Last-Modified header sent by the application is always the same as the last modified date of the HTML document that hosts the page.

Expected behavior

I would expect the Last-Modified header to be the current time at the time of the generation of the page. To work around this bug, I added the following to my controller.xql:

else if (ends-with($exist:resource, ".html")) then (
    login:set-user($config:login-domain, (), false()),
    (: the html page is run through view.xql to expand templates :)
    <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
        <view>
            <forward url="{$exist:controller}/modules/view.xql">
                <set-header name="Last-Modified" value="{current-dateTime()}"/>
            </forward>
        </view>
        <error-handler>
            <forward url="{$exist:controller}/error-page.html" method="get"/>
            <forward url="{$exist:controller}/modules/view.xql"/>
        </error-handler>
    </dispatch>
)

This stops the browser from unwanted caching of pages.

To Reproduce

Unfortunately, I don't have a self-contained sample, but I think it should be easy enough to find this problem in any templating application

Context (please always complete the following information):

  • OS: Ubuntu 18.04
  • eXist-db Version: 5.2.0
  • Java Version: 1.8.0_201
  • App Version: n/a

Additional context

  • How is eXist-db installed? unzipped the distribution.
  • Any custom changes in e.g. conf.xml?

highlight + ace prevent jQuery updates

@wolfgangmm Would it be possible to wean our apps off the custom highlight jQuery plugin, as it prevents jQuery updates past 1.8? It might also help with using a new ace that fixed some bidi bugs that are bugging exide users.

The state of js syntax highlighters for XQuery is not great, but if we could expand on this highlight.js parser that would remove one bloc from using html5 and more current js libraries. Since you wrote the current highlighter, do you think thats feasible?

P.S.: In the meantime if we could switch the current attribute from data-language="xquery" to <code class="language-XQuery"> or <code class="xquery"> we would be closer to html5 recommendations.

templates, enhancement: allow loading of remote template documents

Currently the templates:include and templates:surround APIs have the $path and $with parameter, and this is assumed to be a template file within the same application with a relative path.

However, in my case I am applying some pre-processing on the template using Mustache and then providing it to eXist. So I want to serve the templates from a different templates server. I found making the $path and $with support http paths is very easy. I believe this small change adds a significant improvement to the templating functionality.

So the call to the template would look something like:

<div  data-template="templates:surround" data-template-
     with="http://localhost:9999/templatesServer/templates/page.xml" 
     data-template-at="content">
....
</div>

calling a non-existent templating function no longer(?) reports error

@merenyics commented on Jul 20, 2018, 3:56 PM UTC:

What is the problem

If I remember correctly, prior to version 4.3 calling a templating function like this
<div class="some:function"/>
resulted in an error being thrown immediately, indicating that the given function does not exist. Right now, using 4.3, the server does not respond within a reasonable amount of time, I can see in Monex that a query is running (view.xql) but it won't return, I need to kill it manually.

What did you expect

I expected to get the error message I used to get, instead of the query hanging

Describe how to reproduce or add a test

Just try calling a non-existent function using templating

Context information

Please always add the following information

  • eXist-db version 4.3
  • Java version Java8u161
  • Operating system Windows 10
  • 64 bit
  • How is eXist-db installed? (JAR installer)
  • no custom changes

This issue was moved by joewiz from eXist-db/exist#2050.

the description in the generated app.xql needs to be updated

The function currently has:

declare function app:test($node as node(), $model as map(*)) {

Dummy template output generated by function app:test at {current-dateTime()}. The templating
function was triggered by the class attribute class="app:test".


};

but it is using the data-templates* attributes, so it should be:

declare function app:test($node as node(), $model as map(*)) {

Dummy template output generated by function app:test at {current-dateTime()}. The templating
function was triggered by the attribute data-template="app:test".


};

Words cut off in documentation definition lists because of bootstrap CSS

Definition lists in apps that use shared-resources CSS, such as the documentation app's article on serialization http://exist-db.org/exist/apps/doc/xquery.xml#serialization-10, cut off words. The fix is to override bootstrap's default handling of .dl-horizontal dt to change white-space: nowrap to white-space: normal. Perhaps this override should happen in the exist.css file. The screenshots below illustrate the current problem, how the appearance is fixed by changing white-space to normal, and a further fix to add indentation to multi-line entries with padding-left: 1em; text-indent: -1em.

I'd submit a pull request for this, but I'm not sure whether the change should go into .css or .less files.

Current behavior:

screen shot 2014-03-04 at 2 34 35 pm

With white-space: normal

screen shot 2014-03-04 at 2 34 43 pm

With indentation added

screen shot 2014-03-04 at 2 35 20 pm

return signature of apputil:resolve and apputil:resolve-abbrev :

Tiny modification in apputil.xql:
As apputil:resolve and apputil:resolve-abbrev can return an empty sequence, the signature should be xs:string? instead of just xs:string as it is now.
Cheers,
C.

(:~
 : Try to find an application by its unique name and return the relative path to which it
 : has been deployed inside the database.
 : 
 : @param $pkgURI unique name of the application
 : @return database path relative to the collection returned by repo:get-root() 
 : or the empty sequence if the package could not be found or is not deployed into the db
 :)
declare function apputil:resolve($uri as xs:string) as xs:string **?** {
    let $path := collection(repo:get-root())//expath:package[@name = $uri]
    return
        if ($path) then
            substring-after(util:collection-name($path), repo:get-root())
        else
            ()
};

(:~
 : Try to find an application by its abbreviated name and return the relative path to which it
 : has been deployed inside the database.
 : 
 : @param $pkgURI unique name of the application
 : @return database path relative to the collection returned by repo:get-root() 
 : or the empty sequence if the package could not be found or is not deployed into the db
 :)
declare function apputil:resolve-abbrev($abbrev as xs:string) as xs:string **?** {
    let $path := $apputil:PACKAGES($abbrev)
    return
        if ($path) then
            substring-after($path, repo:get-root())
        else
            ()
};

Security - Update Jquery

Hello,

Shared-resources uses the version 1.7.1 of Jquery which contains a XSS vulnerability. Is it possible to update it to a least the version 1.9 of Jquery or better, the 3.4.1 version.

Even if the version is updated to 1.9, this version is no longer maintained by the Jquery team and does not receive any security update.

publish loadsource.js to npm

there is a dependency by all default template generated packages to this js script in shared-resources.

as part of the ongoing revamp I would suggest to publish this on npm under our namespace, so folks can import it without going to shared resources.

Templating and transform:transform: empty output on error

@dariok commented on Jul 27, 2018, 4:55 PM UTC:

What is the problem

  • The templating system is used to provide the basic HTML for displaying the result of an XSL transformation:
<html data-template="wdb:getEE">
    <head><title>test</title></head>
    <body>
        <div id="wdbContent" data-template="wdb:getContent" />
    </body>
</html>
  • the function to apply the transformation is basically this:
declare function wdb:getContent($node as node(), $model as map(*)) {
  let $re :=
    try { transform:transform(doc($file), doc($xslt), $params, $attr, "expand-xincludes=no") }
    catch * { <h1>Error</h1> }

  return 
    <div id="wdbContent">
        {$re}
    </div>
};
  • this works fine if there are no errors in the XSLT. However, if there is an error, e.g. calling doc() on a file that does not exist, the output is an empty file:
<!DOCTYPE html>
<html></html>

What did you expect

The output of the given HTML in case of an error.

additional observations:

  1. calling wdb:getContent with exactly the same parameters from eXide produces the expected output in case of an error
  2. everything else inside the catch is processed correctly – I tried to console:log before returning output, which worked, and forwarding handling to another function: there, too, console:log worked but no output was produced
  3. using transform:stream-transform returns the expected output in case of an error (but of course won't work correctly with the templating system)

Describe how to reproduce or add a test

The attached .zip contains an example. Store in /db/apps and call $server/exist/apps/catch/view.html.
If the line with doc() is commented out in the XSLT, you get “Testing”; if it is active, you get an empty response. If you use stream-transform instead of transform in app.xql, you get “error“ if the doc() line is active.
catch.zip

Context information

Please always add the following information

  • eXist-db: 4.3.0
  • Java version: 1.8.0_171
  • Operating system: tested on Ubuntu 16.04 and Windows 10
  • 64 bit
  • How is eXist-db installed? JAR installer
  • Any custom changes in e.g. conf.xml: added an additional root to controller-config.xml on the Ubuntu machine; this is not present under Windows.

This issue was moved by duncdrum from eXist-db/exist#2074.

[question] outdated js libraries

bootstrap 3.0.3 (released 2014) is severely outdated, 3.3.7 is current and 4.0.0 is approaching. Beginners can no longer just copy paste examples from the bootstrap docs into their exist code, without running into troubles because of this. I have tried to update the js library in my local test machine and ran into js artefacts all over the place (granted that was a while ago). I dislike jquery but it probably suffers a similar fate.

Are there better strategies to keep shared resources current, without breaking existing apps? Would it make sense to move shared-resources to a more aggressive dependency management regiment? Maybe switch the html starter code to cdnjs?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.