[wellwell-devel] [SCM] Interchange wellwell catalog branch, master, updated. fcdfd2f6855426dc784dd0d41ac2f06a9ea0ed58

Stefan Hornburg racke at rt.icdevgroup.org
Wed Jan 28 21:14:52 UTC 2009


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Interchange wellwell catalog".

The branch, master has been updated
       via  fcdfd2f6855426dc784dd0d41ac2f06a9ea0ed58 (commit)
       via  7cc6eec887588321842b3ff9b27f5976a23e2548 (commit)
      from  156c2e0dea060a325459e104e077595e7333801c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fcdfd2f6855426dc784dd0d41ac2f06a9ea0ed58
Merge: 7cc6eec887588321842b3ff9b27f5976a23e2548 156c2e0dea060a325459e104e077595e7333801c
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date:   Wed Jan 28 22:14:42 2009 +0100

    Merge branch 'master' of ssh://racke@git.icdevgroup.org/var/git/wellwell

commit 7cc6eec887588321842b3ff9b27f5976a23e2548
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date:   Wed Jan 28 22:13:54 2009 +0100

    content plugin (very early development stage)

-----------------------------------------------------------------------

Summary of changes and diff:
 plugins/content/README                          |    6 ++
 plugins/content/code/content.sub                |   21 ++++++++
 plugins/content/code/content.tag                |   59 +++++++++++++++++++++++
 plugins/content/code/form_content_edit_load.sub |   16 ++++++
 plugins/content/code/form_content_edit_save.sub |   19 +++++++
 plugins/content/components/content_display      |    1 +
 plugins/content/components/content_edit         |    4 ++
 plugins/content/components/content_list         |   12 +++++
 plugins/content/components/content_menu         |    3 +
 plugins/content/components/fckeditor_js         |   17 +++++++
 plugins/content/pages/content/display.itl       |    5 ++
 plugins/content/pages/content/edit.itl          |    6 ++
 plugins/content/pages/content/recent.itl        |    3 +
 plugins/content/plugin.cfg                      |    5 ++
 14 files changed, 177 insertions(+), 0 deletions(-)
 create mode 100644 plugins/content/README
 create mode 100644 plugins/content/code/content.sub
 create mode 100644 plugins/content/code/content.tag
 create mode 100644 plugins/content/code/form_content_edit_load.sub
 create mode 100644 plugins/content/code/form_content_edit_save.sub
 create mode 100644 plugins/content/components/content_display
 create mode 100644 plugins/content/components/content_edit
 create mode 100644 plugins/content/components/content_list
 create mode 100644 plugins/content/components/content_menu
 create mode 100644 plugins/content/components/fckeditor_js
 create mode 100644 plugins/content/pages/content/display.itl
 create mode 100644 plugins/content/pages/content/edit.itl
 create mode 100644 plugins/content/pages/content/recent.itl

diff --git a/plugins/content/README b/plugins/content/README
new file mode 100644
index 0000000..73b0d5b
--- /dev/null
+++ b/plugins/content/README
@@ -0,0 +1,6 @@
+Permissions:
+
+create_content
+edit_content
+edit_own_content
+
diff --git a/plugins/content/code/content.sub b/plugins/content/code/content.sub
new file mode 100644
index 0000000..3c51399
--- /dev/null
+++ b/plugins/content/code/content.sub
@@ -0,0 +1,21 @@
+Sub content <<EOS
+sub {
+	my $url = shift;
+	my @parts = split(/\//, $url);
+
+	if ($parts[1] =~ /^(\d+)$/) {
+		$CGI->{mv_nextpage} = 'content/display';
+		$CGI->{code} = $1;
+	}
+	else {
+		if ($parts[$#parts] =~ /^(\d+)$/) {
+			$CGI->{code} = pop(@parts);
+			$url = join('/', @parts);
+		}
+
+		$CGI->{mv_nextpage} = $url;
+	}
+
+	return 1;
+}
+EOS
\ No newline at end of file
diff --git a/plugins/content/code/content.tag b/plugins/content/code/content.tag
new file mode 100644
index 0000000..7ef9e29
--- /dev/null
+++ b/plugins/content/code/content.tag
@@ -0,0 +1,59 @@
+UserTag content Order function code
+UserTag content AddAttr
+UserTag content Routine <<EOR
+sub {
+	my ($function, $code, $opt) = @_;
+	my ($ctref, $out);
+
+	$Tag->perl({tables => 'content'});
+
+	if ($opt->{uri}) {
+		my ($ctset, $uri_qt);
+
+		$uri_qt = $Db{content}->quote($opt->{uri});
+
+		$ctset = $Db{content}->query({sql => qq{select * from content where uri = $uri_qt},
+			hashref => 1});
+			
+		if (@$ctset) {
+			$code = $ctset->[0]->{code};
+			$ctref = $ctset->[0];
+		} else {
+			$Tag->error({name => 'content',
+					set => 'Content not found'});
+			return '';
+		}
+	} 
+	else {
+		unless ($ctref = $Db{content}->row_hash($code)) {
+			Log("Code $code not found.");
+			$Tag->error({name => 'content',
+						set => 'Content not found'});
+			return '';
+		}
+	}
+
+	if ($opt->{edit_link}) {
+		my (@edit_perms, $uri);
+
+		# determine whether uses has permissions to edit content
+		@edit_perms = ('edit_content');
+
+		if ($Session->{logged_in} && $Session->{username} == $ctref->{uid}) {
+			push (@edit_perms, 'edit_own_content');
+		}
+
+		if ($Tag->acl({function => 'check', permission => \@edit_perms})) {
+			$uri = $Tag->area({href => "content/edit/$ctref->{code}"});
+			$out .= qq{<a href="$uri">Edit</a>};
+		}
+	}
+
+	unless ($opt->{no_title}) {
+		$out .= $ctref->{title};
+	}
+
+	$out .= $ctref->{body};
+	return $out;
+}
+EOR
diff --git a/plugins/content/code/form_content_edit_load.sub b/plugins/content/code/form_content_edit_load.sub
new file mode 100644
index 0000000..4d85506
--- /dev/null
+++ b/plugins/content/code/form_content_edit_load.sub
@@ -0,0 +1,16 @@
+Sub form_content_edit_load <<EOS
+sub {
+	my (@fields, @content);
+Log("Loading form");
+	@fields = qw/title body uri/;
+
+	$Tag->perl({tables => 'content'});
+	
+	@content = $Db{content}->get_slice($CGI->{code}, \@fields);
+
+	for (my $i = 0; $i <= @fields; $i++) {
+		$Values->{$fields[$i]} = $content[$i];
+	}
+	
+}
+EOS
diff --git a/plugins/content/code/form_content_edit_save.sub b/plugins/content/code/form_content_edit_save.sub
new file mode 100644
index 0000000..9aa6969
--- /dev/null
+++ b/plugins/content/code/form_content_edit_save.sub
@@ -0,0 +1,19 @@
+Sub form_content_edit_save <<EOS
+sub {
+	# create new content
+	my (%content, $code);
+
+	for (qw/title body uri/) {
+		$content{$_} = $CGI->{$_};
+	}
+	$content{uid} = $Session->{username} || 0;
+	$content{type} = 'page';
+	$content{created} = 0;
+
+	$Tag->perl({tables => 'content'});
+	
+	$code = $Db{content}->set_slice($CGI->{code}, %content);
+
+	return {code => $code, page => 'content/recent'};
+}
+EOS
diff --git a/plugins/content/components/content_display b/plugins/content/components/content_display
new file mode 100644
index 0000000..1322d5d
--- /dev/null
+++ b/plugins/content/components/content_display
@@ -0,0 +1 @@
+[content function="display" code="__CODE__" edit_link="1"]
diff --git a/plugins/content/components/content_edit b/plugins/content/components/content_edit
new file mode 100644
index 0000000..3db4e88
--- /dev/null
+++ b/plugins/content/components/content_edit
@@ -0,0 +1,4 @@
+[compose
+	components.body="content"
+    forms.content.name="content"
+]
\ No newline at end of file
diff --git a/plugins/content/components/content_list b/plugins/content/components/content_list
new file mode 100644
index 0000000..873c9da
--- /dev/null
+++ b/plugins/content/components/content_list
@@ -0,0 +1,12 @@
+[query sql="select * from content" list=1]
+[on-match]
+<table>
+<tr><th>[L]Title[/L]</th><th>[L]Author[/L]</th></tr>
+[/on-match]
+[list]
+<tr><td><a href="[area content/[sql-code]]">[sql-param title]</a></td><td>[sql-param uid]</td></tr>
+[/list]
+[on-match]
+</table>
+[/on-match]
+[/query]
\ No newline at end of file
diff --git a/plugins/content/components/content_menu b/plugins/content/components/content_menu
new file mode 100644
index 0000000..3329cb5
--- /dev/null
+++ b/plugins/content/components/content_menu
@@ -0,0 +1,3 @@
+<a href="[area content/recent]">Recent posts</a>
+
+<a href="[area content/edit]">Create content</a>
\ No newline at end of file
diff --git a/plugins/content/components/fckeditor_js b/plugins/content/components/fckeditor_js
new file mode 100644
index 0000000..32f0a9a
--- /dev/null
+++ b/plugins/content/components/fckeditor_js
@@ -0,0 +1,17 @@
+<script type="text/javascript">
+    _editor_url = "/fckeditor/";
+
+ function addLoadEvent(func) {
+	var oldonload = window.onload;
+	if (typeof window.onload != 'function') {
+		window.onload = func;
+	} else {
+		window.onload = function() {
+		oldonload();
+		func();
+		}
+	}
+   }
+</script>
+<script type="text/javascript" src="/fckeditor/fckeditor.js"></script>
+
diff --git a/plugins/content/pages/content/display.itl b/plugins/content/pages/content/display.itl
new file mode 100644
index 0000000..1eed7e5
--- /dev/null
+++ b/plugins/content/pages/content/display.itl
@@ -0,0 +1,5 @@
+CODE: [cgi code]
+[compose
+	components.body="content_display"
+	attributes.content_display.code="[cgi code]"
+]
\ No newline at end of file
diff --git a/plugins/content/pages/content/edit.itl b/plugins/content/pages/content/edit.itl
new file mode 100644
index 0000000..1289580
--- /dev/null
+++ b/plugins/content/pages/content/edit.itl
@@ -0,0 +1,6 @@
+[compose 
+    components.body="content_edit"
+    forms.content_edit.name="content_edit"
+]
+
+
diff --git a/plugins/content/pages/content/recent.itl b/plugins/content/pages/content/recent.itl
new file mode 100644
index 0000000..12e90f6
--- /dev/null
+++ b/plugins/content/pages/content/recent.itl
@@ -0,0 +1,3 @@
+[compose
+	components.body="content_list"
+]
\ No newline at end of file
diff --git a/plugins/content/plugin.cfg b/plugins/content/plugin.cfg
index 252b38c..ca9cf1c 100644
--- a/plugins/content/plugin.cfg
+++ b/plugins/content/plugin.cfg
@@ -5,6 +5,11 @@ include plugins/default.cfg
 
 Database content AUTO_SEQUENCE content_code_seq
 
+# Use fckeditor as default editor
+ifndef HTMLAREA_FLAVOUR
+Variable HTMLAREA_FLAVOUR fckeditor
+endif
+
 Variable CONTENT_ANON_NAME Anonymous user
 Variable CONTENT_DISPLAY_NAME {FIRST_NAME} {LAST_NAME}
 


hooks/post-receive
-- 
Interchange wellwell catalog



More information about the wellwell-devel mailing list