# Copyright 2006 by the LeMill Team (see AUTHORS) # # This file is part of LeMill. # # LeMill is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # LeMill is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with LeMill; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from OFS.SimpleItem import SimpleItem from OFS.PropertyManager import PropertyManager from Products.CMFCore.utils import UniqueObject from Globals import InitializeClass from AccessControl import ClassSecurityInfo from Products.CMFCore.utils import getToolByName from config import TYPE_NAMES, SEARCHABLE_TYPES, CONTENT_TYPES, COMMUNITY_TYPES, TOOLS_TYPES, ACTIVITY_TYPES, MATERIAL_TYPES, GOOD_STORIES_ONLY from permissions import MANAGE_PORTAL from itertools import chain from Products.LeMill.Resources import Resource from random import choice import datetime from DateTime import DateTime import time, re from Products.LeMill import LeMillMessageFactory as _ import sre from itertools import chain, dropwhile good_sites=["http://www.youtube.com/", "http://video.google.com/", "http://s3.amazonaws.com/slideshare/", "http://www.macromedia.com/go/", "http://odeo.com/", "http://fpdownload.macromedia.com/", "http://www.schooltube.com/", "http://maps.google.com/maps/", "http://ourmedia.org/players/1pixelout/audio-player.js", "http://channels.ourmedia.org/", "http://www.archive.org/"] urlfinder=re.compile(r"(http://\S*)", re.IGNORECASE) pattern=re.compile(r""" (?P(<|<)[a-z].*?>|(>)) # opening html tags, those that begin with ') # closing html tags, those that begin with '(?\[.*?\]) # everything that is put inside brackets |(?P\\\(.*?\\\)) # tex should be written inside \( ... \) |(?P\\begin\{(?P.*?)\}(?P.*?)\\end\{(?P=tex_tag)\}) # detect \begin{smthing}...\end{smthing} |(?P(?)\n.\n) # two linebreaks in a row make a paragraph. |(?P(?)[\n]) # detect linebreaks, unless they're after closed tag, f.ex !'
\n' |(?P[^ \t\n\r\f\v<>]{41}) # detect >40 char words, """, re.IGNORECASE | re.VERBOSE | re.MULTILINE | re.DOTALL) # whitelist is for html-tags only whitelist=re.compile(r""" (p |a |br |b |i |h2 |pre |li |ul |ol |table |tr |th |td |sub |sup) """, re.IGNORECASE | re.VERBOSE) restricted=re.compile(r""" (?Pimg) |(?Pembed) |(?Pobject) |(?P