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

Make custom themes work on microsites. #9282

Closed
wants to merge 1 commit into from

Conversation

mtyaka
Copy link
Contributor

@mtyaka mtyaka commented Aug 12, 2015

Background: Custom themes currently don't work on microsites. Custom theme only works on the base site (and only if there is no default microsite configured), while requests to microsites use the default edX theme with optional microsite template overrides. In most cases this is not the desired behavior - when you install a custom theme you will most likely want it to work on the base site as well as any configured microsites. Custom themes and microsites were previously discussed here. The discussion resulted in the patch at https://github.com/edx/edx-platform/pull/3495 which enabled microsite template overrides to work on sites with custom themes, but it has a side-effect of completely disabling custom themes on microsites. This patch enables custom themes on microsites while still allowing microsites to override specific templates.
JIRA ticket: https://openedx.atlassian.net/browse/OSPR-748
Partner information: not an edX partner - 3rd party-hosted open edX instance
Reviewers: @smarnach & TBD

This patch enables custom themes on microsites. Microsites can still override specific templates, although when a custom theme is enabled, microsites have to override theme templates (theme-header.html, theme-footer.html...) rather than default edX templates (navigation.html, footer.html...). I believe this makes sense since with a custom theme installed, microsites will be building upon the theme rather that the default edX look.

This patch also makes the main_django.html template custom theme friendly, so that custom themes don't have to override the entire file. It also makes the main_django.html template microsite override friendly.

Note that this change is NOT backwards compatible. If an Open edX instance was configured with both a custom theme and microsites, the microsites will start using the custom theme after deploying this patch, while they were using the default edX theme before the patch.
If desired, we could add a flag to microsite configuration to disable custom theme on the microsite level. I didn't implement it yet, because I'm not sure how useful that would be, but will be happy to do it if there is need for it.

To test this change, install a custom theme, for example https://github.com/Stanford-Online/edx-theme. Ensure that the custom theme is working, then configure a microsite (https://github.com/edx/edx-platform/wiki/Microsites-Theming). If you visit the microsite without this patch, you will see the default edX theme. If you visit the microsite with this patch applied, you will see the custom theme.

@openedx-webhooks
Copy link

Thanks for the pull request, @mtyaka! It looks like you're a member of a company that does contract work for edX. If you're doing this work as part of a paid contract with edX, you should talk to edX about who will review this pull request. If this work is not part of a paid contract with edX, then you should ensure that there is an OSPR issue to track this work in JIRA, so that we don't lose track of your pull request.

To automatically create an OSPR issue for this pull request, just visit this link: https://openedx-webhooks.herokuapp.com/github/process_pr?repo=edx%2Fedx-platform&number=9282

@mtyaka mtyaka changed the title (WIP) Make custom themes work on microsites. Make custom themes work on microsites. Aug 12, 2015
@mtyaka mtyaka force-pushed the mtyaka/microsite-themes branch from c737517 to 20d292b Compare August 12, 2015 08:38
@openedx-webhooks
Copy link

Thanks for the pull request, @mtyaka! I've created OSPR-748 to keep track of it in JIRA. JIRA is a place for product owners to prioritize feature reviews by the engineering development teams.

Feel free to add as much of the following information to the ticket:

  • supporting documentation
  • edx-code email threads
  • timeline information ('this must be merged by XX date', and why that is)
  • partner information ('this is a course on edx.org')
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will still be done via the Github pull request interface. As a reminder, our process documentation is here.

]
)


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: how about

return {"THEME_ENABLED": settings.FEATURES.get("USE_CUSTOM_THEME", False)}

or

return dict(
    THEME_ENABLED=settings.FEATURES.get("USE_CUSTOM_THEME", False)
)

just to reduce the number of parentheses a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote it that way to make it consistent with other functions in that file. Your comment encouraged me to change them all to use literal dicts.

@smarnach
Copy link
Contributor

The code looks good, and the patch very clean. Is there a way for me to test this with reasonable effort? Would I have to set up an installation with microsites myself?

@mtyaka mtyaka force-pushed the mtyaka/microsite-themes branch from 32de816 to c659164 Compare August 13, 2015 06:47
@antoviaque antoviaque mentioned this pull request Aug 13, 2015
21 tasks
@chrisndodge
Copy link
Contributor

@mtyaka @antoviaque hello, before I take a deeper look at this, I'd like to ask if OpenCraft is an operator of a microsite(s)? I ask this because @felipemontoya and I have been discussing some potential backwards incompatible changes to how configuration overrides are structured in order to make them a bit more consistent. So we wanted to see who are potential stakeholders.

@antoviaque
Copy link
Contributor

@chrisndodge We are only getting started now, we currently don't have a production website running microsites, only a staging one -- ie where we are currently trying to get the microsite and theming to work together : ) So it can definitely be good to be in the loop, but most likely bakward-incompatible changes would be fine until we get it in production on our side. I'll let @mtyaka comment though : )

@mtyaka
Copy link
Contributor Author

mtyaka commented Aug 13, 2015

@chrisndodge Backwards-incompatible changes are fine. We appreciate the effort to try to make microsite configuration more consistent.

@smarnach
Copy link
Contributor

@mtyaka Given that you are already testing this in real deployments, I don't think it's necessary for me to try and deploy microsites myself, so 👍.

@@ -21,6 +21,10 @@
{% block headextra %}{% endblock %}
{% render_block "css" %}

{% if THEME_ENABLED %}
{% include "theme-head-extra.html"|microsite_template_path %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an awkward usage pattern. Django's template lookup system is designed to handle the sort of directory lookup that the microsite.get_template_path() function does: just insert the directory at the front of the list of directories, and the template lookup system will find it first. For that matter, Mako's template lookup system is designed that way, too -- @nedbat and I are refactoring how this works in #8271. Could you take a look at what we're doing in that PR, and see if you can do the same sort of thing here? (Or we could just wait until it gets reviewed and merged, and then merge this in afterward.)

Also, you're doing a conditional include here. I think it would be better to do some kind of optional include: have the template system include the template file if it can find it, and if it can't find it, don't include anything. I implemented that in Mako in #8271, and I'm sure it would be possible to implement that in Django templates as well with a custom template tag.

@singingwolfboy
Copy link
Contributor

I've put this pull request into the "blocked by other work" state on JIRA: we don't want to merge this until after #8271 is merged. This pull request has some useful work in it that I'd like to integrate into our theming system, particularly the parts that touch Django templates (rather than Mako templates), but it'll be a LOT easier to handle after #8271 is merged.

@antoviaque
Copy link
Contributor

@singingwolfboy Now that https://github.com/edx/edx-platform/pull/8271 is merged, what is the next step on this? Would it be worth a quick re-review pass on this before @mtyaka adapts it to comprehensive theming, now that we know the outcome of https://github.com/edx/edx-platform/pull/8271 ?

@singingwolfboy
Copy link
Contributor

@antoviaque Unfortunately, we discovered some problems with #8271 when trying to release it to production on edx.org, particularly related to microsites. As a result, we're going to revert it for now, and try to get it back in for the next release to production. :(

@antoviaque
Copy link
Contributor

@singingwolfboy OK - good luck with the issues :/

@sarina
Copy link
Contributor

sarina commented Nov 3, 2015

Hi everyone - this is now one of our top 5 oldest PRs.

DB is working hard at making the theming stuff work, but this can't be reviewed until that happens. Further, this will need a lot of work I think to bring it up to speed.

My preference is that this PR is closed until we're ready to start reviewing it, and communication in the meantime (questions etc) be done on email. However if that's distasteful to you, so be it.

@mtyaka mtyaka closed this Nov 4, 2015
@mtyaka
Copy link
Contributor Author

mtyaka commented Nov 4, 2015

I closed this PR for now, will reopen when the new theming stuff is merged. This PR will probably have to be changed significantly to work with new theming anyway, so it doesn't make much sense to keep it open in its current form.

@antoviaque
Copy link
Contributor

@sarina @mtyaka Since this is an active issue for us to have this working, even if we closed it in the meantime we would still have to track it. From prior experiences with PRs closed "temporarily", they tend to be forgotten upstream. I've seen that Matjaz just closed it, but I'd rather reopen it if possible to reflect the current status on this - would you mind?

@sarina
Copy link
Contributor

sarina commented Nov 4, 2015

@antoviaque I have the same experiences w/ PRs that stay open - they get very stale, and the only action that happens is the literally weekly checking I have to do to see what the status of the PR is. From that perspective, I prefer having PRs that aren't being actively worked on or reviewed/waiting for review not be a thing that has to take energy every week.

I guess I also don't see how it being open and stale reminds you that it still needs to be done, over active tickets on your issue tracker. But, all that said, if you think it's valuable to have it open, perhaps the PR can be open but a new OSPR ticket could be made when it's time to kick the tires again?

@antoviaque
Copy link
Contributor

@sarina Ah, I see what you mean. That makes sense for me to save your the weekly work. How will we know that it's the right time to reopen it, though? I've a bit lost track of the status of the dependencies on this, with the merges & revert - would someone think of letting us know, if you're not checking on this PR anymore?

@sarina
Copy link
Contributor

sarina commented Nov 5, 2015

@singingwolfboy can you please make a jira task to loop back on this PR
with Xavier and team when appropriate?

On Thu, Nov 5, 2015 at 3:12 AM, Xavier Antoviaque notifications@github.com
wrote:

@sarina https://github.com/sarina Ah, I see what you mean. That makes
sense for me to save your the weekly work. How will we know that it's the
right time to reopen it, though? I've a bit lost track of the status of the
dependencies on this, with the merges & revert - would someone think of
letting us know, if you're not checking on this PR anymore?


Reply to this email directly or view it on GitHub
https://github.com/edx/edx-platform/pull/9282#issuecomment-153983584.

@antoviaque
Copy link
Contributor

@sarina @singingwolfboy Perfect - that would work well. Thank you!

@antoviaque
Copy link
Contributor

@singingwolfboy @mtyaka Now that comprehensive theming is merged, will it be a good time to resurrect this PR? If so we'll try to schedule this in an upcoming sprint.

CC @bradenmacdonald

@antoviaque
Copy link
Contributor

@singingwolfboy @sarina Ping : )

@sarina
Copy link
Contributor

sarina commented Dec 14, 2015

Hi @antoviaque I assume now is the right time, but I would recommend to rebase the branch and open a new PR.

@antoviaque
Copy link
Contributor

@sarina Sounds good, we'll do it like that, and schedule the work for one of the upcoming sprints. Thanks!

@mtyaka
Copy link
Contributor Author

mtyaka commented Jan 4, 2016

We tested comprehensive theming with microsites and found out it works well on microsites. Adding microsite support to the deprecated stanford system doesn't make sense anymore, so we are done with this issue.

@bradenmacdonald bradenmacdonald deleted the mtyaka/microsite-themes branch January 12, 2022 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked by other work PR cannot be finished until other work is complete open-source-contribution PR author is not from Axim or 2U
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants