How can I add a menu of local Trac projects to templates/site.html? - trac

I have multiple Trac projects with different environments on the same server. I would like to have a list of links to all projects at the top of each project page so I can quickly switch between them with out having to go up to the top level list at /projects/.
The ideal solution would:
not require loading all the Trac environments on every page load.
update automatically when a new project is added.
only require editing the config and/or templates or add a plugin.
work for Trac 0.11.

The NavAddPluggin allows the main trac navigation bar to be customized. You could add menu options for each trac of your projects. To add a new menu item the following is added to the trac.ini file.
[navadd]
add_items = project1
project1.target = mainnav
project1.title = Project One
project1.url = http://webserver/trac_project_1
To sort the order edit the mainnav option in the trac.ini
mainnav = project1,wiki,timeline,roadmap,browser,tickets,newticket,search

To answer the question of how to add a meny using site.html, here is a very basic top header to get you started - paste into the site.html placeholder:
<!--! A top header -->
<py:match path="body" once="True">
<body py:attrs="select('#*')">
<div id="top">
<a py:if="req.href() != '/one'" href="/one">one</a>
<a py:if="req.href() != '/two'" href="/two">two</a>
<a py:if="req.href() != '/three'" href="/three">three</a>
</div>
${select('*|comment()|text()')}
</body>
</py:match>
The example uses very simple logic and just hides the current project . You may want to do it differently, typically using highlighting or similar.
See Trac Layout Recipe for an advanced example. This is the layout in use at edgewall.org to switch between the various projects (Trac, Genshi, Babel, Bitten).

The method described by sudo_o is probably your best bet. It will give you something that is very well integrated into the Trac interface.
However, I wanted to mention a quick-n-dirty alternative that you may find useful. You can configure the logo in the upper-left corner of every Trac page to link to a specific page when clicked. Many Trac installations use this to link back to the start page. The link is configurable, however, and you can make it point to your project listing page. In your trac.ini file:
[header_logo]
src = site/your_logo.png
link = /url/to/projects/page
alt = Click to load projects listing
This method gives you easy access to your projects listing, and doesn't require adding any extra entries to your Trac menus. When you add or remove projects, you don't have to modify every trac.ini file to update the links. The downsides are that it takes an extra click to get to another project and that some users might not find this method as intuitive (setting the alt property helps with this a little).

Related

Display module fields in Sitefinity using conditions in the back end

I'm looking for a way to show module fields conditionally on the back end screen of Sitefinty.
For example, say I've created a module through module builder - and I have two fields: a checkbox and a text field.
I'd like the text field only to display to content editors only after they've checked the checkbox field. Ideally that checkbox could hide/show a handful of fields on the spot through the content entering process.
Is there a straightforward, maintainable way to go about this?
Currently using version 10.2, it'd be great to know how to accomplish
this via both the new and old UI.
Hoping there is an advanced setting I just don't know about, but
willing to go a JS approach as well.
Thanks!
After a little digging I've been able to find a working solution. Here's how I handled it:
Note: [module] and [section] assume your custom module name and section. If you didn't setup sections in backend screens and tweaks then all of the fields will be under MainSection
Step 1 - Add a custom script to the module in advanced settings.
Assuming this is a dynamic module...
Create a JS file in your project and reference it in advanced settings by going to:
Advanced settings > Dynamic Modules > Controls > [module] > Views > [Module]View > Scripts
Click Create New and point the script location to the JS file you created.
Step 2 - Add custom classes to your fields
Stay where you're at in advanced settings and navigate to the fields you've made. For example:
Advanced settings > Dynamic Modules > Controls > [module] > Sections > [Section] > Fields > [Field]
On this page scroll down to CSS Class and add a custom CSS class to this field
Step 3 - Add your custom Javascript
Sitefinity uses jQuery so I worked with that and set up some really basic JS based off the class names:
$(document).ready(function(){
$('.myTextBox').hide();
$('.myCheckbox input').on('change', function(){
var $this = $(this),
textBox = $('.myTextBox');
$this.is(':checked') ? textBox.show() : textBox.hide();
})
});
Note: the custom CSS class gets applied to the parent wrapper of the actual element
Now when a content editor goes to add a new content item to a module, checking that specific checkbox will show and hide the custom text box.
Besides the fact that this process seems a little over the top, there are a few other issues:
You have to set the call to your custom script on the edit and insert
view.
It doesn't take into account any validation.
With Sitefinity getting a backend UI upgrade, long term sustainability is questionable.
I'll leave this question unanswered for a while if there is a better/easier approach to this.

Modify Shopify Checkout page css

Based on answers to this question, I've added BOTH checkout.scss.liquid (for responsive checkout, which is what I am using) and checkout.css.liquid (when scss one failed to do anything) to Assets. According to the answers I found, Shopify will search for these filenames and include them on the checkout pages. This doesn't work for me.
One of these answers also included a screenshot of the Checkout settings page (Settings > Checkout > Customize checkout). The screenshot shows a lot more options than what I see. All I see are:
1) "Use a logo" drop down
2) Tagline
3) Order Summary and Text Entry Fields - Background
4) Colors - Accent
For example, the screenshot shows 3 options under Colors - Accent, Buttons, Call to Action. (would be nice to be able to change the button color without trying to get the css file to work)
You can't use custom CSS for the checkout unless you're in the Shopify Plus plan. More details at: https://help.shopify.com/themes/development/templates/checkout-scss-liquid
In all other plans you just able to use the options you see in your theme customizer (like you already named).

Flag module - link's position change (Drupal)

I've just installed Flags module and it looks awful when on the bottom I see "Flag this item" link. The only thing I've found in configuration is enabling it to show as normal link. Still I haven't found how to change position of this link. Is it even possible to change link's place? I have installed CCK Blocks but it doesn't give me any option to get rid of it. If someone know or suspect what's possible - please help me.
Try the Display Suite module, this module is integrated with many modules like flag, title etc...
Display Suite allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your
nodes, views, comments, user data etc. the way you want without having
to work your way through dozens of template files. A predefined list
of layouts (D7 only) is available for even more drag and drop fun!
https://drupal.org/project/ds
You can move and generate custom layouts for the fields/properties on the entity display formatter: teaser, full...

Alfresco Share site's dashlet for document library

I was wondering whether exists any dashlet which allows you to explore a site's document library. As far as I know doesn't exist such dashlet out of the box, there only exists the "Site Content" dashlet but it is slightly limited.
I have been searching around and "googling" and I found these useful resources that could be useful as a starting point if I had to create my own:
http://ecmarchitect.com/archives/2012/05/08/1592
http://code.google.com/p/fme-alfresco-extensions/wiki/GalleryPlusDashlet2
Do somebody know more dashlets/resources targeting this issue? Any suggestion?
As a temporary solution, I'm also thinking in the possibility of taking advantage of the "Web View" dashlet, by configuring in it such URL that retrieves the documentlist region/component in the documentlibrary page. For example:, share/page/components/documentlibrary/documentlist or share/page/site/{site}/documentlibrary?region=documentlist. Maybe it is crazy or what I'm saying doesn't make any sense, but it is just an idea.
Another idea that have just came to my mind is the option of creating a custom Surf/Share page which includes the component/webscript that implements the explorer of the document library, specifically the documentlist component. Then configure the "Web View" dashlet giving the URL that points to the custom page created. Would it make sense?
Thanks in advance.
You are going to see a couple of site visualization and navigation dashlets on Alfresco Visualization Tools available on https://github.com/bhagyas/alfresco-visualization-tools. The project is still at it's initial phase, but you will find interesting snippets of code used to retrieve the document library content trees within the dashlets.
The project was presented by me at Alfresco DevCon in Berlin just a week ago to bring interactive navigation and content analytics. If interested, you can find the slides at the lightening talk slides in the DevCon 2012 site at Alfresco.
Cheers! =)
Hi I've done exactly the same, it was not really needed for a Dashlet but for to embed the documentlibrary of a site in an iframe for another site.
So what I did was indeed create a new page template embedded-documentlibrary.
I've copied first the following files and renamed them:
site-data/pages/documentlibrary.xml
site-data/template-instances/documentlibrary.xml
site-webscripts/org/alfresco/documentlibrary.ftl
If you rename file 3 or put it in another folder, you need to check the paths in file 1 & 2.
So to make only the documentlibrary appear instead of everyting I just removed everything in file 3 within the <div id="alf-hd"> tag.
If you remove the tag, the document-tree will also be removed and it gave some javascript errors. This should be fixed in the latest version, but haven't tied that.
So it's extremely easy to create your own page and instead of navigating to site/documentlibrary you just navigate to site/embedded-documentlibrary or your own name you've chosen.
And yes then you'll need to use the web-view Dashlet to show it.
The only thing you need to know is, that the links open within the iframe. So if you use the web-view Dashlet, you need to open the links in a new window.
For my situation I needed an iframe, in your case you could also just let the freemarker from your Dashlet render the components needed.
There is a document-liberary-display dashlet available in the alfresco add-on list which can be used to show all the documents from document-library on site-dashlet.
http://addons.alfresco.com/addons/document-library-display-dashlet

adding "last edit time" to trac wiki pages

My organization has a sprawling wiki that isn't kept up to date very well. To reduce the danger of new people reading a page and not realizing how outdated it is, I'd like to modify the page header so that instead of
Page Name
at the top, it says something like
Page Name - last modified 5/8/10 by Joe
I see that Trac allows page templates, but if we haven't used those before, is there a 'blank' template I could alter to change all existing pages?
Unless you have changed something, Trac wiki pages should have a "Last Modified" entry in the top right-hand corner of each page. Hovering the mouse over different parts of the text will show you more details, like the user name of the last person to edit the page and a detailed timestamp of when the last edit was made. Is this different from the functionality that you are asking about?
You can put the following in site.html in the templates directory of your project directory:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:py="http://genshi.edgewall.org/"
py:strip="">
<!--!
This file allows customizing the appearance of the Trac installation.
Add your customizations here and rename the file to site.html. Note that
it will take precedence over a global site.html placed in the directory
specified by [inherit] templates_dir.
More information about site appearance customization can be found here:
http://trac.edgewall.org/wiki/TracInterfaceCustomization#SiteAppearance
-->
<div py:match="div[#id='wikipage']" py:attrs="select('#*')" once="true">
<h1>Last modified ${format_date(page.time)} by ${authorinfo(page.author)}</h1>
${select('*|text()|comment()')}
</div>
</html>
It doesn't add the last modified info into the title, but displays it before rendering the rest of the page. I don't think you can add it to the title without changing the code of how wiki formatting is rendered.
If you want the last modified date to be more visible, you can use the LastModifiedMacro. I'm fairly sure you could insert it into all existing pages with a simple script that read/writes to wiki table in the database, but I've never done anything like that myself. Take a look at the Database Schema, though keep in mind there may be a better way to do this through the Trac API.