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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] User can override templates for table and graph #7176

Merged
merged 8 commits into from Jun 18, 2020

Conversation

jgsogo
Copy link
Member

@jgsogo jgsogo commented Jun 10, 2020

Changelog: Feature: Templates for conan search --table and conan info --graph can be overridden by the user.
Docs: conan-io/docs#1739

馃幎 Unblocks PR #6815 (although it has to be rewritten)

  • Add base_template_path to context: path to the folder where the template file is located.

  • Unit-testing graph objects (table too, but there is already something)


After #6833 and #6832 next step is to let the user override default templates with a custom one. This PRs will look into <cache_folder>/templates directory for the templates before using the Conan provided ones. Current templates that can be overridden are:

  • <cache_folder>/templates/output/search_table.html: table output
  • <cache_folder>/templates/output/info_graph.dot: graph output in graphviz format
  • <cache_folder>/templates/output/info_graph.html: graph output in HTML format

This PR will require to document the context for these templates and unit-testing for those objects

@jgsogo jgsogo added this to the 1.27 milestone Jun 10, 2020
@jgsogo jgsogo self-assigned this Jun 10, 2020
@jgsogo jgsogo added the component: ux No changes to core business logic label Jun 10, 2020
Copy link
Member

@memsharded memsharded left a comment

This is very nice.
Is it possible to implement the use case of using custom .js and .css files for the templates? Not embedded in the html, but as separate files. This was already a request in the past, and will certainly be requested again over this new functionality if people use it.

@jgsogo
Copy link
Member Author

@jgsogo jgsogo commented Jun 10, 2020

This is very nice.
Is it possible to implement the use case of using custom .js and .css files for the templates? Not embedded in the html, but as separate files. This was already a request in the past, and will certainly be requested again over this new functionality if people use it.

Yes, it requires just one more variable from our side. With this feature the user can write whatever they want in the html file, for example:

  • Use URL (preferred one)

        <head>
            <script type="text/javascript" src="https://mycompany/assets/.../vis.min.js"></script>
            <link href="https://mycompany/assets/.../vis.min.css" rel="stylesheet" type="text/css"/>
        </head>
  • use absolute paths:

        <head>
            <script type="text/javascript" src="/absolute/path/.../vis.min.js"></script>
            <link href="/absolute/path/.../vis.min.css" rel="stylesheet" type="text/css"/>
        </head>

    Typically a company (if not using URL) will distribute these assets together with the template, so they will be in some folder in the cache:

    • <cache_folder>/templates/output/info_graph.html
    • <cache_folder>/templates/output/assets/vis.min.js
    • <cache_folder>/templates/output/assets/vis.min.css

    We only need to provide the path to the templates folder in the cache, probably something like base_template_path=<cache_folder>/templates/output/ and the info_graph.html could use it to build those absolute paths:

        <head>
            <script type="text/javascript" src="{{ base_template_path }}/vis.min.js"></script>
            <link href="{{ base_template_path }}/vis.min.css" rel="stylesheet" type="text/css"/>
        </head>

    The main issue here is that the generated html file will work only in the developer machine, as it contains hardcoded paths to its cache. The template is generic, but the rendered result isn't.

  • use relative paths: the problem here is that these paths will be relative to the place where the output file is written (probably not the place where the assets are located).

        <head>
            <script type="text/javascript" src="js/vis.min.js"></script>
            <link href="css/vis.min.css" rel="stylesheet" type="text/css"/>
        </head>

@jgsogo jgsogo requested a review from memsharded Jun 12, 2020
@jgsogo jgsogo requested a review from czoido Jun 12, 2020
@memsharded memsharded requested review from SSE4 and uilianries Jun 15, 2020
czoido
czoido approved these changes Jun 18, 2020
@memsharded memsharded merged commit 51bf334 into conan-io:develop Jun 18, 2020
2 checks passed
@jgsogo jgsogo deleted the feature/user-templates branch Jun 18, 2020
sthagen added a commit to sthagen/conan-io-conan that referenced this issue Jun 21, 2020
[feature] User can override templates for table and graph (conan-io#7176)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ux No changes to core business logic type: feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants