Re: [PATCH] filter: add support for owner-filter

2014-12-23 Thread Jason A. Donenfeld
Hi Chris,

I like this patch, and I intend to merge it. Would you take care of John's
nitpicks, and rebase this against the current master, and I'll merge?

Sorry for the delay.

Thanks,
Jason
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH] filter: add support for owner-filter

2014-08-01 Thread Chris Burroughs
Followup and attempt at implementation of an owner filter as described
in http://lists.zx2c4.com/pipermail/cgit/2014-July/002163.html.  There
are two parts I am unsure of:
 * Is there an advantage (performance?) to passing the owner as an
   argument instead of using CGIT_REPO_OWNER?
 * I passed along the cgit_rooturl so that a filter could re-implement
   what the C code is doing.  This seemed a good test of if the filter
   was flexible enough, but passing it along as an argument feels a
   bit wonky.  Maybe this would be better as an environmental variable
   to all filters?

---
 cgit.c|6 ++
 cgit.h|4 +++-
 cgitrc.5.txt  |   18 ++
 filter.c  |6 ++
 filters/owner-example.lua |   24 
 shared.c  |1 +
 ui-repolist.c |2 ++
 7 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 filters/owner-example.lua

diff --git a/cgit.c b/cgit.c
index 20f6e27..d29e7f5 100644
--- a/cgit.c
+++ b/cgit.c
@@ -91,6 +91,8 @@ static void repo_config(struct cgit_repo *repo, const char 
*name, const char *va
repo-source_filter = cgit_new_filter(value, SOURCE);
else if (!strcmp(name, email-filter))
repo-email_filter = cgit_new_filter(value, EMAIL);
+   else if (!strcmp(name, owner-filter))
+   repo-owner_filter = cgit_new_filter(value, OWNER);
}
 }
 
@@ -194,6 +196,8 @@ static void config_cb(const char *name, const char *value)
ctx.cfg.commit_filter = cgit_new_filter(value, COMMIT);
else if (!strcmp(name, email-filter))
ctx.cfg.email_filter = cgit_new_filter(value, EMAIL);
+   else if (!strcmp(name, owner-filter))
+   ctx.cfg.owner_filter = cgit_new_filter(value, OWNER);
else if (!strcmp(name, auth-filter))
ctx.cfg.auth_filter = cgit_new_filter(value, AUTH);
else if (!strcmp(name, embedded))
@@ -802,6 +806,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
cgit_fprintf_filter(repo-source_filter, f, 
repo.source-filter=);
if (repo-email_filter  repo-email_filter != ctx.cfg.email_filter)
cgit_fprintf_filter(repo-email_filter, f, 
repo.email-filter=);
+   if (repo-owner_filter  repo-owner_filter != ctx.cfg.owner_filter)
+   cgit_fprintf_filter(repo-owner_filter, f, 
repo.owner-filter=);
if (repo-snapshots != ctx.cfg.snapshots) {
char *tmp = build_snapshot_setting(repo-snapshots);
fprintf(f, repo.snapshots=%s\n, tmp ? tmp : );
diff --git a/cgit.h b/cgit.h
index 0badc64..0078ac1 100644
--- a/cgit.h
+++ b/cgit.h
@@ -53,7 +53,7 @@ typedef void (*filepair_fn)(struct diff_filepair *pair);
 typedef void (*linediff_fn)(char *line, int len);
 
 typedef enum {
-   ABOUT, COMMIT, SOURCE, EMAIL, AUTH
+   ABOUT, COMMIT, SOURCE, EMAIL, AUTH, OWNER
 } filter_type;
 
 struct cgit_filter {
@@ -100,6 +100,7 @@ struct cgit_repo {
struct cgit_filter *commit_filter;
struct cgit_filter *source_filter;
struct cgit_filter *email_filter;
+   struct cgit_filter *owner_filter;
struct string_list submodules;
 };
 
@@ -253,6 +254,7 @@ struct cgit_config {
struct cgit_filter *commit_filter;
struct cgit_filter *source_filter;
struct cgit_filter *email_filter;
+   struct cgit_filter *owner_filter;
struct cgit_filter *auth_filter;
 };
 
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index b7570db..7ed2c80 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -247,6 +247,14 @@ logo-link::
calculated url of the repository index page will be used. Default
value: none.
 
+owner-filter::
+   Specifies a command which will be invoked to format the Owner column
+   of the main page.  The command will get the default html on its STDIN,
+   and the STDOUT from the command will be included verbatim in the
+   table.  This can be used to link to additional context such as an
+   owners home page. Default value: none.
+   See also: FILTER API.
+
 max-atom-items::
Specifies the number of items to display in atom feeds view. Default
value: 10.
@@ -509,6 +517,10 @@ repo.logo-link::
calculated url of the repository index page will be used. Default
value: global logo-link.
 
+repo.owner-filter::
+   Override the default owner-filter. Default value: none. See also:
+   enable-filter-overrides. See also: FILTER API.
+
 repo.module-link::
Text which will be used as the formatstring for a hyperlink when a
submodule is printed in a directory listing. The arguments for the
@@ -641,6 +653,12 @@ email filter::
expected to write to standard output the formatted text to be included
in the page.
 
+owner filter::
+   This filter is given two

Re: [PATCH] filter: add support for owner-filter

2014-08-01 Thread John Keeping
On Fri, Aug 01, 2014 at 04:01:53PM -0400, Chris Burroughs wrote:
 revised patch

This type of comment should go below the --- line below, since it's
not intended to be part of the commit message in the permanent history.
Also filter in the subject doesn't really identify a code area.  How
about something like this:

repolist: add owner-filter

This allows custom links to be used for repository owners by
configuring a filter to be applied in the Owner column in the
repository list.

More below...

 ---
  cgit.c|6 ++
  cgit.h|4 +++-
  cgitrc.5.txt  |   18 ++
  filter.c  |6 ++
  filters/owner-example.lua |   19 +++
  shared.c  |1 +
  ui-repolist.c |   20 +---
  7 files changed, 66 insertions(+), 8 deletions(-)
  create mode 100644 filters/owner-example.lua
 
 diff --git a/cgit.c b/cgit.c
 index 20f6e27..d29e7f5 100644
 --- a/cgit.c
 +++ b/cgit.c
 @@ -91,6 +91,8 @@ static void repo_config(struct cgit_repo *repo, const char 
 *name, const char *va
   repo-source_filter = cgit_new_filter(value, SOURCE);
   else if (!strcmp(name, email-filter))
   repo-email_filter = cgit_new_filter(value, EMAIL);
 + else if (!strcmp(name, owner-filter))
 + repo-owner_filter = cgit_new_filter(value, OWNER);
   }
  }
  
 @@ -194,6 +196,8 @@ static void config_cb(const char *name, const char *value)
   ctx.cfg.commit_filter = cgit_new_filter(value, COMMIT);
   else if (!strcmp(name, email-filter))
   ctx.cfg.email_filter = cgit_new_filter(value, EMAIL);
 + else if (!strcmp(name, owner-filter))
 + ctx.cfg.owner_filter = cgit_new_filter(value, OWNER);
   else if (!strcmp(name, auth-filter))
   ctx.cfg.auth_filter = cgit_new_filter(value, AUTH);
   else if (!strcmp(name, embedded))
 @@ -802,6 +806,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
   cgit_fprintf_filter(repo-source_filter, f, 
 repo.source-filter=);
   if (repo-email_filter  repo-email_filter != ctx.cfg.email_filter)
   cgit_fprintf_filter(repo-email_filter, f, 
 repo.email-filter=);
 + if (repo-owner_filter  repo-owner_filter != ctx.cfg.owner_filter)
 + cgit_fprintf_filter(repo-owner_filter, f, 
 repo.owner-filter=);
   if (repo-snapshots != ctx.cfg.snapshots) {
   char *tmp = build_snapshot_setting(repo-snapshots);
   fprintf(f, repo.snapshots=%s\n, tmp ? tmp : );
 diff --git a/cgit.h b/cgit.h
 index 0badc64..0078ac1 100644
 --- a/cgit.h
 +++ b/cgit.h
 @@ -53,7 +53,7 @@ typedef void (*filepair_fn)(struct diff_filepair *pair);
  typedef void (*linediff_fn)(char *line, int len);
  
  typedef enum {
 - ABOUT, COMMIT, SOURCE, EMAIL, AUTH
 + ABOUT, COMMIT, SOURCE, EMAIL, AUTH, OWNER
  } filter_type;
  
  struct cgit_filter {
 @@ -100,6 +100,7 @@ struct cgit_repo {
   struct cgit_filter *commit_filter;
   struct cgit_filter *source_filter;
   struct cgit_filter *email_filter;
 + struct cgit_filter *owner_filter;
   struct string_list submodules;
  };
  
 @@ -253,6 +254,7 @@ struct cgit_config {
   struct cgit_filter *commit_filter;
   struct cgit_filter *source_filter;
   struct cgit_filter *email_filter;
 + struct cgit_filter *owner_filter;
   struct cgit_filter *auth_filter;
  };
  
 diff --git a/cgitrc.5.txt b/cgitrc.5.txt
 index b7570db..d774ed3 100644
 --- a/cgitrc.5.txt
 +++ b/cgitrc.5.txt
 @@ -247,6 +247,15 @@ logo-link::
   calculated url of the repository index page will be used. Default
   value: none.
  
 +owner-filter::
 + Specifies a command which will be invoked to format the Owner
 + column of the main page.  The command will get the owner on STDIN,
 + and the STDOUT from the command will be included verbatim in the
 + table.  This can be used to link to additional context such as an
 + owners home page.  When active this filter is used instead of the
 + default owner query url.  Default value: none.
 + See also: FILTER API.
 +
  max-atom-items::
   Specifies the number of items to display in atom feeds view. Default
   value: 10.
 @@ -509,6 +518,10 @@ repo.logo-link::
   calculated url of the repository index page will be used. Default
   value: global logo-link.
  
 +repo.owner-filter::
 + Override the default owner-filter. Default value: none. See also:
 + enable-filter-overrides. See also: FILTER API.
 +
  repo.module-link::
   Text which will be used as the formatstring for a hyperlink when a
   submodule is printed in a directory listing. The arguments for the
 @@ -641,6 +654,11 @@ email filter::
   expected to write to standard output the formatted text to be included
   in the page.
  
 +owner filter

owner filter?

2014-07-17 Thread Chris Burroughs
We would like to decorate the owner field (make a link to a wiki for 
internal teams, maybe an icon).  I've read the FILTER API and other 
parts of cgitrc and as far as I can tell it's not an existing filter 
option.  Is that correct?

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


Re: owner filter?

2014-07-17 Thread John Keeping
On Thu, Jul 17, 2014 at 10:10:38AM -0400, Chris Burroughs wrote:
 We would like to decorate the owner field (make a link to a wiki for 
 internal teams, maybe an icon).  I've read the FILTER API and other 
 parts of cgitrc and as far as I can tell it's not an existing filter 
 option.  Is that correct?

Yes, it would need to new filter added in order to filter the owner
field in cgit_print_repolist().  Presumably the interface would be
similar to that of the email filter.
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit