So i have massively reworked the import/export code to use CTools export.inc. This has the nice advantage of making skinr code simpler and providing a means to provide default skins.
so as example
function my_module_ctools_plugin_api($module, $api) {
if ($module == 'skinr' && $api == 'skinr_skins') {
return array('version' => 1);
}
}
function my_module_skinr_default_skins() {
$skinr = new stdClass;
$skinr->disabled = FALSE; /* Edit this to true to make a default skinr disabled initially */
$skinr->api_version = 1;
$skinr->name = 'garland:block:user-0';
$skinr->theme = 'garland';
$skinr->module = 'block';
$skinr->sid = 'user-0';
$skinr->skins = array(
'block_border' => array(
'bordered-block border-top' => 'bordered-block border-top',
'bordered-block border-left' => 'bordered-block border-left',
),
);
$skinr->settings = array();
$skins[$skinr->name] = $skinr;
return $skins
}
You can edit them, delete / revert them, export and import them. The one bad part about this patch as I have remove the Bulk Export. I would like to bring that back in but by leveraging CTools Bulk Export. Im hoping that can be a continuation patch.
This should not affect creating skins at all it just produces a 'meld' of exported skins and skins in the database. It does change the output of skinr_get() for when not all the variables are provided ($theme, $module, $sid). If one or more aren't present, the returned result isn't the same as it used to be. If thats an issue then it can be reworked to behave exactly the same.
| Comment | File | Size | Author |
|---|---|---|---|
| #51 | skinr-features_support-744706-51.patch | 118.16 KB | moonray |
| #47 | skinr-features_support-744706-47.patch | 108.09 KB | moonray |
| #43 | skinr-features_support-744706-43.patch | 10.04 KB | moonray |
| #46 | skinr-features_support-744706-46.patch | 32.79 KB | moonray |
| #35 | 744706.patch | 4.45 KB | ericduran |
Comments
Comment #1
Scott Reynolds commentedfound another bug, it seems that when you use the click sortable table it fails to find the default ones. This is because the click sortable header uses SQL. that will need to be reworked and might be worth stealing some code from Views for that.Actually thats not true, it works just fine I just had a typo in a function name.
Comment #2
Scott Reynolds commentedd.o swallowed my patch
Comment #3
Scott Reynolds commented...doh! have an error in that patch.
should be
Comment #4
jacineI don't fully understand the implications of this patch, but I wanted to chime in with a few things:
First off, thanks so much for posting this patch.
It also makes changes to the data structure. I am not personally tied to the current structure (though moonray might be), but given how far along we are into 6.2, and where this stands, I wonder if we are better off postponing this until the next version.
Comment #5
Scott Reynolds commentedThe only change to the data structure is one field that is concat of the previous primary key. And the only reason for it is so it has a name field that can be used as one field in CTools.
Bulk Export "works" in this sense
Basically, its equivalent of Views export that you do per View.
So this isn't true in the sense i *THINK* you are thinking. There can be multiple skins defined by one module and each time you build a skin you can export it into that module. Just no easy way as it stands to export 5 at one time. Just export each one individually. And I don't think I have ever used a bulk export, I have found it bulky and besides I make small changes all the time. Individual exports are more important IMHO. But if you view it as a requirement, I can write it fairly quickly.
Well, CTools is pretty light weight it would only use the Export part of it. CTools is already a requirement for UI (via Dialog). And I actually don't use Panels yet I use CTools all the time so I challenge your assertion. CTools handles complicated task of handling the meld between database and in code. That is a lot of code you don't have to write and maintain, and you get all the features of Panels exports. Seems to make a ton of sense to add it as a dependency and its not being abandoned anytime soon ;-).
To move forward on this patch.
Comment #6
jacineMaybe "useless" is a bit strong, but exporting one-by-one is (a) a regression and (b) not something most use cases will call for.
In Drupal 7 we don't have a CTools dependency anymore, so I'm hesitant about adding it back. This isn't a deal breaker, just something that needs to be considered.
Like I said - I do like the idea of this patch. I'm not against it; it's just late for this release and it needs a decent bit of work still. We are looking at wrapping things up for this release over the next couple of days.
Comment #7
Scott Reynolds commentedReally? In my use of skinr this is exactly what I needed. I added a skin to a View, I don't want to export all of them, just the one I just applied.
Comment #8
jacineI'm sorry, but I'm really not interested in arguing about this.
Show me a fully working patch that doesn't take away current functionality and we'll talk.
Comment #9
sinasalek commentedsubscribed. I think this a very useful feature.
Comment #10
ericduran commentedI'm working on the same things, except I'm only doing the skinr rules. The reason why I started with the rules is because that's a lot easier to to make exportable being that we can easily add the machine name to the skinr rules form that's already there.
Also I don't think ctools needs to be a requirement, the ctools code could had been wrapped around in a module_exists that way skinr can still fall back to it's regular ways if ctools is not available.
Also the big problem is really exporting skinr settings for blocks. I'm sure it'll work fine with Views blocks because views uses machine names but Drupal blocks don't play well with exportables because of their auto increment value. They're already multiple projects trying to solve this very same problem so maybe there should be a consensus on which route to go.
I think this is a good start but there has to be more discussing on which route to take regarding exportable for blocks settings. Just my thoughts :-)
Comment #11
jensimmons commentedSubscribe. Yeah, we need exportables on Skinr in order to use it to move sites from one build server to another. It's pretty important. IMO, requiring CTools is no big deal. And using CTools to make exportables easy is one of the current best practices.
If we want to let people who don't need exportables be able to use Skinr without CTools, then perhaps we make the exportable support a separate module inside the Skinr module package. Views for instances is actually 3 modules in 1: Views (core), Views exportables, and Views UI. If we have Skinr, Skinr UI, and Skinr exportables, then only Skinr exportables could require CTools. And we could have the best of both worlds. Features support for largers sites, and simplicity for smaller sites.
Without solid exportables and support for Features, Skinr won't be as awesome as it should be.
Comment #12
moonray commentedIf a patch is submitted for a separate skinr_exportables module, I'll be happy to include it in skinr's package.
Comment #13
ericduran commentedMoonray, that sounds great. Anyone want to work on this with me? I might not have time till this weekend but maybe we could move the dev to github in the time being until is stable to be committed to skinr?
Comment #14
ericduran commentedIf anyone is interested. I started working on this as a separate module. It's no where near being completed yet but if anyone wants to help out I'm working on github (until is ready to be contributed back here). url: http://github.com/ericduran/skinr_export
Right now all it does is exposes the skinr table to ctools so it can be exported using features or ctools bulk export module.
The missing feature is getting skinr to read the exported data. This might end up being a tiny patch to skinr, but not sure yet. I haven't started working on that part yet.
Comment #15
ericduran commentedJust a quick follow up. I believe the skinr_export (http://github.com/ericduran/skinr_export) is in pretty good shape. Any testers? The one feature that I know is missing is the exporting of page rules. I'm working on that now. I'll post a follow up here when I get that done. When is ready and tested I'll post a patch here so more people can test.
Comment #16
jacineComment #17
jacineComment #18
dstol@ericduran It would be helpful to have some documentation here as to how to use and expected results.
I guess, just looking at the gui, I'm missing that things have changed. I see your hook_form_alter, I just don't see anything different from what's expected in 2.x-dev.
Comment #19
ericduran commented@dstol, Thanks for reviewing.
So the skinr export module doesn't do much on it's own. It really just exposes Skinr settings to either Features or Ctools Bulk export. Or any other module that implements the hook_default_skinr_skins.
I'll see if I can record a video or put up a blog post showing what this module does.
@jacine this actually brings up a good question. Should the exporter in skinr be remove? or even better replace with this one? It's a lot easier to implement the exporter using ctools (this one currently doesn't have a exporter ui but it can get one ;-) ). So in other words this module will still be separate from skinr but it'll provide a ui for exporting skinr settings using ctools, and it'll also have Features support.
This might be to ambitious for 2.x release. But let me know.
Comment #20
ericduran commentedComment #21
jacine@ericduran, it should replace the existing export functionality (definitely needs a UI), and is fine in a separate module.
It's not too ambitious, IMO. If you get it working, and we can get a few people to test it, I'll happily commit it! ;)
Comment #22
ericduran commented@jacine, cool. Working on it now.
Comment #23
ericduran commentedHa, so after writing all the code, I really dislike the implementation with the separate module :-/. It just add so much extra complexity for something that should be simple or at least not as complex.
Also after working on this, I've notice that skinr has ctools function sprinkle around it.
Here's my Proposed Plan:
- Make the skinr.module support exportable using ctools without exportable api without explicitly requiring ctools. So in other words if it's there we'll use it if not, we don't do anything. This is nice because you won't need to enable skinr and an extra module just to load your exported skins.
- Replace parts of the skinr_ui.module with ctools export_ui. This would ideally lower the amount of code in skinr_ui and there's no need for an extra dependency since ctools is already required by skinr_ui since it's a dependency fo dialog.
That being said I'm going to work on these issue each individually and create patches in separate issues. I just think it makes more sense than trying to get one big patch in at once.
Hope this is ok? All comments welcome.
Comment #24
ericduran commentedComment #25
moonray commentedericduran: Considering the things you've mentioned above, I have no problem with your proposed way of implementing things.
Comment #26
ericduran commentedI'm moving this to 7.x I still plan on fixing this
Comment #27
jacineChanging title and priority.
Comment #28
simeHey ho. It might be useful to know that Views 3 for Drupal 7 is dependent on ctools. So pretty much every site will be running ctools.
Comment #29
neurojavi commentedAny news about this?
It would be very useful to have features support in the 7.x-2.0 version...
Many thanks!
Comment #30
rickvug commentedsub.
Comment #31
moonray commentedPerhaps we can take another swing at this now that our Skin Configuration data structure has solidified?
Comment #32
aquariumtap commentedSo what needs to be done here? ericduran built a separate module but wasn't happy with the end result. It sounds like the next step was to strip out any existing import/export functionality and replace it with ctool exportables. Is that right? @ericduran, do you have any suggestions?
Comment #33
moonray commentedSome of the stuff that made ericduran unhappy is probably gone now (I hope).
If someone could tell me how much code would be eliminated by NOT having a separate module for skinr export functionality, that would help make a decision whether to create a new module or not.
Comment #34
ericduran commentedThe separate module was for an earlier version of skinr, so I'm sure that's completely unworkable now.
I haven't check out skinr in a while, but I might just give this a try again this weekend and see how it turns out.
/me starts now!
Comment #35
ericduran commentedOk, here goes a 1st pass at making skinr rules exportable.
This doesn't add any dependancies and support exporting out your rule when using feature.
This patch does not contain an update hook, so it will require a clean install.
Hmm, we'll this is pretty much it for the rules, now we need to do the skins ;)
Comment #36
rickvug commented@ericduran Your patch in #35 is working with Features directly rather than CTools export.inc. Is there a particular reason for taking this direction? Aside from having (awesome) exportables support I was hoping that using exportables would allow skin configuration to be read from disk rather than the database, saving the many queries that Skinr creates.
Let me know your thoughts. Either way thank you for your work on this.
Comment #37
ericduran commented@rickvug, Hey,
So yea, in all the other patches I was trying to make skinr work with ctools instead of features directly and in this patch I took the complete opposite approach.
There's a couple of reasons for that.
- Skinr is using auto-increment ids (I didn't want to rewrite the schema).
- I found it easier to just add a machine_name and do matching of that, instead of trying to actually make the skinr schema exportable.
- I wanted to make the patch as light as possible. I didn't want to make one big patch, especially since I wasn't involve in most of the drupal 7 rework I didn't want to just jump in here and be like hey, here's a 300 line patch.
There was a couple of other reasons, I don't remember all of them right now.
The patch above works with Skinr Rules. I'm going to make another one for skins. But I wanted to separate them out, since they are essentially two different task.
But all in all, the Patch above should work great with Skinr Rules. Skinr skins coming soon ;)
Comment #38
rickvug commented@ericduran Thank you for giving the background. I completely respect not wanting to rip-apart too much of Skinr to make the change. At the same time I'm also wondering if the change would be worth the effort and if now is the right time for API changes. I think everyone would rather have Features support than nothing and you're the one taking the time on the patch so I'll leave it at that! Thanks again for your work here.
Comment #39
moonray commentedOnce #1007482: Make use of Context API instead of custom rules goes in we'll have nailed down our whole db/objects structure. We can then create an import/export scheme that will no longer need to be changed.
Comment #40
jurriaanroelofs commentedAny updates on this? I'm planning to release a dashboard module that uses skinr to manage it's layout so I'll have to somehow include the skinr configuration in the module.
Comment #41
moonray commentedNo updates on this one. It's a bit of a beast to tackle.
Help on getting CTools exportables would be appreciated. :)
Comment #42
gints.erglis commentedImporting Skinr settings with Features.
1. In the file myfeature.install
2. Create folder 'skins' next to myfeature.install file and put exported skinr code in the myfile.inc
Comment #43
moonray commented@ericduran, @Scott Renolds: Apologies for this taking so long that your code became outdated.
Attached patch adds basic features support for Skin Configuration objects (applied skins).
Still to do:
Add testsImplement features support for Skin Configuration Groups (Skinr Context module)Related: #1163676: Allow cloning of exisitng skin configuration to apply to another theme
EDIT: Note that I've chosen to copy uuid.inc from UUID module, rather than depend on UUID module; we want to keep dependencies to a minimum, and UUID module (like CTools) does a lot more than we need it to. Additionally, with UUID coming to core in D8, I feel using UUID for skin configurations is the right way to go here.
Comment #45
moonray commentedLooks like the tests failed due to a stray dpm() stuck in there somewhere. Otherwise the patch is good.
Comment #46
moonray commentedAttached patch adds in support for features for the skinr_context module. It includes tests for the changes made to skinr_context as well.
Comment #47
moonray commentedI've updated the patch with the following changes:
$group->gidto be a machine name instead of adding a new machine_name field; the latter complicated matters needlessly.Comment #49
moonray commentedRe-review failed test due to test system bug.
Comment #50
moonray commented#47: skinr-features_support-744706-47.patch queued for re-testing.
Comment #51
moonray commentedFixed a few more bugs and added more tests.
Comment #52
moonray commentedCommitted. See http://drupalcode.org/project/skinr.git/commit/cfe800a