Skip to content

Commit

Permalink
refactored code. Added listings css class config option. Metadata key…
Browse files Browse the repository at this point in the history
…s are now sorted alphabetically.
  • Loading branch information
billyfish committed Sep 28, 2016
1 parent 731d5d6 commit 3c8dedc
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 345 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ APXS := /home/billy/Applications/grassroots-0/apache/bin/apxs
INSTALL_DIR ?= /usr/lib64/httpd/modules
INSTALLED := $(INSTALL_DIR)/mod_$(MODNAME).so

CFILES := mod_davrods.c auth.c common.c config.c prop.c propdb.c repo.c meta.c
HFILES := mod_davrods.h auth.h common.h config.h prop.h propdb.h repo.h
CFILES := mod_davrods.c auth.c common.c config.c prop.c propdb.c repo.c meta.c theme.c
HFILES := mod_davrods.h auth.h common.h config.h prop.h propdb.h repo.h meta.h theme.h

# The DAV providers supported by default (you can override this in the shell using DAV_PROVIDERS="..." make).
DAV_PROVIDERS ?= LOCALLOCK NOLOCKS
Expand Down
27 changes: 20 additions & 7 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* along with Davrods. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "theme.h"

#include <apr_strings.h>

Expand Down Expand Up @@ -75,13 +76,7 @@ void *davrods_create_dir_config(apr_pool_t *p, char *dir) {


conf -> themed_listings = 0;
conf -> theme.ht_head_s = NULL;
conf -> theme.ht_top_s = NULL;
conf -> theme.ht_bottom_s = NULL;
conf -> theme.ht_collection_icon_s = NULL;
conf -> theme.ht_object_icon_s = NULL;
conf -> theme.ht_parent_icon_s = NULL;
conf -> theme.ht_show_metadata = 0;
InitHtmlTheme (& (conf -> theme));
}
return conf;
}
Expand Down Expand Up @@ -125,8 +120,10 @@ void *davrods_merge_dir_config(apr_pool_t *p, void *_parent, void *_child) {
DAVRODS_PROP_MERGE(theme.ht_collection_icon_s);
DAVRODS_PROP_MERGE(theme.ht_object_icon_s);
DAVRODS_PROP_MERGE(theme.ht_parent_icon_s);
DAVRODS_PROP_MERGE(theme.ht_listing_class_s);
DAVRODS_PROP_MERGE(theme.ht_show_metadata);


assert(set_exposed_root(conf, exposed_root) >= 0);

#undef DAVRODS_PROP_MERGE
Expand Down Expand Up @@ -367,6 +364,17 @@ static const char *cmd_davrods_html_parent_icon (cmd_parms *cmd_p, void *config_
return NULL;
}


static const char *cmd_davrods_html_listing_class (cmd_parms *cmd_p, void *config_p, const char *arg_p)
{
davrods_dir_conf_t *conf_p = (davrods_dir_conf_t*) config_p;

conf_p -> theme.ht_listing_class_s = arg_p;

return NULL;
}


static const char *cmd_davrods_html_metadata (cmd_parms *cmd_p, void *config_p, const char *arg_p)
{
davrods_dir_conf_t *conf_p = (davrods_dir_conf_t*) config_p;
Expand Down Expand Up @@ -475,6 +483,11 @@ const command_rec davrods_directives[] = {
NULL, ACCESS_CONF, "Icon to use for parent link in the directory listings"
),

AP_INIT_RAW_ARGS(
DAVRODS_CONFIG_PREFIX "HTMLListingClass", cmd_davrods_html_listing_class,
NULL, ACCESS_CONF, "CSS class to use for the listing <table> element"
),

AP_INIT_TAKE1(
DAVRODS_CONFIG_PREFIX "HTMLMetadata", cmd_davrods_html_metadata,
NULL, ACCESS_CONF, "Options for displaying metadata"
Expand Down
21 changes: 2 additions & 19 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,7 @@

#include "mod_davrods.h"


struct html_theme
{
const char *ht_head_s;

const char *ht_top_s;

const char *ht_bottom_s;

const char *ht_collection_icon_s;

const char *ht_object_icon_s;

const char *ht_parent_icon_s;

int ht_show_metadata;
};

#include "theme.h"

/**
* \brief Davrods per-directory config structure.
Expand Down Expand Up @@ -81,7 +64,7 @@ typedef struct {
} rods_exposed_root_type;

int themed_listings;
struct html_theme theme;
struct HtmlTheme theme;

} davrods_dir_conf_t;

Expand Down
6 changes: 2 additions & 4 deletions meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,13 @@ apr_array_header_t *GetMetadataForDataObject (const dav_resource *resource_p, co

}

//freeGenQueryOut (&metadata_query_results_p);
freeGenQueryOut (&metadata_query_results_p);
} /* metadata_query_results_p */

} /* if (success_code == 0) */

} /* for (i = 0; i < meta_id_results_p -> rowCnt; ++ i) */


} /* if (meta_id_results_p -> attriCnt == 1) */
else
{
Expand All @@ -197,8 +196,7 @@ apr_array_header_t *GetMetadataForDataObject (const dav_resource *resource_p, co

}


//freeGenQueryOut (&meta_id_results_p);
freeGenQueryOut (&meta_id_results_p);
} /* if (meta_id_results_p) */
}
}
Expand Down
1 change: 1 addition & 0 deletions meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "apr_pools.h"
#include "apr_tables.h"

#include "rodsGenQuery.h"

typedef struct IrodsMetadata
{
Expand Down
Loading

0 comments on commit 3c8dedc

Please sign in to comment.