Comments

Anonymous’s picture

Assigned: Unassigned » linclark

I'm a good way into coding this, so marking as mine.

Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new8.2 KB

This patch adds an overview of all mappings.

This is a dirty patch, it includes the patch from http://drupal.org/node/1106662#comment-4268006 so that you can see the overview. You actually have to type in /mapping at the end of the URL, though, to see the page.

Some things to consider:

  1. The links to the edit form for Comments does not work. Why is there an admin path set in the Comment entity if there is no admin form?... I have no idea. I also don't know why Taxonomy has no admin path set, catch says this is an oversight.
  2. Whether we want to provide an interface for changing the mappings of Other Template Variables. I think we do.
  3. Whether we want to allow users to add Other Template Variables. They would have to add the variable's mapping using code in preprocess, so this is less straightforward.
scor’s picture

# Whether we want to provide an interface for changing the mappings of Other Template Variables. I think we do.

I think it might be good to just stick with a read only listing at first. I'm thinking that building a UI for editing *any* RDF mapping would be a nice thing to have (editing not only the Field mapping but any attribute in an entity such as comment_count like we do in core with the RDF mapping API), but this could be added at a later stage with an overlay on top of that overview list for example.

Anonymous’s picture

I'm attaching a screenshot for discussion purposes.

In looking at this, I think it might be clearer if the 'Fields' and 'Other Template Variables' were both set to that light grey and all other rows had white backgrounds.

I'm fine with sticking to the read-only at first.

scor’s picture

I'm wondering if part of this code could be used for #1053928: Port site vocabulary functionality to Drupal 7, the site vocabulary is the same idea, except it's in RDF. Later we might be able to add RDFa to this page too :)

Anonymous’s picture

I guess some of the iterative code that gets all the fields for a bundle could be used... other than that, I'm not seeing where the overlap is, but I haven't worked on that like you have so I could be missing something obvious.

Currently this page is only shown to admins with RDF mapping premissions. I think it would only make sense to use RDF if we have a non-admin version. I think it does make sense to offer that, though, and we could reuse the code from this display. I think that it would have to be displayed at a different path, though.

If it is a standard page at a standard URI on all Drupal sites with this module enabled, we might even add some VoID about the site and make it an easy access point for those who want to know more about what data is exposed. This could actually be extremely useful, particularly for those trying to access data from other sites (say, using SPARQL Views).

If we can figure this out quickly, I'd love to have it coded for this weekend's Drupal Gov Days. I'm not going, but I know there will be a few talks about Linked Data stuff. I can dedicate time to working on this.

Anonymous’s picture

There could also be an interface that would generate export code for entities so that they could be automatically added as SPARQL Views resources on another site.

This would mean it would be as simple as pressing that button and importing the types you want, and then you could have immediate Views access to that external Drupal site... this sounds pretty rad to me!

scor’s picture

yes, it would have to be a non-admin path behind a permission. I was only thinking out loud here, not sure how much of an overlap there is. after thinking about this a bit more, there might not be enough overlap. The overlap is loading all entity types info and all fields info and foreaching them (only a few lines of code). The site vocabulary would display more data such as range, domain, field constraints, which might overload an "overview of all mappings for all bundles". I certainly do not want to block this issue because of that, so let's move this aspect in #1053928: Port site vocabulary functionality to Drupal 7, and keep the "overview of all mappings for all bundles" page simple for now.

dan7’s picture

hi,
i'm not sure how much functional schould be your patch, but for example when i try to edit RDF type or any Field of "Taxonomy term" it
shows an error >

Notice: Trying to get property of non-object in rdfui_admin_rdf_overview_form() (line 164 of C:\My_programs\wamp_real\wamp\www\drupal-7.0\sites\all\modules\rdf\modules\rdfui\rdfui.module).

is this behavior expected ?

Dan

scor’s picture

thanks for testing this @dan7. It looks like the taxonomy issue you're experiencing is the same as #905340: RDF UI doesn't work when mapping Taxonomy.

scor’s picture

Status: Needs review » Needs work

this will need to be rerolled to take the commit from #1106662: Provide all RDF configuration options in one section in Configuration into account.

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new7.19 KB

Rerolled with a small fix to make the mappings overview the MENU_DEFAULT_LOCAL_TASK...

Would it be better if there were a listing of all the tabs on the first page?

milesw’s picture

@linclark: This is looking great. Good call on the vertical tabs for entity types, I think it works quite well.

Yes, a listing page does seem necessary. It's awkward if you come through Configuration -> RDF publishing settings and hit the big mappings overview table. I'm going to try and put together a patch that includes a listing page, along with some other adjustments I have in mind.

Anonymous’s picture

Thanks for checking it out, Miles :) Here is another one with just the Fields and Other Template Variables headers shaded.

After looking through the other config pages, it turns out only two others use tabs (in core, at least), and neither of those two have an overview list. While I think that it is not optimal to have the entire RDF Mapping overview on the page, I'm tempted to follow convention. In this case, convention would mean we have a default local task, and I think that RDF Mapping Overview is a better default task than RDF Namespaces.

Perhaps there is another RDF config page we need, and if there is maybe it would be better as the default. Anyone have thoughts on other config pages we may need?

Anonymous’s picture

StatusFileSize
new7.55 KB

Gah! Here is the patch.

milesw’s picture

@linclark: Yeah, looking at this again, a listing page could just get annoying. A good rule of thumb seems to be ordering sub-pages (local tasks) by usage frequency. I can imagine the RDF mappings overview being very frequently accessed. Even if another RDF config page becomes necessary, I have a feeling the mappings page will still be the priority under RDF Publishing.

This patch reworks the formatting of tables on the mappings overview. The screenshot shows how they look. Some other changes include...
- Adding some hook_help text
- Added fragment IDs to 'edit' operation links so they open vertical tabs in the mapping UI
- Minor change to the namespaces page to get rid of E_STRICT warning
- Made some text more concise

milesw’s picture

Just noticed that edit links for Comment don't work properly and should probably be removed. I'll wait to hear some thoughts before rolling another patch.

milesw’s picture

StatusFileSize
new11.48 KB

...that patch included a bunch of whitespace which Git does not appreciate. Here's a new one without the whitespace.

Anonymous’s picture

Status: Needs review » Needs work

Some really nice improvements in there. For those watching at home, it also:

  • Uses real path instead of regex-ing the admin path like I did
  • Adds edit link for the title field, which is handled with the real fields in Field UI
  • Ensures RDF UI is enabled before outputing links to RDF UI pages

I like the new table structure, I think it is much clearer. However, I think that making the distinction between Fields and Other Template Variables is important. Fields can be added by the user and have RDFa output automatically. OTVs can only be added by a dev or themer and require their own RDFa handling. This confuses people like Earl Miles who couldn't figure out how the node template variables got their mappings, so I dont' think we want to conflate the two. What do you think? If you agree, then we could just put those headers back in there (and probably change the striping).

BTW, Miles, would you mind moving the namespace changes to another patch? We don't necessarily need another issue, but I'd like to keep the commits distinct (just to appease the version control angel on my shoulder).

Looking good!

milesw’s picture

Status: Needs work » Needs review

Sorry, I was being lazy with the namespace changes. I'll break those changes out into a new patch

Any ideas on how we could distinguish between Fields and Other Template Variables without adding labels inside the table? I really like how clean and easy to read it is without the labels. Another possibility is splitting them into two separate tables.

Do you have any links that might help to understand OTVs? Are they basically anything that is not a true Field API field? The term "template variables" seems misleading here. To me it suggests attributes only used for theme templates.

milesw’s picture

Status: Needs review » Needs work
StatusFileSize
new3.59 KB
new8.86 KB

Oops, didn't mean to change the status. Must have been because I still had the issue open in the browser.

This is the same as before, except changes to the namespace admin are broken out. If there is a better way to do it, please fill me in. I'm still getting the feel for version control.

Anonymous’s picture

Unfortunately, there is nothing that really documents the other template variables.

Basically, they are things that are added to $node by other modules using hooks. For instance, the user module adds the author's name and picture with hook_node_load. These are not actually registered as field values, so they are magic variables as far as the node object is concerned... they don't go through hook_preprocess_field, which is where the RDFa wrapper is set.

For the most part, users will be interacting with RDFa for fields. Advanced users could potentially figure out how to wrap magic variables in RDFa, but the focus of the work is on fields, which are generalizable. However, because in the particular instance of nodes the template variables are mapped and wrapped with RDFa by core, we want to display these in the table... and eventually add a UI for changing these mappings as well.

I think that splitting them into two tables would be somewhat confusing because we are using separate tables for separate bundles of an entity.

In the spirit of brainstorming, two ideas that are most likely really bad:

  • First column could have a rowspan, so there would only be two cells in that column. One is Fields, the other is Other
  • Make background colors slightly different between the two. IE faint blue tint to fields, faint green tint to variables
milesw’s picture

Thanks for clarifying things a bit, I've still got a lot to understand about how the pieces fit together. I'm glad you took care of all the logic for displaying these mappings. :)

Originally I made that first column heading "Fields and Attributes" and later changed it to "Fields". My thinking was that it's usually pretty obvious which items are fields added via Field UI or another module, and which items are special. Having 'real' fields sit at the top of the table definitely helps differentiate them.

I'm not so convinced we need to label the two different types of mappings. The label "Other Template Variables" may even cause extra confusion. If the concern is that people will question why those mappings are not editable, then we could address that in the help text at the top, maybe pointing to further documentation.

If you really think the labels are necessary, the rowspan idea might work. Relying on row striping seems risky because custom themes can look entirely different. What about adding a very short note in the operations column?

scor’s picture

Project: Resource Description Framework (RDF) » RDF Extensions
milesw’s picture

StatusFileSize
new10.08 KB

Re-rolled patch from #21

scor’s picture

Like I said in the call, "template variables" is not the right term for data which is available in entities independently from the theming layer (even if they get themed in template preprocess for the HTML rendereing). Entity API calls them "properties". Although that might be misleading for RDF people, we generally use the term "predicate" in the RDF mapping UI, so maybe that would not be a problem for non-RDF people (the majority of our users). Alternate terminology: attributes, metadata. Any other idea?

Anonymous’s picture

+++ b/rdfx.admin.incundefined
@@ -4,7 +4,157 @@
+  // Add a heading for the Other Tempalte Variables section of the bundle. This
+  // lists all of the mappings for template variables that are added through
+  // preprocess. In order to display RDFa for these template variables, the
+  // RDFa formatting must be added in the preprocess. For an example, see

So you are talking about this comment, correct? We need a better description of why a separate process is required for these variables.

Powered by Dreditor.

scor’s picture

I'm referring to the label "Other Template Variables" in the screenshot of #14. From the discussion we had today, there might not be such a label in this table after all, but I'm sure defining a terminology for "non-field fields" will be useful anyways for other places in the UI.

Anonymous’s picture

We'll be going with something more like the screenshot in #16, I believe.

I thought we decided not to explain the non-field field distinction in the UI but would leave it for documentation? That is, that there would be a link to a page on Drupal.org that explains that there are field predicates (and that RDFa for those get added automatically) and then there are these non-field predicates (and that you need to do special work to add those in the RDFa).

If you agree with that, I think that for the most part that discussion would be another issue. The only part in this patch that I think would be affected is the comment I posted and the one below... and possibly we'd want to come up with a better variable name than $fake_fields for the array of "template variables", but I think that variable name works for now.

+++ b/rdfx.admin.incundefined
@@ -4,7 +4,157 @@
+    // The bundle's RDF mapping array may contain mappings for content variables
+    // that are not fields. The bundle's field array may contain fields that are
+    // not in the RDF mapping array. In order to ensure we get all the available
+    // fields and all the mapped content variables, we compare the arrays.

Powered by Dreditor.

scor’s picture

yes, #16 and #29 look good.

Anonymous’s picture

I've created the other issue at #1174436: Document the difference between Field API fields and fake fields

I will try to rework the comment and will post a revised version of Miles's patch.

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new9.34 KB

First comment changed to:

+    // The bundle's RDF mapping array may contain mappings for entity attributes
+    // that are not fields. The bundle's field array may contain fields that are
+    // not in the RDF mapping array. In order to ensure we get all the available
+    // fields and all the mapped entity attributes, we compare the arrays.

Second comment changed to:

+  // Add any non-Field API entity attributes.
scor’s picture

Status: Needs review » Needs work

patching file rdfx.module
Hunk #1 succeeded at 58 with fuzz 2.
Hunk #2 FAILED at 104.

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new8.36 KB

Ok, this one should apply.

scor’s picture

This looks great!

Only minor points: There seems to be no ordering in the list of vertical tabs and the field names, the order seems random. IMO, it should either be consistent with the "manage fields" tab (with fake fields place last in alpha order), or all in alpha order.

How about offering a tooltip with the full URIs for CURIEs, or a link altogether?

Anonymous’s picture

Status: Needs review » Fixed

Talked with scor about it over Skype, we agreed that we could commit this and move the two comments to their own issue.

So... fixed with b4cb304! Thanks miles for the UI insight.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.