Log In  |  
 
 

Testing VimColo[u]r

Here's a Perl script: #!/usr/bin/perl ############################################################################## # cookie_trail.cgi Version 1.0 # # Copyright 2000 Martin Burns scripts@easyweb.co.uk # # Created 19/9/2000 Last Modified 19/9/2000 # ############################################################################## # COPYRIGHT NOTICE # # Copyright [and -left] 2000 Martin Burns All Rights Reserved except as # # provided below. # # # # CookieTrail may be used and modified free of charge by anyone so long # # as this copyright notice and the comments above remain intact. By using # # this code you agree to indemnify Martin Burns and EasyWeb Design from any # # liability that might arise from it's use. # # # # This script is released under the GPL. # # Selling the code for this program or any derivative work is expressly # # forbidden. A full copy of the GPL can be found in the Code section of # # http://evolt.org. In all cases copyright and this header must remain # # intact. # ############################################################################## ############################################################################ # Some useful stuff # ############################################################################ # Gives better error messages - not that there should be any. A useful way # of increasing the size of your error log, anyway use diagnostics; # Ensures that the case swapping function works in all languages # (Exception: Beta-S in German) FOR VERSION 5.004+ only! #use locale; ############################################################################ # Define configuration constants # ############################################################################ # $URL_PATH is the path from the top of the URL tree - sticking it in a # normal variable for clarity $URL_PATH = $ENV{'DOCUMENT_URI'}; $REQUIRE_DIR = '/cgi-bin/'; @crumbs=''; @crumbs_path=''; $html=''; $TITLE=''; ############################################################################ # Get Required subroutines which need to be included. # ############################################################################ # Push the $REQUIRE_DIR onto the @INC array for include file directories. if ($REQUIRE_DIR ne '') { push(@INC, $REQUIRE_DIR); } # Require Necessary Routines for this script to run. require 'cgi-lib.pl'; ############################################################################ # Parse the arguments and output HTTP headers # ############################################################################ if (!&ReadParse) { print &PrintHeader, ""; } else { print &PrintHeader; } $TITLE = $in{'title'}; if ($TITLE) { $TITLE = '-> '.$TITLE}; ############################################################################ # Parses the path and dumps any trailing filenames (eg 'index.shtml') # ############################################################################ @crumbs = split(/\//, $URL_PATH); if($URL_PATH =~ /./) { pop(@crumbs); } ############################################################################ # Output the link # ############################################################################ for $i ( 1 .. $#crumbs) { # Each part of the link has to contain all the previous parts # separated by slashes of course $a = $i - 1; $crumbs_path[$i] = $crumbs_path[$a].'/'.$crumbs[$i]; # Capitalise the first letter of each part $crumbs[$i] = "\u$crumbs[$i]"; # using qq|foo| to get out of the way of quotes and slashes in HTML # using qq|foo|, not q|foo| to enable interpolation $html .= qq|-> $crumbs[$i] |; } $html .= $TITLE; print "$html\n"; Here's some HTML (actually, DTML from zope): Python #This script has been designed to send email to cmf users with appropriate #preferences. The script should be used in conjunction with the workflow tool. #parameters review_state # Set up a empty list of email addresses # loop through the portal membership, pass memberId to check for # Member role. If successful, check to see if the member has given # permission to send email, and an area of business interest that # coincides with a content keyword. If successful, append the # list of email addresses and send them email # Get the content object we're publishing contentObject = review_state.object # A nifty little function, which checks to see whether there are any elements # that match between two lists, and returns the number of matches. Result: if # the function returns 'true', you've got a match def isIn(list1, list2): y=0 for x in list1: if x in list2: y += 1 return y # Start with an empty list mailList=[] # Iterate through all the site's users for item in context.portal_membership.listMembers(): memberId = item.id # Remember that a real name is not mandatory, so fall back to the username if item.fullname: memberName = item.fullname else: memberName = memberId # Get a list of this member's interests... memberInterests = item.interest # ...and another that's the keywords of this object contentKeywords = contentObject.subject # Check to see if there's a match between the two isInterestedIn = isIn(memberInterests, contentKeywords) # This is the key condition: # If the user has the Member role and # we have an email address and # the user's interested in this content and # we have permission to email them if 'Member' in context.portal_membership.getMemberById(memberId).getRoles() and (item.email !='') and isInterestedIn and item.emailPermission: # add them to the list of people we're emailing mailList.append(item.email) # check that we can send email via the Zope standard Mail Host try: mailhost=getattr(context, context.portal_url.superValues('Mail Host')[0].id) except: raise AttributeError, "Cannot find a Mail Host object" # Let's write an email: mMsg = 'Dear ' + memberName + ',\n\n' mMsg += 'We thought you\'d be interested in hearing about:\n' mMsg += contentObject.TitleOrId() + '\n\n' mMsg += 'Description: \n' + contentObject.Description() + '\n\n' mMsg += 'More info at:\n' + contentObject.absolute_url() + '\n' mTo = item.email mFrom = 'you@yoursite.com' mSubj = 'New Content available' # and send it mailhost.send(mMsg, mTo, mFrom, mSubj) # The change in indentation signals the end of the loop, so we've # now sent all the emails. Let's now send a confirmation that we've done it. # We'll be building the email as a string again, but we have to convert our # list data elements into a string before we can append the information recipients = string.join(mailList, sep='\n') keywordsString = string.join(contentKeywords, sep='\n') mTo = 'you@yourdomain.com' mMsg = 'The following people were sent a link to\n' mMsg += contentObject.absolute_url() + '\n\n' mMsg += recipients + '\n\n' mMsg += 'The keywords were:\n' + keywordsString mSubj = 'Content announcement email confirmation' mailhost.send(mMsg, mTo, mFrom, mSubj) Java Borrowed from http://evolt.org/node/60512 package tmxtest; /** * Title: TMX Example * Description: Java Class to load text resources from TMX file * @author Nicola Asuni [www.tecnick.com]. * @version 1.0 */ public class tmxtest { /** * loads TMX data */ final static TMXResourceBundle res = new TMXResourceBundle("sample_tmx.xml", "en"); /** * Prints 2 strings on System.out * @param args String[] */ public static void main(String[] args) { System.out.println(res.getString("hello", "")); System.out.println(res.getString("world", "")); } }

Trackback URL for this entry:

http://islands.easyweb.co.uk/~martin/drupal/trackback/4

Post new comment

*
*
The content of this field is kept private and will not be shown publicly.


*

  • Glossary terms will be automatically marked with links to their descriptions
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>