def tao_tin_tim_mua(): from plugin_ckeditor import CKEditor table = cms.define_table('tintuc') for field in table.fields: if field == 'htmlcontent': table[field].label = 'Nội dung tìm mua' if field == 'folder': table[field].default = 248 table[field].readable=False table[field].writable=False row = db(db.dfield.name==field).select().first() if row: if row.ckeditor: table[field].widget=CKEditor(db).widget form=SQLFORM(table) if form.process().accepted: from plugin_process import ProcessModel objects = ProcessModel().define_objects() objects_id = objects.insert(folder=248,foldername='san-pham-tim-mua',tablename='tintuc',table_id=form.vars.id,auth_group=7,process=1) # link = form.vars.name.replace('đ','d') # link = '%s.html'%IS_SLUG.urlify(link) # dcontent = cms.define_dcontent() # dcontent.insert(folder=248,dtable='tintuc',table_id=form.vars.id,link=link,name=form.vars.name,avatar=form.vars.avatar,description=form.vars.description,publish_on=request.now,expired_on=None) # cms.db(tin_tuc_edit.id==form.vars.id).update(link=link) session.flash = T('Gửi thông tin tìm mua thành công') redirect(URL(c='portal',f='folder',args=['san-pham-tim-mua'])) response.view = 'layout/home_dang_tin-tim-mua.html' return dict(content=form)
def set_fixtures(self): ckeditor = CKEditor() self.db.article.description.widget = ckeditor.widget # virtual field <3 self.entity.embed_code = Field.Virtual(lambda row: self.get_embed_code( row.video_data.video_source, row.video_data.video_height, row. video_data.video_width, row.video_data.video_embed))
def contact(): id = 90 from plugin_ckeditor import CKEditor box = cms.define_box() box.htmlcontent.widget = CKEditor(cms.db).widget box.name.writable = False box.id.writable = False box.id.readable = False box.boxtype.writable = False box.boxtype.readable = False box.avatar.writable = False box.avatar.readable = False box.link.writable = False box.link.readable = False box.setting.writable = False box.setting.readable = False box.textcontent.writable = False box.textcontent.readable = False form = SQLFORM(box, id) div = DIV(_class="panel panel-default") div.append(DIV(T('Thông tin hỗ trợ trực tuyến'), _class="panel-heading")) div.append(DIV(form, _class='panel-body')) if form.process().accepted: response.flash = T('Cập nhật thành công.') response.view = 'plugin_manager/index.html' return dict(content=div)
def set_properties(self): ckeditor = CKEditor() T = current.T self.fields = [ Field("price", "double", notnull=True, default=0), Field("manufacturer", "string", notnull=True), Field("in_stock", "boolean", notnull=True, default=True), Field("quantity", "integer", default=1), Field("info", "text", notnull=True), Field("option_fields", "list:string"), Field("extra_fields", "list:string"), ] self.validators = { "info": IS_NOT_EMPTY(), "manufacturer": IS_NOT_EMPTY(), } self.widgets = {"info": ckeditor.widget} self.labels = { "price": T("Product Price"), "manufacturer": T("Manufacturer name or brand"), "in_stock": T("Available?"), "info": T("Product specs"), "quantity": T("Quantity in stock"), }
def set_properties(self): ckeditor = CKEditor() T = current.T self.fields = [ Field("price", "double", notnull=True, default=0), Field("manufacturer", "string", notnull=True), Field("in_stock", "boolean", notnull=True, default=True), Field("info", "text", notnull=True), Field("product_size", "string"), ] self.validators = { "info": IS_NOT_EMPTY(), "manufacturer": IS_NOT_EMPTY(), "product_size": IS_EMPTY_OR( IS_IN_SET([("L", T("Large")), ("M", T("Medium")), ("S", T("Small"))], zero=None)), } self.widgets = {"info": ckeditor.widget} self.labels = { "price": T("Product Price"), "manufacturer": T("Manufacturer name or brand"), "in_stock": T("Available?"), "info": T("Product specs"), "product_size": T("Product size"), }
def _(): plugins = PluginManager('text', app=None) if plugins.text.app is not None: # this will register the content/type on the application plugins.text.app.registerContentType('text', ContentText()) if not hasattr(db, 'plugin_text_text'): # configure ckeditor editor = CKEditor(db=db) # definimos la BD tbl = db.define_table( 'plugin_text_text', Field('byline', 'string', length=250, default=''), Field('body', 'text', label=T('Content')), Field('item_id', 'string', length=64), auth.signature, ) tbl.byline.label = T('By line') tbl.item_id.readable = False tbl.item_id.writable = False tbl.body.requires = IS_NOT_EMPTY() tbl.body.widget = editor.widget # enable record versioning tbl._enable_record_versioning() return
def edit_tin_tuc(id, cms, folder_id_ivinh): request = current.request T = current.T from plugin_ckeditor import CKEditor tin_tuc = cms.define_table('tintuc') tin_tuc.folder.default = folder_id_ivinh tin_tuc.folder.writable = False tin_tuc.folder.readable = False tin_tuc.htmlcontent.widget = CKEditor(cms.db).widget form = SQLFORM(tin_tuc, id) ajax = "ajax('%s', [''], 'news_detail')" % (URL( r=current.request, c='plugin_app', f='act_delete', args=[request.args(0)], vars=dict(table_name='tintuc', table_id=id))) form[0][-1] = TR(TD(INPUT(_type='submit', _value=T('Submit')), INPUT(_type='button', _value=T('Xóa bài viết'), _onclick=ajax, _class='btn btn-danger'), _colspan="3"), _class='act_ivinh') if form.process().accepted: current.response.flash = T('Cập nhật thành công.') return form
def define_comment(self, migrate=False): if 'tcomment' in self.db.tables: return self.db.tcomment from gluon.dal import Field from plugin_ckeditor import CKEditor ckeditor = CKEditor(self.db) return self.db.define_table('tcomment', Field('tablename'), Field('table_id', 'integer'), Field('objects_id', 'integer'), Field('procedures', 'integer'), Field('process', 'integer'), Field('auth_group', 'list:integer'), Field('txtcontent', 'text', length=16777215, widget=ckeditor.widget), Field('created_by', 'integer', default=self.auth.user_id or 1, writable=False, readable=False), Field('created_on', 'datetime', default=current.request.now, writable=False, readable=False), migrate=migrate)
def view_san_pham(): san_pham_id = request.vars.san_pham_id div = DIV(_class='col-md-12') folder_id_ivinh = folder_id_gian_hang.id if auth.has_permission('quan_tri_gian_hang', 'folder', folder_id_ivinh): name = request.args(0) from plugin_ckeditor import CKEditor san_pham = cms.define_table('san_pham') san_pham.folder.default = folder_id_ivinh san_pham.folder.writable = False san_pham.folder.readable = False san_pham.r_folder.writable = False san_pham.r_folder.readable = False san_pham.htmlcontent.widget = CKEditor(cms.db).widget form = SQLFORM(san_pham, san_pham_id) if san_pham_id: ajax = "ajax('%s', [''], 'news_detail')" % (URL( c='plugin_app', f='act_delete', args=[request.args(0)], vars=dict(table_name='san_pham', table_id=san_pham_id))) form[0][-1] = TR(TD(INPUT(_type='submit', _value=T('Submit')), INPUT(_type='button', _value=T('Xóa sản phẩm'), _onclick=ajax, _class='btn btn-danger'), _colspan="3"), _class='act_ivinh') if form.process().accepted: print 123 div.append(form) response.view = 'plugin_app/view_new.%s' % request.extension return dict(content=div)
def start(self): from movuca import DataBase, User, UserTimeLine, UserContact, UserBoard from datamodel.article import Article, ContentType, Category, Favoriters, Subscribers, Likers, Dislikers, Comments from datamodel.ads import Ads from datamodel.contenttypes import Article as ArticleData from datamodel.contenttypes import CookRecipe, CookRecipeBook, CodeRecipe, Product from datamodel.notification import NotificationPermission, Notification, EmailTemplate from datamodel.menu import Menu self.db = DataBase([ User, UserTimeLine, ContentType, Category, Article, Favoriters, Subscribers, Likers, Dislikers, Comments, UserBoard, UserContact, CookRecipe, CookRecipeBook, CodeRecipe, Product, Ads, NotificationPermission, Notification, EmailTemplate, Menu ]) self.db.ArticleData = ArticleData(self.db).entity # visibility comments_fields = [ 'article_id', "user_id", "nickname", "parent_id", "replies", "commenttime", "answer" ] for f in comments_fields: self.db.article_comments[f].readable = self.db.article_comments[ f].writable = True ckeditor = CKEditor() self.db.article_comments.comment_text.widget = ckeditor.widget # visibility if not self.db.auth.has_membership("admin"): redirect(self.db.CURL("home", "index"))
def set_properties(self): ckeditor = CKEditor(self.db) T = current.T self.fields = [ Field("author", "reference auth_user"), Field("title", "string", notnull=True), Field("description", "text"), Field("body_text", "text", notnull=True), Field("slug", "text", notnull=True), ] self.widgets = {"body_text": ckeditor.widget} self.visibility = {"author": (False, False)} self.representation = {"body_text": lambda row, value: XML(value)} self.validators = { "title": IS_NOT_EMPTY(), "body_text": IS_NOT_EMPTY() } self.computations = { "slug": lambda r: IS_SLUG()(r.title)[0], } self.labels = { "title": T("Your post title"), "description": T("Describe your post (markmin allowed)"), "body_text": T("The content") }
def edit_box(): div = DIV(_id='ads_product', _class='panel panel-default') div.append(DIV(T('Quảng cáo'), _class='panel-heading')) box = cms.define_box() from plugin_ckeditor import CKEditor box.htmlcontent.widget = CKEditor(cms.db).widget box.boxtype.writable = False box.boxtype.readable = False box.name.writable = False box.avatar.writable = False box.avatar.readable = False box.link.writable = False box.link.readable = False box.setting.writable = False box.setting.readable = False box.textcontent.writable = False box.textcontent.readable = False form = SQLFORM(box, request.args(0)) if form.process().accepted: response.flash = T('Cập nhật thành công') div.append(DIV(form, _class='panel-body')) response.view = 'plugin_sgd/ads.%s' % request.extension return dict(content=div)
def set_properties(self): ckeditor = CKEditor() T = current.T self.fields = [ Field("prep_time", "string", notnull=True), Field("cook_time", "string", notnull=True), Field("difficulty", "string", notnull=True), Field("servings", "double", notnull=True), Field("ingredients", "list:string", notnull=True), Field("instructions", "text", notnull=True), Field("credits", "text"), ] self.validators = { "ingredients": IS_NOT_EMPTY(), "instructions": IS_NOT_EMPTY(), "difficulty": IS_IN_SET([("1", T("Easy")), ("2", T("Medium")), ("3", T("Hard"))], zero=None), "prep_time": IS_NOT_EMPTY(), "cook_time": IS_NOT_EMPTY(), "servings": IS_NOT_EMPTY(), } self.widgets = {"instructions": ckeditor.widget} self.labels = { "instructions": T("Preparation instructions"), "ingredients": T("Ingredients"), "prep_time": T("Preparation time"), "cook_time": T("Cooking time"), "difficulty": T("Difficulty"), "servings": T("Servings"), "credits": T("credits"), } self.comments = { "ingredients": T("One item per line. Press enter to wrap. e.g: 3 cups of water<enter>" ), "instructions": T("You can include pictures."), "prep_time": T("The whole time considering ingredients preparation."), "cook_time": T("The time needed after all ingredients are ready."), "servings": T("How many portions, plates, cups etc?"), "credits": T("Include links, names, books etc."), "difficulty": T("Easy, Medium or hard to cook?"), }
def _(): plugins = PluginManager('audio', app=None) if plugins.audio.app is not None: plugins.audio.app.registerContentType('audio', ContentAudio()) # the audio rendentions tbl = db.define_table( # register my content type plugin 'plugin_audio_rendition', Field('purpose', 'string', length=50, default='web'), Field('audio', 'upload', uploadseparate=True, autodelete=True), ) tbl.purpose.comment = T(''' Descrive the purpose of this rendition of the video, e.g.: web, social networks, etc. ''') tbl.purpose.label = T('Purpose') tbl.audio.label = T('Audio File') tbl.audio.requires = IS_NOT_EMPTY() # configure ckeditor editor = CKEditor(db=db) # content table tbl = db.define_table( 'plugin_audio_content', Field('credit_line', 'string', length=150, default=''), Field('description', 'text', label=T('Description'), default=''), Field('renditions', 'list:reference plugin_audio_rendition'), Field('item_id', 'string', length=64), auth.signature, ) tbl.item_id.readable = False tbl.item_id.writable = False tbl.credit_line.label = T("Credit line") tbl.description.label = T('Description') tbl.description.widget = editor.widget tbl.renditions.label = T("Renditions") tbl.renditions.default = [] tbl.renditions.writable = False tbl.renditions.readable = False tbl._enable_record_versioning() # add callback for item cleanup on delete. def __plugin_audio_item_on_delete(s): item = s.select().first() if item.item_type == 'audio': # cleanup here cnt = db.plugin_audio_content(item_id=item.unique_id) db(db.plugin_audio_rendition.id.belongs( cnt.renditions)).delete() db(db.plugin_audio_content.item_id == item.unique_id).delete() return False # remember to procced db.item._before_delete.insert(0, __plugin_audio_item_on_delete)
def _(): plugins = PluginManager('photoset', app=None) if plugins.photoset.app is not None: plugins.photoset.app.registerContentType('photoset', ContentPhotoset()) editor = CKEditor(db=db) if not hasattr(db, 'plugin_photoset_photo'): db.define_table( 'plugin_photoset_photo', Field('thumbnail', 'upload', uploadseparate=True, autodelete=True, default=None), Field('picture', 'upload', uploadseparate=True, autodelete=True), ) if not hasattr(db, 'plugin_photoset_content'): tbl = db.define_table( 'plugin_photoset_content', Field('credit_line', 'string', length=250, default=''), Field('description', 'text', label=T('Description'), default=''), Field('photoset', 'list:reference plugin_photoset_photo'), Field('item_id', 'string', length=64), auth.signature, ) tbl.credit_line.label = T("Credit line") tbl.description.label = T('Description') tbl.description.widget = editor.widget tbl._enable_record_versioning() # add callback for item cleanup on delete. def __plugin_photoset_item_on_delete(s): item = s.select().first() if item.item_type == 'photoset': # cleanup here cnt = db.plugin_photoset_content(item_id=item.unique_id) db(db.plugin_photoset_photo.id.belongs( cnt.photoset)).delete() db(db.plugin_photoset_content.item_id == item.unique_id).delete() return False # remember to procced db.item._before_delete.insert(0, __plugin_photoset_item_on_delete)
def set_properties(self): self.fields = [ Field("template_key", "string", notnull=True, unique=True), Field("plain_text", "text", notnull=True, default=""), Field("html_text", "text", notnull=True, default=""), Field("subject_text", "string"), Field("copy_to", "string"), Field("reply_to", "string"), Field("detect_links", "boolean", default=True), Field("attachment_file", "upload"), ] from plugin_ckeditor import CKEditor ckeditor = CKEditor(self.db, self.db.config.theme.name) self.widgets = {"html_text": ckeditor.widget}
def set_properties(self): ckeditor = CKEditor() T = self.db.T self.fields = [ Field("markup", default="html"), Field("body", "text", notnull=True), ] self.validators = { "body": IS_NOT_EMPTY(), #"markup": IS_IN_SET(["html", "markmin"], zero=None), } self.labels = {"body": T("Article Text")} self.visibility = {"markup": (False, False)} self.widgets = {"body": ckeditor.widget}
def view_san_pham(id, cms, folder_id_ivinh): request = current.request T = current.T div = DIV(_class='col-md-12', _id='news_detail') name = request.args(0) from plugin_ckeditor import CKEditor san_pham = cms.define_table('san_pham') # san_pham.folder.default=folder_id_ivinh # san_pham.folder.writable=False # san_pham.folder.readable=False from plugin_app import widget_danh_muc_san_pham san_pham.folder.widget = widget_danh_muc_san_pham san_pham.r_folder.writable = False san_pham.r_folder.readable = False san_pham.htmlcontent.widget = CKEditor(cms.db).widget form = SQLFORM(san_pham, id) ajax = "ajax('%s', [''], 'news_detail')" % (URL( r=current.request, c='plugin_app', f='act_delete', args=[request.args(0)], vars=dict(table_name='san_pham', table_id=id))) form[0][-1] = TR(TD(INPUT(_type='submit', _value=T('Submit')), INPUT(_type='button', _value=T('Xóa sản phẩm'), _onclick=ajax, _class='btn btn-danger'), _colspan="3"), _class='act_ivinh') if form.process().accepted: dcontent = cms.define_dcontent() link = cms.db.san_pham[request.vars.id].link id_d = cms.db((dcontent.dtable == 'san_pham') & (dcontent.link == link)).update( name=request.vars.name, folder=request.vars.folder, avatar=request.vars.avatar, description=request.vars.description) current.response.flash = T('Cập nhật thành công.') div.append(form) return div
def _(): plugins = PluginManager('package', app=None) if plugins.package.app is not None: # this will register the the application on content/type plugins.package.app.registerContentType('package', ContentPackage()) if not hasattr(db, 'plugin_package_content'): editor = CKEditor(db=db) tbl = db.define_table( 'plugin_package_content', Field('item_list', 'list:string'), Field('description', 'text'), Field('item_id', 'string', length=64), auth.signature, ) tbl.item_id.writable = False tbl.item_id.readable = False tbl.item_list.writable = False tbl.item_list.readable = False tbl.description.label = T('Description') tbl.description.widget = editor.widget tbl._enable_record_versioning()
def _(): plugins = PluginManager('package', app=None) if plugins.package.app is not None: # this will register the the application on content/type plugins.package.app.registerContentType('package', ContentPackage()) if not hasattr(db, 'plugin_package_content'): editor = CKEditor(db=db) tbl = db.define_table( 'plugin_package_content', Field('item_list', 'list:string'), Field('description', 'text'), Field('item_id', 'string', length=64), auth.signature, ) tbl.item_id.writable = False tbl.item_id.readable = False tbl.item_list.writable = False tbl.item_list.readable = False tbl.description.label = T('Description') tbl.description.widget = editor.widget tbl._enable_record_versioning() # add a callback to the item table for updating the item list of # the package on item deletion. def plugin_package_callback(s): item = s.select().first() # this are the packages with contains the item to delete pkgs = db( db.plugin_package_content.item_list.contains( item.unique_id)).select() for pkg in pkgs: # remove the item from the package pkg.item_list.remove(item.unique_id) pkg.update_record() return False db.item._before_delete.insert(0, plugin_package_callback)
def set_properties(self): ckeditor = CKEditor() self.fields = [ Field("title", unique=True), Field("description", "text"), Field("page_content", "text"), Field("picture", "upload"), Field("thumbnail", "upload"), Field("tags", "list:string"), Field("slug"), Field("page_scope", "list:string", default=["public", "sitemap"]), Field("visibility"), Field("text_language", default="pt-br"), Field("redirect_url"), ] self.widgets = { "tags": StringListWidget.widget, "page_content": ckeditor.widget } self.comments = { "page_scope": "public, sitemap, members" } self.computations = { "slug": lambda r: IS_SLUG()(r.title)[0], "thumbnail": lambda r: THUMB2(r.picture, 200, 200) } self.validators = { "title": [IS_NOT_EMPTY(), IS_NOT_IN_DB(self.db, "internal_page.title")], "description": IS_NOT_EMPTY(), "picture": IS_EMPTY_OR(IS_IMAGE()), "tags": COMMA_SEPARATED_LIST(), "text_language": IS_IN_SET(["en", "pt-br", "es"]) }
def _(): plugins = PluginManager('picture', app=None) # this will register the content/type on the application if plugins.picture.app is not None: editor = CKEditor(db=db) plugins.picture.app.registerContentType('picture', ContentPicture()) if not hasattr(db, 'plugin_picture_rendition'): tbl = db.define_table( 'plugin_picture_rendition', Field('picture', 'upload', uploadseparate=True, autodelete=True), Field('purpose', 'string', length=50, default='raw'), Field('height', 'integer', default=0, readable=False, writable=False), Field('width', 'integer', default=0, readable=False, writable=False), Field('color', 'string', length=20, readable=False, writable=False), Field('format', 'string', length=10, readable=False, writable=False)) tbl.purpose.comment = T(''' It may contain any value but it is recommended to use one of the values: raw, web, thumbnail, print ''') tbl.purpose.label = T('Purpose') tbl.height.label = T('Height') tbl.width.label = T('Width') tbl.color.label = T('Color space') tbl.format.label = T('Format') tbl.format.comment = T('Automatic form PIL') tbl.picture.label = T('Picture') tbl.picture.requires = [IS_IMAGE(), IS_NOT_EMPTY()] if not hasattr(db, 'plugin_picture_info'): # definimos la BD tbl = db.define_table( 'plugin_picture_info', Field('credit_line', 'string', length=250, default=''), Field('description', 'text', label=T('Description'), default=''), Field('caption', 'string', length=250, default=''), Field('thumbnail', 'upload', uploadseparate=True, autodelete=True, default=None), Field('renditions', 'list:reference plugin_picture_rendition'), Field('item_id', 'string', length=64), auth.signature, ) tbl.credit_line.label = T("Credit line") tbl.description.label = T('Description') tbl.description.widget = editor.widget tbl.caption.label = T("Caption") tbl.renditions.label = T("Renditions") tbl.item_id.readable = False tbl.item_id.writable = False # enable record versioning tbl._enable_record_versioning() return
from plugin_ckeditor import CKEditor ckeditor = CKEditor(db, download_url=('initial','download')) ckeditor.define_tables()
# -*- coding: utf-8 -*- ################################################### # This file was developed by ToanLK # It is released under BSD, MIT and GPL2 licenses # Version 0.1 Date: 27/02/2014 ################################################### from plugin_cms import Cms cms = Cms() from plugin_ckeditor import CKEditor CKEditor(cms.db).define_tables() if request.controller in [ 'plugin_cms', 'portal', 'plugin_app', 'plugin_box', 'plugin_sgd', 'plugin_folder', 'plugin_manager', 'plugin_report' ]: from plugin_process import ProcessModel db = cms.db cms.define_dcontent(False) cms.define_box(False) cms.define_folder(False) cms.define_rtable(False) auth = ProcessModel().auth folder_id_gian_hang = '' if auth.user_id: folder = cms.define_folder() db_auth = ProcessModel().db rows = db_auth( db_auth.auth_membership.user_id == auth.user_id).select() list_group = []
# -*- coding: utf-8 -*- from mzw2p import Q from plugin_ckeditor import CKEditor ckeditor = CKEditor(db) # ckeditor.define_tables() -- done in controllers db.define_table('typ_zacatku', Field('typ', length=48), format='%(typ)s' ) db.define_table('typ_kontaktu', Field('typ', length=96, label=Q('Typ kontaktu')), Field('lze_pouzivat', 'boolean', label=Q('lze použít')), # existuje podpora zasílání pozvánek na tento typ kontaktu format='%(typ)s' ) db.define_table('typ_mista', Field('typ', length=96), format='%(typ)s' ) db.define_table('misto', Field('idtyp_mista', db.typ_mista), Field('misto', length=128), Field('lat', 'decimal(10,5)'), Field('lon', 'decimal(10,5)'), format='%(misto)s' )
def printMetaProperties(self): import string from gluon import META config = Settings() request = current.request metas = [] db = self.db #si es un post de blog, extraer metadatos de la entrada if (request.controller == 'blog') and (request.function == 'show'): from blog import Blog, Images from plugin_ckeditor import CKEditor ckeditor = CKEditor(db) Blog(db, ckeditor), Images(db) if request.args(0).isdigit(): post = db(db.blog.id == request.args(0)).select( db.blog.ALL, db.images.image, join=[db.images.on(db.images.id == db.blog.image) ]).first() else: post = db(db.blog.urlfriendly == request.args(0)).select( db.blog.ALL, db.images.image, join=[db.images.on(db.images.id == db.blog.image) ]).first() if post != None: self.logger.debug(post.blog.title) metas.append( META(_property="og:title", _content=post.blog.title)) #metas.append(META(_property="og:description", _content=post.description)) #hace falta un field description metas.append( META(_property="og:image", _content=URL('blog', 'download', args=post.images.image, host=True))) metas.append(META(_property="og:type", _content="article")) if post.blog.tags != None: for tag in post.blog.tags.split(','): if tag != "": metas.append( META(_property="article:tag", _content=tag.strip())) metas.append( META(_property="url", _content=URL('blog', 'show', request.args(0), host=True))) metas.append( META(_property="article:published_time", _content=post.blog.created_on)) metas.append( META(_name="twitter:image:src", _content=URL('blog', 'download', args=post.images.image, host=True))) metas.append( META(_name="twitter:card", _content="summary_large_image")) metas.append(META(_name="twitter:site", _content="@gextiendas")) metas.append( META( _name="twitter:domain", _content= "Tu plataforma experta para la gestión de tiendas online" )) metas.append( META(_name="twitter:creator", _content="@gestionexperta")) metas.append( META(_property="article:publisher", _content="http://www.facebook.com/gextiendas")) #puede ocurrir que un controller/function tengan meta_keys y meta_values definidos en seo table elif request.controller != 'blog' and request.controller != 'administrator' and request.controller != 'account': metas.append( META(_property="og:title", _content=config.settings['title'])) metas.append( META(_property="og:description", _content=config.settings['description'])) metas.append(META(_property="og:type", _content='website')) metas.append( META(_property="og:site_name", _content=config.settings['title'])) metas.append( META( _property="og:image", _content= "http://www.gextiendas.es/gextiendas/static/img/slides/up-sales.png" )) metas.append( META( _name="twitter:image:src", _content= "http://www.gextiendas.es/gextiendas/static/img/slides/up-sales.png" )) metas.append( META(_name="twitter:card", _content="summary_large_image")) metas.append(META(_name="twitter:site", _content="@gextiendas")) metas.append( META( _name="twitter:domain", _content= "Tu plataforma experta para la gestión de tiendas online")) metas.append( META(_name="twitter:creator", _content="@gestionexperta")) metas.append( META(_property="article:publisher", _content="http://www.facebook.com/gextiendas")) for seovalues in db((db.seo.controller == request.controller) & (db.seo.function == request.function)).select( db.seo.meta_key, db.seo.meta_key): metas.append( META(_property=seovalues.meta_key, _content=seovalues.meta_value)) #y si ninguna de las anteriores, entonces metas por defecto else: metas.append( META(_property="og:title", _content=config.settings['title'])) metas.append( META(_property="og:description", _content=config.settings['description'])) metas.append(META(_property="og:type", _content='website')) metas.append( META(_property="og:site_name", _content=config.settings['title'])) metas.append( META( _property="og:image", _content= "http://www.gextiendas.es/gextiendas/static/img/slides/up-sales.png" )) metas.append( META( _name="twitter:image:src", _content= "http://www.gextiendas.es/gextiendas/static/img/slides/up-sales.png" )) return metas
def comment_internal(self): is_author = False if self.session.auth and self.session.auth.user: is_author = True if self.session.auth.user.id == self.context.article.author else False self.db.Comments.article_id.default = self.context.article.id self.db.Comments.user_id.default = self.session.auth.user.id self.db.Comments.commenttime.default = self.request.now self.db.Comments.comment_text.label = self.T("Post your comment") from plugin_ckeditor import CKEditor ckeditor = CKEditor() self.db.Comments.comment_text.widget = ckeditor.basicwidget form = SQLFORM(self.db.Comments, formstyle='divs') submit_button = form.elements(_type='submit')[0] submit_button['_class'] = "btn btn-info" submit_button['_value'] = self.T("Post comment") if form.process(message_onsuccess=self.T('Comment included')).accepted: self.new_article_event('new_article_comment', self.session.auth.user, data={'event_text': form.vars.comment_text, 'event_link': form.vars.nickname or form.vars.user_id, 'event_image': self.get_image(None, 'user', themename=self.context.theme_name, user=self.session.auth.user), 'event_link_to': "%s/%s#comment_%s" % (self.context.article.id, self.context.article.slug, form.vars.id)}) else: form = CAT(A(self.T("Login to post comments"), _class="button btn", _href=self.CURL('default', 'user', args='login', vars=dict(_next=self.CURL('article', 'show', args=[self.context.article.id, self.context.article.slug])))), BR(), BR()) if 'commentlimitby' in self.request.vars: limitby = [int(item) for item in self.request.vars.commentlimitby.split(',')] else: limitby = (0, 5) comment_set = self.db(self.db.Comments.article_id == self.context.article.id) comments = comment_set.select(orderby=~self.db.Comments.created_on, limitby=limitby) if comments and is_author: edit_in_place = ckeditor.bulk_edit_in_place(["comment_%(id)s" % comment for comment in comments], URL('editcomment')) elif comments and self.session.auth and self.session.auth.user: usercomments = comments.find(lambda row: row.user_id == self.session.auth.user.id) if usercomments: edit_in_place = ckeditor.bulk_edit_in_place(["comment_%(id)s" % comment for comment in usercomments], URL('editcomment')) else: edit_in_place = ('', '') else: edit_in_place = ('', '') self.context.lencomments = comment_set.count() def showmore(anchor, limitby=limitby, lencomments=self.context.lencomments): if lencomments > limitby[1]: return A(self.T('show more comments'), _class="button btn", _style="width:97%;", _href=self.CURL(args=self.request.args, vars={"commentlimitby": "0,%s" % (limitby[1] + 10)}, anchor=anchor)) else: return '' return DIV( H4(IMG(_src=URL('static', '%s/images/icons' % self.context.theme_name, args='board.24.png')), self.T("Comments"), " (%s)" % self.context.lencomments), UL(form, *[LI( H5( A( self.T("%s %s", (comment.nickname or comment.user_id, self.db.pdate(comment.commenttime))), _href=self.CURL('person', 'show', args=comment.nickname or comment.user_id)) ), DIV( XML(comment.comment_text), **{'_class': 'editable commentitem', '_data-object': 'comment', '_data-id': comment.id, '_id': "comment_%s" % comment.id} ), _class="comment_li" ) for comment in comments], **dict(_class="comment_ul")), edit_in_place[1], showmore("comment_%s" % comment.id) if comments else '', _class="internal-comments article-box" )
def set_fixtures(self): ckeditor = CKEditor() self.db.article.description.widget = ckeditor.widget
__author__ = 'Evolutiva' from plugin_ckeditor import CKEditor ckeditor = CKEditor(db) ckeditor.define_tables() ##tabla caso db.define_table('caso', Field('depiction', 'upload', label=T('Logotipo')), Field('name', 'string', label=T('Nombre')), Field('description', 'text', label=T('Reseña'), widget=ckeditor.widget), Field('country', db.country, label=T('País'), requires=IS_IN_DB(db, 'country.id', 'country.name'), default=44), Field('city', 'string', label=T('Ciudad')), Field('documentSource', 'list:reference document', required=False, requires=IS_IN_DB(requiere, 'document.id', '%(name)s / (documentURL)s', multiple=True), label=T('Fuentes')), Field('documentCloud', 'list:reference documentCloud', required=False, requires=IS_IN_DB(db,
# -*- coding: utf-8 -*- import os from gluon import * from plugin_ckeditor import CKEditor current.plugin_ckeditor = CKEditor() current.plugin_ckeditor.define_tables() db = current.plugin_ckeditor.db def upload(): (new_filename, old_filename, length, mime_type) = current.plugin_ckeditor.handle_upload() title = os.path.splitext(old_filename)[0] result = current.plugin_ckeditor.settings.table_upload.validate_and_insert( title=title, filename=old_filename, upload=new_filename, flength=length, mime_type=mime_type, user_id=session.auth.user.id, created_on=request.now ) text = '' url = URL('default', 'download', args=[new_filename]) if not result.id: text = result.errors return dict(text=text, cknum=request.vars.CKEditorFuncNum, url=url)
def comment_internal(self): is_author = False if self.session.auth and self.session.auth.user: is_author = True if self.session.auth.user.id == self.context.article.author else False self.db.Comments.article_id.default = self.context.article.id self.db.Comments.user_id.default = self.session.auth.user.id self.db.Comments.commenttime.default = self.request.now self.db.Comments.comment_text.label = self.T("Post your comment") from plugin_ckeditor import CKEditor ckeditor = CKEditor() self.db.Comments.comment_text.widget = ckeditor.basicwidget form = SQLFORM(self.db.Comments, formstyle='divs') if form.process( message_onsuccess=self.T('Comment included')).accepted: self.new_article_event( 'new_article_comment', self.session.auth.user, data={ 'event_text': form.vars.comment_text, 'event_link': "%s/%s#comment_%s" % (self.context.article.id, self.context.article.slug, form.vars.id) }) else: form = A( self.T("Login to post comments"), _class="button", _href=self.CURL( 'default', 'user', args='login', vars=dict(_next=self.CURL('article', 'show', args=[ self.context.article.id, self.context.article.slug ])))) comments = self.db( self.db.Comments.article_id == self.context.article.id).select( orderby=self.db.Comments.created_on) if comments and is_author: edit_in_place = ckeditor.bulk_edit_in_place( ["comment_%(id)s" % comment for comment in comments], URL('editcomment')) elif comments and self.session.auth and self.session.auth.user: usercomments = comments.find( lambda row: row.user_id == self.session.auth.user.id) if usercomments: edit_in_place = ckeditor.bulk_edit_in_place( ["comment_%(id)s" % comment for comment in usercomments], URL('editcomment')) else: edit_in_place = ('', '') else: edit_in_place = ('', '') return DIV(H4( IMG(_src=URL('static', '%s/images/icons' % self.context.theme_name, args='board.24.png')), self.T("Comments")), UL( *[ LI(H5( A(self.T("%s %s" % (comment.nickname or comment.user_id, self.db.pdate(comment.commenttime))), _href=self.CURL('person', 'show', args=comment.nickname or comment.user_id))), DIV( XML(comment.comment_text), **{ '_class': 'editable commentitem', '_data-object': 'comment', '_data-id': comment.id, '_id': "comment_%s" % comment.id }), _class="comment_li") for comment in comments ], **dict(_class="comment_ul")), edit_in_place[1], form, _class="internal-comments article-box")
from plugin_ckeditor import CKEditor ckeditor = CKEditor(db) ckeditor.define_tables() UCS = ['UC Berkeley', 'UC Davis', 'UC Irvine', 'UC Los Angeles', 'UC Merced', 'UC Riverside', 'UC San Diego', 'UC Santa Barbara', 'UC Santa Cruz'] # This is a table called 'category' which defines a bunch of names for categories. We use this table to make # categories such as Student Life, Sports, and Events. You won't be able to create a category that already # exists. It can also not contain special characters (IS_SLUG). The URL cannot be lowercase. db.define_table('category', Field('name', requires=(IS_SLUG(), IS_LOWER(), IS_NOT_IN_DB(db, 'category.name')))) # This table called 'post' is responsible for defining what a post is. A post will belong to a specific # category and it will reference that category. The category field for the post can't be readable or # writable because we want the users to be able to make a post in a given category such as Student Life, # Sports, or Events, but we don't want them to be able to change the name of that category. A post will # also need to have a title and a body of text. We don't want either of these to be empty. If one or more # of those fields is empty, the form will throw an error. A post will also have a number of votes. Users # cannot see these votes when they are viewing a post and we don't want them to be able to edit the number # of votes. Since we are also adding in an auth.signature, we are adding in 5 more fields that hold # references to the logged in user who posted the specific post. These fields include created_by, modified_by, # created_on, modified_on, and is_active. We do not use is_active. db.define_table('post', Field('category', 'reference category', writable=False, readable=False), Field('title', 'string', length=45, requires=[IS_NOT_EMPTY(), IS_LENGTH(45)]), Field('body', 'text', widget=ckeditor.widget, requires=IS_NOT_EMPTY()), Field('votes', 'integer', default=0, writable=False, readable=False), Field('uc', label="UC", default='[All]', requires=IS_IN_SET(['[All]']+UCS)), Field('image', 'upload', autodelete=True,
def comment_internal(self): is_author = False if self.session.auth and self.session.auth.user: is_author = True if self.session.auth.user.id == self.context.article.author else False self.db.Comments.article_id.default = self.context.article.id self.db.Comments.user_id.default = self.session.auth.user.id self.db.Comments.commenttime.default = self.request.now self.db.Comments.comment_text.label = self.T("Post your comment") from plugin_ckeditor import CKEditor ckeditor = CKEditor() self.db.Comments.comment_text.widget = ckeditor.basicwidget form = SQLFORM(self.db.Comments, formstyle="divs") if form.process(message_onsuccess=self.T("Comment included")).accepted: self.new_article_event( "new_article_comment", self.session.auth.user, data={ "event_text": form.vars.comment_text, "event_link": "%s/%s#comment_%s" % (self.context.article.id, self.context.article.slug, form.vars.id), }, ) else: form = A( self.T("Login to post comments"), _class="button", _href=self.CURL( "default", "user", args="login", vars=dict( _next=self.CURL("article", "show", args=[self.context.article.id, self.context.article.slug]) ), ), ) comments = self.db(self.db.Comments.article_id == self.context.article.id).select( orderby=self.db.Comments.created_on ) if comments and is_author: edit_in_place = ckeditor.bulk_edit_in_place( ["comment_%(id)s" % comment for comment in comments], URL("editcomment") ) elif comments and self.session.auth and self.session.auth.user: usercomments = comments.find(lambda row: row.user_id == self.session.auth.user.id) if usercomments: edit_in_place = ckeditor.bulk_edit_in_place( ["comment_%(id)s" % comment for comment in usercomments], URL("editcomment") ) else: edit_in_place = ("", "") else: edit_in_place = ("", "") return DIV( H4( IMG(_src=URL("static", "%s/images/icons" % self.context.theme_name, args="board.24.png")), self.T("Comments"), ), UL( *[ LI( H5( A( self.T( "%s %s" % (comment.nickname or comment.user_id, self.db.pdate(comment.commenttime)) ), _href=self.CURL("person", "show", args=comment.nickname or comment.user_id), ) ), DIV( XML(comment.comment_text), **{ "_class": "editable commentitem", "_data-object": "comment", "_data-id": comment.id, "_id": "comment_%s" % comment.id, } ), _class="comment_li", ) for comment in comments ], **dict(_class="comment_ul") ), edit_in_place[1], form, _class="internal-comments article-box", )