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

Issue 103 dynamic template #179

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

jbao
Copy link

@jbao jbao commented Dec 19, 2016

This automatically generates the current timestamp in the template and resolves #103

Auto-reviewers: @NiharikaRay @matthewwardrop @earthmancash @danfrankj

@matthewwardrop
Copy link
Collaborator

matthewwardrop commented Dec 20, 2016

Hi @jbao,

Thanks for your contribution!

Can you perhaps use jinja2 templating like we are doing for the site pages itself? Thus, rather than "&current_date" you would use "{{ current_date }}", and do the substitution in the knowledge_repo script using something like:

with open('<template_name>') as f:
   result = jinja2.Template(f.read()).render(current_date=...)

This simplifies the code a lot.

In the testing, you can then use the knowledge_repo create command to do the substitution, which will also act as a good test that this mechanism is working appropriately.

Thanks again! Little fixes for nits like this are a great help, as we are often so busy with the "bigger" stuff that we lose sight of these sorts of things which can have a big effect on user experience.

M

@matthewwardrop
Copy link
Collaborator

Just thinking too: maybe you can add support for automatically populating the author too?

Should be as easy as passing in author = os.getlogin() to the Template.render method; and adding {{ author }} to the templates.

@jbao
Copy link
Author

jbao commented Dec 20, 2016

Hi @matthewwardrop , that's a great idea.

It seems that Travis doesn't like os.getlogin() though, with the automatic author rendering, I got the error

Inappropriate ioctl for device

This needs further investigation.

@matthewwardrop
Copy link
Collaborator

@jbao How are you getting on here? Does something like the following help?

import pwd
import os


def get_login():
    """
    Try to retrieve the user login to in a
    """
    try:
        user_login = os.getlogin()
    except OSError:
        user_login = pwd.getpwuid(os.geteuid()).pw_name
    return user_login

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

scripts/knowledge_repo Outdated Show resolved Hide resolved
@AppVeyorBot
Copy link

@mdshw5
Copy link
Contributor

mdshw5 commented Jun 7, 2021

@naoyak We're planning a deployment in our data science group, and the author and date templating are features we discussed as "nice to have", so I'm surprised to find that this functionality already exists in this pull request. Is there anything I can do to get this through the door and merged to master? Thanks!

@naoyak naoyak force-pushed the issue-103-dynamic-template branch 2 times, most recently from f5476e1 to a9960e7 Compare August 3, 2021 04:12
@naoyak naoyak force-pushed the issue-103-dynamic-template branch from a9960e7 to 6082211 Compare August 3, 2021 07:45
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

Successfully merging this pull request may close these issues.

Make templates more dynamic (user, dates, etc)
5 participants