-
Notifications
You must be signed in to change notification settings - Fork 109
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
Adding support for DisplayModes for all .Net based templates and functions #4
base: master
Are you sure you want to change the base?
Conversation
@burningice2866 great job, impressive as always! P.S.Would you move CompositeC1Contrib to GitHub? |
Yay! Our first pull request on GitHub - thanks! Since this the first time we do this in a well functioning context (which CodePlex/TFS certainly wasn't) we try to learn a bit from this and expand the wiki on this topic. We are bogged down with full day training sessions this whole week, so we won't be able to dive deep into the changes before next week, but below are some initial questions and comments.
|
@aeont I'm usually more of a Mercurial guy, but I'm slowly getting the hang of Git so you might see C1Contrib here on GitHub before you know it :) |
@mawtex thank you your feedback, it will be a quick task to decorate it all with
I agree that the QueryString (qs) overrides for Mobile and Desktop is up for discussion, and frankly I would go with any suggestion you might come with. The reason for the LegacyC1DisplayMode, is because that the first versions of the implementation used "_" as separator, instead of "." which later became the default in WebPages. This code dates back more than 6 years, and the first public traces of it can be found here https://bitbucket.org/burningice/compositec1contrib/src/4b4df0e47040/Rendering.MasterPages/Web/MasterPageModule.cs?fileviewer=file-view-default#MasterPageModule.cs-65. Two years later, Masterpages and RazorFunctions was no longer a part of C1Contrib and the feature was requested on Codeplex (http://compositec1.codeplex.com/workitem/1711). It didn't catch much attention unfortunately, and was therefor maintained in a custom build of C1 - the infamous "acto build". |
…in case external function providers wants to utilize DisplayModes.
Since DisplayModeProvider is a public class included in the WebPages library, there is no need for C1 to provide a PrintMode out-of-the-box, since sites that need this, or other special modes, are able to add them manually.
I've removed the Print-mode, since sites that need such a mode are able to add them manually, using whatever querystring or other parameters of their choosing. |
@mawtex so whats the deal here
|
94c8d1f
to
f539610
Compare
…/Desktop displaymode
f539610
to
ba0df78
Compare
Sorry for the laggy response. Questions and comments: LegacyC1DisplayMode - I still have a problem understanding that name. Since you write it, I understand it makes complete sense to you, but for us and anyone else digging through our source code, what is this legacy thing? Is this a construct that exists to ensure backwards capability at your end? (why is this needed in our C1 core?). SpecialModesFileResolver in Composite.Core.Application - is this the right namespace (Composite.Core.IO or Composite.AspNet feels more appropriate?) and is this a descriptive class name? A quick read of the code give me the impression that a URL with ?mobile will trigger this feature - my plae for the use of a obscure word (c1device=...) was to ensure this feature is only triggered via this keyword and never ever inintended. Here my mode of thought is that I can imagine someone, sometime, somewhere make a feature where ?mobile is used, without actually wanting the rendering engine to change behavior. Right now both is supported? |
@mawtex this is not new code written in October but is several years old and is used on a numerous sites. Its no different than you having to support .aspx extensions and media urls formatted as In the same way, the official way to write a DisplayMode-file is The same goes for ?desktop and ?mobile. I'm fine with using for c1device= going forward, but backward compatibility still has to be maintained. Or not...? I understand that there comes a time in every software projects life where you remove old API's, so that could be now for this feature if you insist. Regarding the right namespace for the code, i'm fine with wherever it ends up since its not supposed to be used as a public api. |
If I understand you correctly, you suggest we pull in extra code/rules/complexity, so "official C1" is a better fit with the websites you have running on your branch of C1. While I can see this would save you some time when upgrading those sites to run on our branch, this is not really a "nice clean commit". From our point of view we get classes, logic and rules which are kind of marked "deprecated" before we add it. I will close this pull request without merging, but the core feature you are suggesting is super awesome and I would love if we can press "reset" and get this into the C1 core, in a way where we look at this as a "clean new feature". |
I clearly said that i'm fine by removing old backward-compatibility code, so i don't understand why you feel the need to close the Pull Request. Give me 20 minutes and that code is gone. |
Don't worry about "polluting the history". When all can agree on the final code, its normal practice to squash the commits into a single one which then gets merged. You can say a pull request is like pair programming... the code evolves by anyone giving their opinion and at the end its cleaned up and merged. ie. http://programmers.stackexchange.com/questions/263164/why-squash-git-commits-for-pull-requests and https://github.com/ginatrapani/todo.txt-android/wiki/Squash-All-Commits-Related-to-a-Single-Issue-into-a-Single-Commit |
@burningice2866 the pull request is reopened |
Thank you. I'll remove the last few backward-compatibility parts and change the namespace to |
Thanks for taking this time, appreciate it. My comments above was made after looking through half of the pull request, so rather than see it as a definitive list, see it as direction. |
…g and file naming.
Can you undo changes related to spaces so changes could be easier to trace? there are lots of them |
@kasravi if you're watching the diff via GitHub you can add w=1 as a querystring to the url, to ignore whitespace changes :) https://github.com/Orckestra/C1-CMS/pull/4/files?w=1 Pretty neat. |
Thank for taking time to do this. There are things you should consider.
|
|
…ver and moved it to Composite.AspNet namespace.
44a373c
to
1b03ba8
Compare
It is a lot easier to read on default diff viewers, when white space reformatting is avoided - so easier to read, by default - which I guess we all feel is a good thing. If you do not have a compelling reason to change white spaces, please don't. No need to fix it this time around, but please resist the urge to re-format (or - make pure "re-format" check-ins if we have something in dire need of it).
I think the point here was that your pull request only allows for two of those modes to be activated via the URL, while - as you say - there can be N. The alternative to "desktop/mobile only" is to come with a user agent string. Having a third option like "useragent;(user agent string)" could work and it would also work well with the device simulator in the C1 Console. Or can you see another way to 'open up' to more devices here? I'm also thinking we should require a user to be logged in, when overriding c1displaymode. Any reason we would expose this publicly? |
HttpContext.SetOverriddenBrowser is setting a cookie that last for 7 days I think, if you test your code with emulator and then switch back to normal would see the bug it creates. its better to clear this cookie at session end. maybe HttpContext.ClearOverriddenBrowser() could help you. Try to replace object type in Bindplaceholders with appropriate interface. yes it is easier and it works but it makes the code harder to maintain |
The reason for exposing c1displaymode is mainly to
@kasravi When using emulators you have no need to use c1displaymode, since you will present yourself as ie. an actual mobile device, so no issues there. |
We were primarily focusing on this feature in conjunction with the C1 Console browser's "device view" feature (the two really fit well together), but with a sticky cookie keeping browsers in the last selected mode I can see this make perfect sense as a public facing feature. If there was a switch in the URL (like "c1displaymode=adhoc;mobile") which allow this to happen on a "per request" basis, this could work in the console as well. Nice to have, since this is beyond the feature you are offering in the pull request. |
DisplayModes is a native part of WebPages and MVC so its only natural that Composite C1 also supports it for its Functions and Templates.
This pullrequest adds supports for the default file-resolving exposed by DisplayModeProvider.GetAvailableDisplayModesForContext (https://msdn.microsoft.com/en-us/library/system.web.webpages.displaymodeprovider.getavailabledisplaymodesforcontext(v=vs.111).aspx) to dynamically choose a different file at execution time based on the given HttpRequest.
Existing Functions and Templates works exactly the same way, but its now possible to add a .mobile.cshtml or .tablet.ascx next to the existing file, and this will then be used to service a given request, instead of the normal one.
Read more about DisplayModes here
The code in this Pull Request has been part of the Community Build for about 2 years so its well tested and used in various of live production sites.