In gitolite, any easier way to create exceptions to users of #all? - gitolite

For instance, in the repo PRJ, there are several groups, like #A1 #A2 #B1 #B2, UserX is in group #B1.
Now I want to add one rule for UserX, only allow him to modify the code in src/ folder, but do not apply this rule to others.
Is there any easier way to implement it?
#B1 = UserX UserY UserZ
repo PRJ
R = #A1 #A2
RW+ = #B1 #B2
RW NAME/ = #A1 #A2 #B2 UserY UserZ
#RW NAME/ = #all-UserX # like this?
RW NAME/src/ = UserX
- NAME/ = UserX

Gitolite follows a system of rule of accumulation
for each user+repo combination, several rules will apply.
Gitolite combines them all into one list (in the sequence they are found in the conf file), before applying the access checks.
for options and config lines, a later setting overrides earlier ones
There is a way of making deny rules easier to manage with the deny-rules directive, but it doesn't apply in your case.
This is closer to the rules you see in a delegation mechanism, and would be adapted in something like (not tested)
repo Prj
R = #A1 #A2
RW+ = #B1 #B2
RW VREF/NAME/src = UserX
- VREF/NAME/src = #all

Related

Append a number to a variable name in GDScript

I'd like to append an integer to the end of several variable names in GDSCript.
I'm working on a roguelike and I've decided to organise themed tilesets and NPC's and group them in folders by number (ie, theme 1 may be a crypt filled with undead, theme 2 a forest filled with animals).
The idea is that at the start of level generation I can randomly select a number, generate a level and fill it with corresponding enemies.
For example (assuming the random number is 1)
tileset_to_use = tileset_1
NPC_mid_boss = folder_1/mid_boss
NPC_end_boss = folder_1/end_boss
Aside from a series of nested IF statements along the lines of:
if RNG = 1:
tileset_to_use = tileset_1
NPC_mid_boss = folder_1/mid_boss
NPC_end_boss = folder_1/end_boss
elif RNG = 2:
tileset_to_use = tileset_2
etc...
...what would be a more efficient way of doing this? Something like tileset+RNG
I've looked into using dictionaries but, unless I've misunderstood them, they seem to be used for accessing values rather than generating variable names.
If all your themes share the same exact structure, you can do something similar to what Christopher Bennett proposes. Another option that may give you more flexibility, at the expense of possibly more repetition, is something like this:
# Defined at class level
const THEMES = [
# Theme 1
{
tileset = 'tileset_1',
NPC_mid_boss = 'folder_1/mid_boss',
NPC_end_boss = 'folder_1/end_boss',
# ...
},
# Theme 2
{
tileset = 'tileset_2',
NPC_mid_boss = 'folder_2/mid_boss',
NPC_end_boss = 'folder_2/end_boss',
# ...
},
# ...
]
func my_func():
# Pick a random theme
var theme = THEMES[randi() % THEMES.size()]
tileset_to_use = theme.tileset
# ...
This also allows you to add more properties like arbitrary strings (e.g. theme name) or other things, and can be externalized to something like a JSON document if you want. But again, it requires more manual setup.
Sorry, I think I misunderstood your question when I posted my first comment. Would something like this work?
var RNG = randi()%1-(total number of tilesets);
var tileset_to_use = (str("tileset_",RNG));
NPC_mid_boss = (str("folder_",RNG,"/mid_boss"));

DocumentHelper.GetDocuments().InCategories() API Method not working as intended

I am trying to get documents of given type with assigned category. This is my code:
var inCategoryDocuments = DocumentHelper.GetDocuments("XYZ.MyType").InCategories("CategoryCodeName");
It's result with this query:
SELECT * FROM View_CMS_Tree_Joined AS V WITH (NOLOCK, NOEXPAND) INNER JOIN xyz_MyType AS C WITH (NOLOCK) ON [V].[DocumentForeignKeyValue] = [C].[MyTypeID] AND V.ClassName = N'xyz.MyType' LEFT OUTER JOIN COM_SKU AS S WITH (NOLOCK) ON [V].[NodeSKUID] = [S].[SKUID] WHERE ([DocumentCulture] = N'en-EN' AND 0 = 1)
It looks like this API method (.InCategories()) doing nothing or I am missing something?
Kentico v11.0.26
Is this category assigned to specific site? If so, it wouldn't work, because in your query you didn't specify the site from which you want get documents.
You can simply add
.OnCurrentSite()
to your DataQuery, it will look like this
var inCategoryDocuments = DocumentHelper.GetDocuments("XYZ.MyType").OnCurrentSite().InCategories("CategoryCodeName");
It will retrieve the documents from the current website based on domain.
IMO method .InCategory shouldn't take care about site or it should be parametrized.
You need to include the using statement for it to work because those methods are extensions.
using CMS.DocumentEngine;

Fabric js select object in group

Is it possible to select a single object from a group created like this?
var r = new fabric.Rect(...);
var l = new fabric.Line(...);
var roadGroup = new fabric.Group([r,l],{ ... });
So I want to have a group, but select objects l or r separately.
The simple answer is yes, but you should make sure you take into account the purpose of a group.
To get a handle on an object that is wrapped in a group you can do something like this:
var r = roadGroup._objects[0];
var l = roadGroup._objects[1];
To select a child of a group try something like this:
fabricCanvas.setActiveObject(roadGroup._objects[0]);
soapbox:
The purpose of creating a group is to treat several objects as if they were a single one. The purpose of selecting an object is to allow user interactions with an object. If you want your user to interact with a portion of a group, you might want to consider not grouping them in the first place, or else un-grouping them prior to selecting the child object.
/soapbox
I believe _objects is to be used internally only and may thus change in the future.
To me it group.item(indexOfItem) seems to be the way
So I had this scenario where I have multiple images in a box. Those all images move along with the box (as a group) but user should also be able to select an individual image and move it.
Basically I wanted to select individual objects (in my case images) of group, I did it like this:
groupImages.forEach(image => image.on('mousedown', function (e) {
var group = e.target;
if (group && group._objects) {
var thisImage = group._objects.indexOf(image);
var item = group._objects[thisImage];//.find(image);
canvas.setActiveObject(item);
}
}));
groupImages could be list of objects which you want to select individually.

how to filter out content nodes with wintersmith static site generator?

In a Wintersmith application (node.js static site generator) I have several contents/articles that I want to pre-write.
I only want them to be generated when their metadata.date is in the past regarding to the date of generation.
How can you do this with Wintersmith ?
You have a couple of options. A simple yet hackish one would be to use filename templating and set the filename to something like draft.html and ignore it in some htaccess file.
in metadata: filename: "{{ (page.date>Date.now()) ? 'draft' : 'index' }}.html"
Another option would be to create a generator that populates a tree based on your conditions, check https://github.com/jnordberg/wintersmith/blob/master/examples/blog/plugins/paginator.coffee for a example.
Or you can subclass the MarkdownPage plugin and re-register it with your own custom additions, perhaps adding a draft property and a check in getView to send it to none if draft is true.
class DraftyPage extends MarkdownPage
isDraft: -> #date > Date.now()
getView: ->
return 'none' if #isDraft()
return super()
env.registerContentPlugin 'pages', '**/*.*(markdown|mkd|md)', DraftyPage
See:
https://github.com/jnordberg/wintersmith/blob/master/src/plugins/page.coffee
https://github.com/jnordberg/wintersmith/blob/master/src/plugins/markdown.coffee
Sure, you can go ahead and change the paginator file for this purpose -
getArticles = (contents) ->
# helper that returns a list of articles found in *contents*
# note that each article is assumed to have its own directory in the articles directory
articles = contents[options.articles]._.directories.map (item) -> item.index
#Add the following lines of code
articles = articles.filter (article) -> article.metadata.date < new Date
articles.sort (a, b) -> b.date - a.date
return articles
another hackish solution would be to have a subfolder call _draft, you could htaccess protect everything in that folder. When you want to promote it, just copy it into the correct location.
Not an exact answer to the question but solving a similar problem. I wanted to be able to set a draft variable on articles. The solution is similar to #Tushar:
getArticles = (contents) ->
# helper that returns a list of articles found in *contents*
# note that each article is assumed to have its own directory in the articles directory
articles = contents[options.articles]._.directories.map (item) -> item.index
# Filter draft articles
articles = articles.filter (article) -> typeof article.metadata.draft == 'undefined' or article.metadata.draft == false
articles.sort (a, b) -> b.date - a.date
return articles

Create user group as subgroup in WebSphere 7 (Portal)

In a portlet running on a websphere 7 portal server I want to create a new user group that is a subgroup of an existing group.
Here is the code (that I shortend as much as possible to keep the focus):
/* vars */
final PumaController controller = ...;
final PumaLocator locator = ...;
final PumaProfile pumeProfile = ...;
final groupCn = ... ;
/* code to add group */
final List<Group> parent = locator.findGroupsByAttribute("cn", CN_OF_GROUP);
final String parentDn = pumaProfile.getIdentifier(parent.get(0));
log.debug("creating new group with cn=" + groupCn + ", parentDn=" + parentDn);
newGroup = controller.createGroup(groupCn, parentDn, new HashMap<String, Object>(0));
The debug statement prints:
creating new group with
cn=[groupCn],
parentDn=cn=[CN_OF_GROUP],o=defaultWIMFileBasedRealm
The code DOES create a group. But it looks like the parentDN argument is ignored. The group is not created as a subgroup of parent, but it is created as a top level group. (Which is the same thing that happens if I pass null as parentDn).
What am I doing wrong here?
Probably nothing. I would raise a PMR if I were you.
If you configured federated security instead of standalone security please delete the file based realm by the way. You should always delete it when configuring federated security.

Resources