Compare commits

..

39 Commits

Author SHA1 Message Date
5b0ab76434 Fixed more unicode issues, or being more flexible when loading from database. 2015-10-20 19:02:04 +02:00
a84f86d7a2 Addressed various unicode related issues.
Note this is using recent changes from text_filter library.
2015-10-20 18:49:40 +02:00
3f4e70b98c Updated roc tools, and associated scripts.
Also include Eiffel Store ODBC persistence.
2015-10-20 11:29:16 +02:00
782e9397a3 Added missing sql_finalize which is used to cleanup as early as possible the last statement when it is not needed anymore. 2015-10-19 23:33:17 +02:00
f51ddc9796 Extracted launcher code into cms/launcher/... libraries.
(mostly to help new project based on ROC CMS).
Renamed and simplified the roc cms server launcher, and the related cms execution.
Updated cms.ini and extract blocks related management into blocks.ini.
Added debug clauses for cms sqlite3 storage.
2015-10-19 22:50:48 +02:00
a260bbc2c5 Removed obsolete usage of {TYPE}.attempt from CMS_MODULE_COLLECTION. 2015-10-19 20:50:47 +02:00
eb5ae32e46 Added persistence support for Eiffel sqlite3 wrapper.
Updated existing persistency solution to be more generic to any db solution.
2015-10-19 11:24:22 +02:00
7fcacad5eb Use extended type support from EiffelStore to handle STRING_32, and other extended types. 2015-10-19 11:20:04 +02:00
7c99f2dc83 Added recent_changes.ecf 2015-10-18 20:47:33 +02:00
57430193e3 Fixed compilation of CMS_FILE_BLOCK. 2015-10-18 19:24:43 +02:00
62bf58ce6d Added support for block options for the feed aggregator blocks.
Updated weight for primary_tabs block.
2015-10-17 00:17:59 +02:00
23c395513b Fixed handling of block and optional block.
- All blocks behavior can be specified and overwritten via the configuaration.
  - And optional block are not displayed by default.
2015-10-16 23:46:18 +02:00
d2d86ecdf2 Added notion of block options, declared in cms.ini as
[blocks]
    {block_id}.options[name]=value
    {block_id}.options[size]=123
2015-10-16 23:11:44 +02:00
e90f82387f Added notion of alias block, to provide a way to include a block content in mutiple regions. 2015-10-16 23:02:47 +02:00
05472abdd7 Improved block condition "path:..." by allowing wildchar.
Added weight data to CMS_BLOCK to be able to sort the block lists,
  and thus order the display of blocks.
Set negative weight for various core block, so that they appear first as expected.
The weight can be set and overwritten in cms.ini , by pref  blocks.{block_id}.weight=integer_weight.
2015-10-16 17:22:22 +02:00
788cf3738d Fixed compilation of CMS_BLOCK_LOCATION_CONDITION (not used for now). 2015-10-14 14:20:55 +02:00
f6185612b2 Fixed compilation issue. 2015-10-12 19:42:09 +02:00
d37f45d958 Include block caches clearing during "clear_cache" hook invocation. 2015-10-12 19:39:41 +02:00
872f2a177d For now, only clear feed aggregation cache if clear all cache is requested. 2015-10-12 19:22:37 +02:00
3ed2f410d9 Added feeds.json example in feed_aggregator module folder. 2015-10-12 19:15:09 +02:00
1b451ef142 Moved the feeds.json example in associated module files. 2015-10-12 19:12:42 +02:00
50146985de Added CMS_HOOK_CACHE, and admin cache.
Prepared evolution of feed module, by allowing json object to list feeds locations.
   The associated key will be used to identify the location, and have category filter by location.
2015-10-12 19:03:12 +02:00
8cdf9ba973 Updated demo feed info. 2015-10-12 19:00:46 +02:00
8044f7d52b Implemented feed aggregation filtering based on categories. 2015-10-12 15:53:50 +02:00
ed24eb7c94 Updated theme example, to have only 2 feeds. 2015-10-09 19:47:49 +02:00
43d6b4a197 Committed module files installed for demo example. 2015-10-09 19:45:21 +02:00
dffd06e331 Implemented a basic block caching system.
- for block {block_id}, to have a cache with 3600 seconds of expiration,
    declare in the cms.ini
     [blocks]
     {block_id}.expiration=3600

Added support for size in feed aggregation with new field "size"
2015-10-09 19:38:57 +02:00
463105f29f Added feed aggregation module.
Redesigned the CMS_BLOCK system,
   - added condition attribute. It can be set via configuration file
     with
     [blocks]
      {blockid}.region={region_name}
      {blockid}.conditions[]=is_front
      {blockid}.conditions[]=path:location-path/foo/bar
   - For backward compatibility, the CMS will check only conditions for block name prefixed by "?".
Improved the configuration library to support list and table properties.
Updated theme for now, to include the feed examples.
Added "cache" classes, to ease caching of html output for instance. (TODO: improve by providing a cache manager).
2015-10-08 13:56:31 +02:00
abebd00a4f Added feed aggregation module.
Improved the CMS Block system to support condition.
2015-10-05 16:04:24 +02:00
ec53a2682b Updated notification mailer, to always store output messages.
Fixed CMS_RESPONSE, and specific error response, to return expected status code.
2015-09-28 10:47:57 +02:00
jvelilla
7b2e6ab7b4 Merge branch 'jvelilla-roc_jv_issues' 2015-09-15 14:35:35 -03:00
jvelilla
87f4de1264 Merge branch 'roc_jv_issues' of https://github.com/jvelilla/ROC into roc_jv_issues 2015-09-15 14:30:02 -03:00
jvelilla
ed614a662c Updated CMS node and blog to remove extension data.
Comments: minor update.

Updated CMS_NODE_STORAGE_I API.
Delete a node using a node as formal parameter instead of node id.
Clean code and update log information.

Added precondition to delete node to accept nodes with a valid a id.

Added missing assertions tag names.
2015-09-15 14:28:33 -03:00
jvelilla
d54ad59e5f Added missing assertions tag names. 2015-09-15 14:10:51 -03:00
jvelilla
9173ef2ded Added precondition to delete node to accept nodes with a valid a id. 2015-09-15 11:40:13 -03:00
jvelilla
ad9e908dc2 Updated CMS_NODE_STORAGE_I API.
Delete a node using a node as formal parameter instead of node id.
Clean code and update log information.
2015-09-15 10:42:30 -03:00
jvelilla
4584917877 Comments: minor update. 2015-09-15 09:02:38 -03:00
jvelilla
f7d68d09e4 Updated CMS node and blog to remove extension data. 2015-09-15 08:54:43 -03:00
f9ecd4956f Keep the until date in the form data, so that new filter will remember the until date. 2015-09-09 23:12:52 +02:00
109 changed files with 4235 additions and 425 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="cms" uuid="8CC0D052-57D1-4CAA-AFF1-448FA290734B" library_target="cms">
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="cms" uuid="8CC0D052-57D1-4CAA-AFF1-448FA290734B" library_target="cms">
<target name="cms">
<root all_classes="true"/>
<file_rule>
@@ -14,14 +14,16 @@
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension-safe.ecf"/>
<library name="cms_app_env" location=".\library\app_env\app_env-safe.ecf"/>
<library name="cms_model" location=".\library\model\cms_model-safe.ecf" readonly="false"/>
<library name="cms_config" location=".\library\configuration\config-safe.ecf"/>
<library name="cms_model" location=".\library\model\cms_model-safe.ecf" readonly="false"/>
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf" readonly="false"/>
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
<library name="i18n" location="$ISE_LIBRARY\library\i18n\i18n-safe.ecf"/>
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
<library name="kmp_matcher" location="$ISE_LIBRARY\library\text\regexp\kmp_matcher\kmp_matcher-safe.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
<library name="notification_mailer" location="$ISE_LIBRARY\contrib\library\runtime\process\notification_email\notification_email-safe.ecf"/>
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty-safe.ecf" readonly="false"/>
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
@@ -30,7 +32,6 @@
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html-safe.ecf" readonly="false"/>
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
</system>

View File

@@ -15,14 +15,16 @@
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension.ecf"/>
<library name="cms_app_env" location=".\library\app_env\app_env.ecf"/>
<library name="cms_model" location=".\library\model\cms_model.ecf" readonly="false"/>
<library name="cms_config" location=".\library\configuration\config.ecf"/>
<library name="cms_model" location=".\library\model\cms_model.ecf" readonly="false"/>
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto.ecf"/>
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder.ecf" readonly="false"/>
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error.ecf"/>
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http.ecf"/>
<library name="i18n" location="$ISE_LIBRARY\library\i18n\i18n.ecf"/>
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
<library name="kmp_matcher" location="$ISE_LIBRARY\library\text\regexp\kmp_matcher\kmp_matcher.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/>
<library name="notification_mailer" location="$ISE_LIBRARY\contrib\library\runtime\process\notification_email\notification_email.ecf"/>
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty.ecf" readonly="false"/>
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter.ecf"/>
@@ -31,7 +33,6 @@
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension.ecf" readonly="false"/>
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html.ecf" readonly="false"/>
<library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
</system>

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="demo" uuid="3643E657-BCBE-46AA-931B-71EAEA877A18" library_target="demo">
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="demo" uuid="3643E657-BCBE-46AA-931B-71EAEA877A18" library_target="demo">
<description>Example/demo for Eiffel ROC CMS library</description>
<target name="common" abstract="true">
<root class="DEMO_CMS_SERVER" feature="make_and_launch"/>
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
@@ -12,45 +13,48 @@
</option>
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="cms" location="..\..\cms-safe.ecf" readonly="false"/>
<library name="cms" location="..\..\cms-safe.ecf" readonly="false">
<option>
<assertions precondition="true" postcondition="true" supplier_precondition="true"/>
</option>
</library>
<library name="cms_admin_module" location="..\..\modules\admin\admin-safe.ecf" readonly="false"/>
<library name="cms_app_env" location="..\..\library\app_env\app_env-safe.ecf" readonly="false"/>
<library name="cms_auth_module" location="..\..\modules\auth\auth-safe.ecf" readonly="false"/>
<library name="cms_basic_auth_module" location="..\..\modules\basic_auth\basic_auth-safe.ecf" readonly="false"/>
<library name="cms_blog_module" location="..\..\modules\blog\cms_blog_module-safe.ecf" readonly="false"/>
<library name="cms_demo_module" location="modules\demo\cms_demo_module-safe.ecf" readonly="false"/>
<library name="cms_email_service" location="..\..\library\email\email-safe.ecf" readonly="false"/>
<library name="cms_feed_aggregator_module" location="..\..\modules\feed_aggregator\feed_aggregator-safe.ecf" readonly="false"/>
<library name="cms_model" location="..\..\library\model\cms_model-safe.ecf" readonly="false"/>
<library name="cms_node_module" location="..\..\modules\node\node-safe.ecf" readonly="false"/>
<library name="cms_oauth_20_module" location="..\..\modules\oauth20\oauth20-safe.ecf" readonly="false"/>
<library name="cms_openid_module" location="..\..\modules\openid\openid-safe.ecf" readonly="false"/>
<library name="cms_admin_module" location="..\..\modules\admin\admin-safe.ecf" readonly="false"/>
<library name="cms_recent_changes_module" location="..\..\modules\recent_changes\recent_changes-safe.ecf" readonly="false"/>
<library name="persistence_store_odbc" location="..\..\library\persistence\store_odbc\store_odbc-safe.ecf" readonly="false"/>
<library name="persistence_sqlite3" location="..\..\library\persistence\sqlite3\sqlite3-safe.ecf" readonly="false">
<option>
<assertions/>
</option>
</library>
<library name="persistence_store_odbc" location="..\..\library\persistence\store_odbc\store_odbc-safe.ecf" />
<!--
<library name="persistence_store_mysql" location="..\..\library\persistence\store_mysql\store_mysql-safe.ecf" readonly="false"/>
<library name="persistence_store_mysql" location="..\..\library\persistence\store_mysql\store_mysql-safe.ecf" />
-->
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
</target>
<target name="demo_any" extends="common">
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
<setting name="concurrency" value="thread"/>
<library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi-safe.ecf"/>
<library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi-safe.ecf"/>
<library name="nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\nino-safe.ecf"/>
<library name="standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\standalone-safe.ecf"/>
<cluster name="launcher" location=".\launcher\any\" recursive="true"/>
<library name="any_launcher" location="..\..\launcher\any-safe.ecf" readonly="false"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
<target name="demo_standalone" extends="common">
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
<option debug="true">
<debug name="dbglog" enabled="true"/>
</option>
<setting name="concurrency" value="thread"/>
<setting name="concurrency" value="scoop"/>
<variable name="httpd_ssl_disabled" value="true"/>
<library name="default_standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\standalone-safe.ecf"/>
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
<library name="standalone_launcher" location="..\..\launcher\standalone-safe.ecf" readonly="false"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
<target name="demo_standalone_none" extends="demo_standalone">
@@ -62,25 +66,14 @@
<target name="demo_standalone_scoop" extends="demo_standalone">
<setting name="concurrency" value="scoop"/>
</target>
<target name="demo_nino" extends="common">
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
<setting name="concurrency" value="none"/>
<library name="default_nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\nino-safe.ecf"/>
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
<target name="demo_cgi" extends="common">
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
<setting name="concurrency" value="none"/>
<library name="default_cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\cgi-safe.ecf"/>
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
<library name="cgi_launcher" location="..\..\launcher\cgi-safe.ecf" readonly="false"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
<target name="demo_libfcgi" extends="common">
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
<setting name="concurrency" value="none"/>
<library name="default_libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\libfcgi-safe.ecf"/>
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
<library name="libfcgi_launcher" location="..\..\launcher\libfcgi-safe.ecf" readonly="false"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
<target name="demo" extends="demo_standalone">

View File

@@ -10,3 +10,4 @@ set ROC_CMS_DIR=%~dp0
%ROC_CMD% install --module ..\..\modules\oauth20 --dir %ROC_CMS_DIR%
%ROC_CMD% install --module ..\..\modules\openid --dir %ROC_CMS_DIR%
%ROC_CMD% install --module ..\..\modules\recent_changes --dir %ROC_CMS_DIR%
%ROC_CMD% install --module ..\..\modules\feed_aggregator --dir %ROC_CMS_DIR%

View File

@@ -93,7 +93,7 @@ feature -- Hooks
block_list: ITERABLE [like {CMS_BLOCK}.name]
do
Result := <<"demo-info">>
Result := <<"?demo-info">>
end
get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
@@ -103,8 +103,8 @@ feature -- Hooks
m: CMS_MENU
lnk: CMS_LOCAL_LINK
do
if a_block_id.is_case_insensitive_equal_general ("demo-info") then
if a_response.request.request_uri.starts_with ("/demo/") then
if a_block_id.same_string ("demo-info") then
if a_response.location.starts_with_general ("demo/") then
create m.make_with_title (a_block_id, "Demo", 2)
create lnk.make ("demo: abc", "demo/abc")
m.extend (lnk)

View File

@@ -0,0 +1,38 @@
### Blocks settings
#navigation.region=sidebar_first
#navigation.condition=is_front
management.conditions[]=path:admin*
management.conditions[]=is_front
#Feeds
feed.news.weight=3
feed.news.region=feed_news
feed.news.region=content
feed.news.condition=<none>
feed.forum.weight=2
feed.forum.region=feed_forum
feed.forum.region=<none>
feed.forum.condition=<none>
feed.forum.options[size]=15
#Updates
recent_changes.region=content
recent_changes.condition=is_front
recent_changes.title=Updates
recent_changes.options[size]=3
#Aliases
&aliases[foo]=management
&aliases[bar]=feed.forum
foo.region=content
foo.condition=is_front
foo.weight=-10
bar.region=content
bar.condition=is_front
bar.title=Bar

View File

@@ -9,9 +9,9 @@ email=your@email.com
theme=bootstrap
[mailer]
smtp=localhost:25
#smtp=localhost:25
#sendmail=/usr/bin/sendmail
#output=@stderr
output=@stderr
[modules]
# Module status
@@ -20,20 +20,11 @@ smtp=localhost:25
# Default is "on"
# for each module, this can be overwritten with
# module_name= on or off
*=off
admin=on
auth=on
basic_auth=on
blog=on
debug=on
demo=on
node=on
oauth20=on
openid=on
*=all
[blocks]
#navigation.region=sidebar_first
@include=blocks.ini
[admin]
# CMS Installation, are accessible by "all", "none" or uppon "permission". (default is none)
installation_access=permission
installation_access=all

View File

@@ -1,10 +1,15 @@
{
"database": {
"datasource": {
"driver": "odbc",
"environment": "odbc-sqlite"
"driver": "sqlite3",
"environment": "sqlite3",
"-driver": "odbc",
"-environment": "odbc-sqlite"
},
"environments": {
"sqlite3": {
"connection_string":"Database=./site/database.sqlite3;"
},
"odbc-sqlite": {
"connection_string":"Driver=SQLite3 ODBC Driver;Database=./site/database.sqlite;LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;"
},

View File

@@ -0,0 +1,28 @@
{
"ids": ["news", "forum"],
"feeds": {
"news": {
"title": "Eiffel related posts",
"expiration": "21600",
"size": 5,
"locations": [
"https://bertrandmeyer.com/feed/",
"https://room.eiffel.com/blog/feed",
"https://room.eiffel.com/article/feed",
"https://room.eiffel.com/library/feed"
]
, "categories": ["Eiffel"]
,"option_description": "enabled"
},
"forum": {
"title": "Eiffel Forum",
"expiration": "21600",
"size": 5,
"locations": [
"https://groups.google.com/forum/feed/eiffel-users/msgs/atom.xml?num=15",
"http://stackoverflow.com/feeds/tag?tagnames=eiffel&sort=newest"
]
,"option_description": "enabled"
}
}
}

View File

@@ -0,0 +1,53 @@
div.feed ul {
list-style: none;
position: relative;
padding: 0;
margin: 0;
width: 99%;
}
div.feed li {
/* border-top: solid 1px #ddd; */
padding: 0;
margin: 0 0 5px 0;
}
div.feed li a {
font-weight: bold;
}
div.feed li .date {
font-weight: bold;
font-size: small;
}
div.feed li .category {
margin-left: 20px;
font-size: 8px;
height: 9px;
overflow: hidden;
color: #999;
}
div.feed li .description {
margin-left: 20px;
font-size: small;
height: 18px;
overflow: hidden;
color: #999;
}
div.feed li:hover {
margin-bottom: 23px;
}
div.feed li:hover .description {
padding: 5px;
position: absolute;
height: auto;
overflow-y: scroll;
overflow-x: scroll;
color: #000;
background-color: #fff;
border: solid 1px #000;
z-index: 10;
}
div.feed li:hover:last-child {
margin-bottom: 28px;
}
div.feed li .description::after {
content: "...";
}

View File

@@ -0,0 +1,54 @@
div.feed {
ul {
list-style: none;
position: relative;
padding: 0;
margin: 0;
width: 99%;
}
li {
/* border-top: solid 1px #ddd; */
padding: 0;
margin: 0 0 5px 0;
a {
font-weight: bold;
}
.date {
font-weight: bold;
font-size: small;
}
.category {
margin-left: 20px;
font-size: 8px;
height: 9px;
overflow: hidden;
color: #999;
}
.description {
margin-left: 20px;
font-size: small;
height: 18px;
overflow: hidden;
color: #999;
}
&:hover {
margin-bottom: 23px;
.description {
padding: 5px;
position: absolute;
height: auto;
overflow-y: scroll;
overflow-x: scroll;
color: #000;
background-color: #fff;
border: solid 1px #000;
z-index: 10;
}
&:last-child {
margin-bottom: 28px;
}
}
.description::after { content: "..."; }
}
}

View File

@@ -62,9 +62,15 @@
<!-- Main Content Section -->
{unless isempty="$page_title"}<h1 class="page-title">{$page_title/}</h1>{/unless}
{$page.region_content/}
{if condition="$page.is_front"}
{if isset="$page.region_feed_news"}
<div class="column" style="width: 45%; float: left">{$page.region_feed_news/}</div>
{/if}
{if isset="$page.region_feed_forum"}
<div class="column" style="width: 45%; float: left">{$page.region_feed_forum/}</div>
{/if}
{/if}
</div>
</div>
</div>

View File

@@ -1,31 +1,21 @@
note
description: "Summary description for {EWF_ROC_SERVER_EXECUTION}."
description: "[
CMS Execution for the demo server.
]"
date: "$Date$"
revision: "$Revision$"
class
EWF_ROC_SERVER_EXECUTION
DEMO_CMS_EXECUTION
inherit
CMS_EXECUTION
redefine
initialize
end
REFACTORING_HELPER
SHARED_LOGGER
create
make
feature {NONE} -- Initialization
initialize
do
Precursor
end
initial_cms_setup: CMS_DEFAULT_SETUP
-- CMS setup.
local
@@ -39,17 +29,17 @@ feature {NONE} -- Initialization
create Result.make (l_env)
end
feature -- CMS setup
feature -- CMS storage
setup_storage (a_setup: CMS_SETUP)
do
debug ("refactor_fixme")
to_implement ("To implement custom storage")
end
a_setup.storage_drivers.force (create {CMS_STORAGE_SQLITE3_BUILDER}.make, "sqlite3")
-- a_setup.storage_drivers.force (create {CMS_STORAGE_STORE_MYSQL_BUILDER}.make, "mysql")
a_setup.storage_drivers.force (create {CMS_STORAGE_STORE_ODBC_BUILDER}.make, "odbc")
end
feature -- CMS modules
setup_modules (a_setup: CMS_SETUP)
-- Setup additional modules.
local
@@ -82,6 +72,9 @@ feature -- CMS setup
create {CMS_RECENT_CHANGES_MODULE} m.make
a_setup.register_module (m)
-- Recent changes
create {FEED_AGGREGATOR_MODULE} m.make
a_setup.register_module (m)
-- Miscellanious
create {CMS_DEBUG_MODULE} m.make

View File

@@ -0,0 +1,18 @@
note
description: "[
DEMO application server.
]"
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
revision: "$Revision: 96596 $"
class
DEMO_CMS_SERVER
inherit
ROC_CMS_LAUNCHER [DEMO_CMS_EXECUTION]
create
make_and_launch
end

10
launcher/README.txt Normal file
View File

@@ -0,0 +1,10 @@
Collection of ROC CMS launcher ready to use.
- Include any-safe.ecf to use any of cgi, libfcgi or standalone connector.
- Include standalone-safe.ecf to use standalone connector.
- Include libfcgi-safe.ecf to use libfcgi connector.
- Include cgi-safe.ecf to use cgi connector.
In application, the root class need to inherit from ROC_CMS_LAUNCHER with adapted CMS_EXECUTION
descendant.

18
launcher/any-safe.ecf Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="launcher" uuid="6FDCA393-AFC3-436B-A58A-870923967C86" library_target="launcher">
<target name="common" abstract="true">
<root all_classes="true"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="cms" location="..\cms-safe.ecf"/>
<library name="cms_app_env" location="..\library\app_env\app_env-safe.ecf" readonly="false"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
</target>
<target name="launcher" extends="common">
<library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi-safe.ecf"/>
<library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi-safe.ecf"/>
<library name="nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\nino-safe.ecf"/>
<library name="standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\standalone-safe.ecf"/>
<cluster name="src" location=".\" recursive="false"/>
<cluster name="launcher" location=".\any\" recursive="true"/>
</target>
</system>

19
launcher/any.ecf Normal file
View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="launcher" uuid="6FDCA393-AFC3-436B-A58A-870923967C86" library_target="launcher">
<target name="common" abstract="true">
<root all_classes="true"/>
<option void_safety="none" />
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="cms" location="..\cms.ecf"/>
<library name="cms_app_env" location="..\library\app_env\app_env.ecf" readonly="false"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
</target>
<target name="launcher" extends="common">
<library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi.ecf"/>
<library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi.ecf"/>
<library name="nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\nino.ecf"/>
<library name="standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\standalone.ecf"/>
<cluster name="src" location=".\" recursive="false"/>
<cluster name="launcher" location=".\any\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,19 @@
note
description: "[
Effective class for APPLICATION_LAUNCHER_I
You can put modification in this class
]"
date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $"
revision: "$Revision: 36 $"
class
APPLICATION_LAUNCHER [G -> WSF_EXECUTION create make end]
inherit
APPLICATION_LAUNCHER_I [G]
feature -- Custom
end

View File

@@ -0,0 +1,127 @@
note
description: "[
Specific application launcher
DO NOT EDIT THIS CLASS
you can customize APPLICATION_LAUNCHER
]"
date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $"
revision: "$Revision: 36 $"
deferred class
APPLICATION_LAUNCHER_I [G -> WSF_EXECUTION create make end]
inherit
SHARED_EXECUTION_ENVIRONMENT
feature -- Execution
launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
nature: like launcher_nature
do
nature := launcher_nature
if nature = Void then
launch_standalone (opts)
elseif nature = nature_standalone then
launch_standalone (opts)
elseif nature = nature_nino then
launch_nino (opts)
elseif nature = nature_cgi then
launch_cgi (opts)
elseif nature = nature_libfcgi then
launch_libfcgi (opts)
else
-- bye bye
(create {EXCEPTIONS}).die (-1)
end
end
feature {NONE} -- Access
launcher_nature: detachable READABLE_STRING_8
-- Initialize the launcher nature
-- either cgi, libfcgi, or nino.
--| We could extend with more connector if needed.
--| and we could use WSF_DEFAULT_SERVICE_LAUNCHER to configure this at compilation time.
local
p: PATH
ext: detachable READABLE_STRING_32
do
create p.make_from_string (execution_environment.arguments.command_name)
if attached p.entry as l_entry then
ext := l_entry.extension
end
if ext /= Void then
if ext.same_string (nature_standalone) then
Result := nature_standalone
end
if ext.same_string (nature_nino) then
Result := nature_nino
end
if ext.same_string (nature_cgi) then
Result := nature_cgi
end
if ext.same_string (nature_libfcgi) or else ext.same_string ("fcgi") then
Result := nature_libfcgi
end
end
Result := default_nature
end
feature {NONE} -- standalone
nature_standalone: STRING = "standalone"
launch_standalone (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
launcher: WSF_STANDALONE_SERVICE_LAUNCHER [G]
do
create launcher.make_and_launch (opts)
end
feature {NONE} -- nino
nature_nino: STRING = "nino"
launch_nino (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
launcher: WSF_NINO_SERVICE_LAUNCHER [G]
do
create launcher.make_and_launch (opts)
end
feature {NONE} -- cgi
nature_cgi: STRING = "cgi"
launch_cgi (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
launcher: WSF_CGI_SERVICE_LAUNCHER [G]
do
create launcher.make_and_launch (opts)
end
feature {NONE} -- libfcgi
nature_libfcgi: STRING = "libfcgi"
launch_libfcgi (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
launcher: WSF_LIBFCGI_SERVICE_LAUNCHER [G]
do
create launcher.make_and_launch (opts)
end
feature -- Default
default_nature: STRING
do
Result := nature_standalone
end
end

15
launcher/cgi-safe.ecf Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="cgi_launcher" uuid="0FE4F1D0-BB70-4C7F-A66E-B27F1D718109" library_target="cgi_launcher">
<target name="common" abstract="true">
<root all_classes="true"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="cms" location="..\cms-safe.ecf"/>
<library name="cms_app_env" location="..\library\app_env\app_env-safe.ecf" readonly="false"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
</target>
<target name="cgi_launcher" extends="common">
<library name="default_cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\cgi-safe.ecf"/>
<cluster name="src" location=".\" recursive="false"/>
<cluster name="launcher" location=".\default\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,19 @@
note
description: "[
Effective class for APPLICATION_LAUNCHER_I
You can put modification in this class
]"
date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $"
revision: "$Revision: 36 $"
class
APPLICATION_LAUNCHER [G -> WSF_EXECUTION create make end]
inherit
APPLICATION_LAUNCHER_I [G]
feature -- Custom
end

View File

@@ -0,0 +1,26 @@
note
description: "[
Specific application launcher
DO NOT EDIT THIS CLASS
you can customize APPLICATION_LAUNCHER
]"
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
revision: "$Revision: 96596 $"
deferred class
APPLICATION_LAUNCHER_I [G -> WSF_EXECUTION create make end]
feature -- Execution
launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
launcher: WSF_DEFAULT_SERVICE_LAUNCHER [G]
do
create launcher.make_and_launch (opts)
end
end

15
launcher/libfcgi-safe.ecf Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="libfcgi_launcher" uuid="04D7D1EA-059B-4024-B0DE-BBB57AB2D00C" library_target="libfcgi_launcher">
<target name="common" abstract="true">
<root all_classes="true"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="cms" location="..\cms-safe.ecf"/>
<library name="cms_app_env" location="..\library\app_env\app_env-safe.ecf" readonly="false"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
</target>
<target name="libfcgi_launcher" extends="common">
<library name="default_libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\libfcgi-safe.ecf"/>
<cluster name="src" location=".\" recursive="false"/>
<cluster name="launcher" location=".\default\" recursive="true"/>
</target>
</system>

16
launcher/libfcgi.ecf Normal file
View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="libfcgi_launcher" uuid="04D7D1EA-059B-4024-B0DE-BBB57AB2D00C" library_target="libfcgi_launcher">
<target name="common" abstract="true">
<root all_classes="true"/>
<option void_safety="none" />
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="cms" location="..\cms.ecf"/>
<library name="cms_app_env" location="..\library\app_env\app_env.ecf" readonly="false"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
</target>
<target name="libfcgi_launcher" extends="common">
<library name="default_libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\libfcgi.ecf"/>
<cluster name="src" location=".\" recursive="false"/>
<cluster name="launcher" location=".\default\" recursive="true"/>
</target>
</system>

View File

@@ -1,12 +1,12 @@
note
description: "[
application service
Reusable ROC CMS launcher.
]"
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
revision: "$Revision: 96596 $"
class
EWF_ROC_SERVER
ROC_CMS_LAUNCHER [G -> CMS_EXECUTION create make end]
inherit
WSF_LAUNCHABLE_SERVICE
@@ -37,16 +37,27 @@ feature {NONE} -- Initialization
-- Initialize current service.
local
env: CMS_ENVIRONMENT
l_app_name: detachable READABLE_STRING_32
do
Precursor
create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI} service_options.make_from_file ("demo.ini")
create env.make_default
l_app_name := optional_application_name
if l_app_name = Void then
l_app_name := env.name
end
create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI} service_options.make_from_file (l_app_name + ".ini")
initialize_logger (env)
end
optional_application_name: detachable READABLE_STRING_32
-- Optional application name.
--| Redefine if needed.
do
end
feature {NONE} -- Launch operation
launcher: APPLICATION_LAUNCHER [EWF_ROC_SERVER_EXECUTION]
launcher: APPLICATION_LAUNCHER [G]
launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
@@ -70,7 +81,7 @@ feature {NONE} -- Launch operation
l_message.append ("%N%N")
end
else
l_message.append ("The application crash without available information")
l_message.append ("The application crashed without information.")
l_message.append ("%N%N")
end
-- send email shutdown

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="standalone_launcher" uuid="F42660A9-26C2-466B-A63C-C7823C808BE7" library_target="standalone_launcher">
<target name="common" abstract="true">
<root all_classes="true"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="cms" location="..\cms-safe.ecf"/>
<library name="cms_app_env" location="..\library\app_env\app_env-safe.ecf" readonly="false"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
</target>
<target name="standalone_launcher" extends="common">
<library name="default_standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\standalone-safe.ecf"/>
<library name="standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\standalone-safe.ecf"/>
<cluster name="src" location=".\" recursive="false"/>
<cluster name="launcher" location=".\default\" recursive="true"/>
</target>
</system>

17
launcher/standalone.ecf Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="standalone_launcher" uuid="F42660A9-26C2-466B-A63C-C7823C808BE7" library_target="standalone_launcher">
<target name="common" abstract="true">
<root all_classes="true"/>
<option void_safety="none" />
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="cms" location="..\cms.ecf"/>
<library name="cms_app_env" location="..\library\app_env\app_env.ecf" readonly="false"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
</target>
<target name="standalone_launcher" extends="common">
<library name="default_standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\standalone.ecf"/>
<library name="standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\standalone.ecf"/>
<cluster name="src" location=".\" recursive="false"/>
<cluster name="launcher" location=".\default\" recursive="true"/>
</target>
</system>

View File

@@ -33,11 +33,53 @@ feature -- Query
end
end
resolved_text_list_item (k: READABLE_STRING_GENERAL): detachable LIST [READABLE_STRING_32]
-- List of String item associated with key `k',
-- and expanded values to resolved variables ${varname}.
do
if attached text_list_item (k) as lst then
from
lst.start
until
lst.after
loop
lst.replace (resolved_expression (lst.item))
lst.forth
end
end
end
resolved_text_table_item (k: READABLE_STRING_GENERAL): detachable STRING_TABLE [READABLE_STRING_32]
-- Table of String item associated with key `k',
-- and expanded values to resolved variables ${varname}.
do
if attached text_table_item (k) as tb then
from
tb.start
until
tb.after
loop
tb.replace (resolved_expression (tb.item_for_iteration), tb.key_for_iteration)
tb.forth
end
end
end
text_item (k: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
-- String item associated with key `k'.
deferred
end
text_list_item (k: READABLE_STRING_GENERAL): detachable LIST [READABLE_STRING_32]
-- List of String item associated with key `k'.
deferred
end
text_table_item (k: READABLE_STRING_GENERAL): detachable STRING_TABLE [READABLE_STRING_32]
-- Table of String item associated with key `k'.
deferred
end
integer_item (k: READABLE_STRING_GENERAL): INTEGER
-- Integer item associated with key `k'.
deferred
@@ -109,7 +151,7 @@ feature -- Duplication
end
note
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -119,14 +119,47 @@ feature -- Access: Config Reader
text_item (k: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
-- String item associated with key `k'.
local
obj: like item
do
obj := item (k)
if attached {READABLE_STRING_32} obj as s32 then
Result := s32
elseif attached {READABLE_STRING_8} obj as s then
Result := utf.utf_8_string_8_to_escaped_string_32 (s)
Result := value_to_string_32 (item (k))
end
text_list_item (k: READABLE_STRING_GENERAL): detachable LIST [READABLE_STRING_32]
-- List of String item associated with key `k'.
do
if attached {LIST [READABLE_STRING_8]} item (k) as l_list then
create {ARRAYED_LIST [READABLE_STRING_32]} Result.make (l_list.count)
Result.compare_objects
across
l_list as ic
until
Result = Void
loop
if attached value_to_string_32 (ic.item) as s32 then
Result.force (s32)
else
Result := Void
end
end
end
end
text_table_item (k: READABLE_STRING_GENERAL): detachable STRING_TABLE [READABLE_STRING_32]
-- Table of String item associated with key `k'.
do
if attached {STRING_TABLE [READABLE_STRING_8]} item (k) as l_list then
create {STRING_TABLE [READABLE_STRING_32]} Result.make (l_list.count)
Result.compare_objects
across
l_list as ic
until
Result = Void
loop
if attached value_to_string_32 (ic.item) as s32 then
Result.force (s32, ic.key)
else
Result := Void
end
end
end
end
@@ -226,6 +259,15 @@ feature -- Access
feature {NONE} -- Implementation
value_to_string_32 (obj: detachable ANY): detachable STRING_32
do
if attached {READABLE_STRING_32} obj as s32 then
Result := s32
elseif attached {READABLE_STRING_8} obj as s then
Result := utf.utf_8_string_8_to_escaped_string_32 (s)
end
end
item_from_values (a_values: STRING_TABLE [ANY]; k: READABLE_STRING_GENERAL): detachable ANY
local
i,j: INTEGER
@@ -460,7 +502,7 @@ feature {NONE} -- Implementation
invariant
note
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -63,10 +63,46 @@ feature -- Access: Config Reader
text_item (k: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
-- String item associated with query `k'.
do
if attached {JSON_STRING} item (k) as l_string then
Result := l_string.unescaped_string_32
elseif attached {JSON_NUMBER} item (k) as l_number then
Result := l_number.item
Result := value_to_string_32 (item (k))
end
text_list_item (k: READABLE_STRING_GENERAL): detachable LIST [READABLE_STRING_32]
-- List of String item associated with key `k'.
do
if attached {JSON_ARRAY} item (k) as l_array then
create {ARRAYED_LIST [READABLE_STRING_32]} Result.make (l_array.count)
Result.compare_objects
across
l_array as ic
until
Result = Void
loop
if attached value_to_string_32 (ic.item) as s32 then
Result.force (s32)
else
Result := Void
end
end
end
end
text_table_item (k: READABLE_STRING_GENERAL): detachable STRING_TABLE [READABLE_STRING_32]
-- Table of String item associated with key `k'.
do
if attached {JSON_OBJECT} item (k) as obj then
create {STRING_TABLE [READABLE_STRING_32]} Result.make (obj.count)
Result.compare_objects
across
obj as ic
until
Result = Void
loop
if attached value_to_string_32 (ic.item) as s32 then
Result.force (s32, ic.key.item)
else
Result := Void
end
end
end
end
@@ -105,6 +141,15 @@ feature -- Access
feature {NONE} -- Implementation
value_to_string_32 (v: detachable ANY): detachable STRING_32
do
if attached {JSON_STRING} v as l_string then
Result := l_string.unescaped_string_32
elseif attached {JSON_NUMBER} v as l_number then
Result := l_number.item
end
end
object_json_value (a_object: JSON_OBJECT; a_query: READABLE_STRING_32): detachable JSON_VALUE
-- Item associated with query `a_query' from object `a_object' if any.
local
@@ -163,7 +208,7 @@ feature {NONE} -- JSON
end
note
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -21,6 +21,18 @@ feature -- Test
create {INI_CONFIG} cfg.make_from_string ("[
foo = bar
collection[] = a
collection[] = b
collection[] = c
collection[] = 1
collection[] = 2
collection[] = 3
table[a] = 1
table[b] = 2
table[c] = 3
table[d] = test
[first]
abc = 1
def = and so on
@@ -58,6 +70,21 @@ feature -- Test
assert ("has_item (second.is)", cfg.has_item ("second.is"))
assert ("item (second.is)", attached cfg.text_item ("second.is") as v and then v.same_string_general ("2"))
assert ("has_item (collection)", cfg.has_item ("collection"))
assert ("item (collection)", attached cfg.text_list_item ("collection") as lst and then (
lst.has ("a") and lst.has ("b") and lst.has ("c") and lst.has ("1") and lst.has ("2") and lst.has ("3")
)
)
assert ("has_item (table)", cfg.has_item ("table"))
assert ("item (table)", attached cfg.text_table_item ("table") as tb and then (
tb.item ("a") ~ {STRING_32} "1" and
tb.item ("b") ~ {STRING_32} "2" and
tb.item ("c") ~ {STRING_32} "3" and
tb.item ("d") ~ {STRING_32} "test"
)
)
if attached cfg.sub_config ("second") as cfg_second then
assert ("has_item (is)", cfg_second.has_item ("is"))
assert ("item (is)", attached cfg_second.text_item ("is") as v and then v.same_string_general ("2"))
@@ -141,7 +168,9 @@ feature -- Test
"is": 2,
"the": 3,
"end": 4
}
},
"collection": ["a", "b", "c", 1, 2, 3],
"table": { "a": 1, "b": 2, "c": 3, "d" : "test" }
}
]")
@@ -164,6 +193,21 @@ feature -- Test
assert ("item (second.the)", attached cfg.text_item ("second.the") as v and then v.same_string_general ("3"))
assert ("item (second.end)", attached cfg.text_item ("second.end") as v and then v.same_string_general ("4"))
assert ("has_item (collection)", cfg.has_item ("collection"))
assert ("item (collection)", attached cfg.text_list_item ("collection") as lst and then (
lst.has ("a") and lst.has ("b") and lst.has ("c") and lst.has ("1") and lst.has ("2") and lst.has ("3")
)
)
assert ("has_item (table)", cfg.has_item ("table"))
assert ("item (table)", attached cfg.text_table_item ("table") as tb and then (
tb.item ("a") ~ {STRING_32} "1" and
tb.item ("b") ~ {STRING_32} "2" and
tb.item ("c") ~ {STRING_32} "3" and
tb.item ("d") ~ {STRING_32} "test"
)
)
if attached cfg.sub_config ("second") as cfg_second then
assert ("has_item (is)", cfg_second.has_item ("is"))
assert ("item (is)", attached cfg_second.text_item ("is") as v and then v.same_string_general ("2"))

View File

@@ -28,7 +28,6 @@ feature {NONE} -- Initialization
-- Initialize service.
do
admin_email := parameters.admin_email
create {NOTIFICATION_SMTP_MAILER} mailer.make (parameters.smtp_server)
set_successful
end

View File

@@ -86,8 +86,23 @@ feature -- Query
sql_post_execution
end
sql_change (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
-- Execute an sql query change `a_sql_statement' with the params `a_params'.
sql_finalize
-- <Precursor>
do
-- N/A
end
sql_insert (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
-- <Precursor>
do
check_sql_query_validity (a_sql_statement, a_params)
db_handler.set_query (create {DATABASE_QUERY}.data_reader (a_sql_statement, a_params))
db_handler.execute_change
sql_post_execution
end
sql_modify (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
-- <Precursor>
do
check_sql_query_validity (a_sql_statement, a_params)
db_handler.set_query (create {DATABASE_QUERY}.data_reader (a_sql_statement, a_params))
@@ -133,4 +148,32 @@ feature -- Query
end
end
sql_read_integer_32 (a_index: INTEGER): INTEGER_32
-- Retrieved value at `a_index' position in `item'.
local
l_item: like sql_item
do
l_item := sql_item (a_index)
if attached {INTEGER_32} l_item as i then
Result := i
elseif attached {INTEGER_32_REF} l_item as l_value then
Result := l_value.item
else
check is_integer_32: False end
end
end
sql_read_date_time (a_index: INTEGER): detachable DATE_TIME
-- Retrieved value at `a_index' position in `item'.
local
l_item: like sql_item
do
l_item := sql_item (a_index)
if attached {DATE_TIME} l_item as dt then
Result := dt
else
check is_date_time_or_null: l_item = Void end
end
end
end

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="persistence_sqlite3" uuid="4E536C92-A09F-4305-8230-2EC5ABC51416" library_target="persistence_sqlite3">
<target name="persistence_sqlite3">
<root all_classes="true"/>
<option warning="true" void_safety="all">
<assertions precondition="true" supplier_precondition="true"/>
</option>
<setting name="console_application" value="true"/>
<library name="app_env" location="..\..\app_env\app_env-safe.ecf"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="cms" location="..\..\..\cms-safe.ecf"/>
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf"/>
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
<library name="logging" location="$ISE_LIBRARY\library\runtime\logging\logging-safe.ecf"/>
<library name="model" location="..\..\model\cms_model-safe.ecf"/>
<library name="sqlite3" location="$ISE_LIBRARY\unstable\library\persistency\database\sqlite3\sqlite-safe.ecf" readonly="false">
<option msil_application_optimize="false">
<assertions precondition="true" supplier_precondition="true"/>
</option>
</library>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<cluster name="persistence_sqlite" location=".\src\" recursive="true">
<file_rule>
<exclude>/old$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
</cluster>
</target>
</system>

View File

@@ -0,0 +1,450 @@
note
description: "Summary description for {CMS_STORAGE_MYSQL}."
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
revision: "$Revision: 96596 $"
class
CMS_STORAGE_SQLITE3
inherit
CMS_STORAGE_SQL
redefine
sql_read_date_time, sql_read_integer_32,
sql_read_string_32
end
CMS_CORE_STORAGE_SQL_I
redefine
sql_read_date_time, sql_read_integer_32,
sql_read_string_32
end
CMS_USER_STORAGE_SQL_I
redefine
sql_read_date_time, sql_read_integer_32,
sql_read_string_32
end
SQLITE_BIND_ARG_MARSHALLER
REFACTORING_HELPER
create
make
feature {NONE} -- Initialization
make (db: SQLITE_DATABASE)
do
sqlite := db
create error_handler.make
end
sqlite: SQLITE_DATABASE
-- Associated SQLite database.
feature -- Status report
is_initialized: BOOLEAN
-- Is storage initialized?
do
Result := has_user
end
feature -- Status report
is_available: BOOLEAN
-- Is storage available?
do
Result := sqlite.is_interface_usable
end
feature -- Basic operation
close
-- Close/disconnect current storage.
do
sqlite.close
end
feature -- Execution
transaction_depth: INTEGER
sql_begin_transaction
-- Start a database transtaction.
do
if transaction_depth = 0 then
sqlite.begin_transaction (False)
end
transaction_depth := transaction_depth + 1
debug ("roc_storage")
print ("# sql_begin_transaction (depth="+ transaction_depth.out +").%N")
end
end
sql_rollback_transaction
-- Rollback updates in the database.
do
if sqlite.is_in_transaction then
sqlite.rollback
end
transaction_depth := transaction_depth - 1
debug ("roc_storage")
print ("# sql_rollback_transaction (depth="+ transaction_depth.out +").%N")
end
end
sql_commit_transaction
-- Commit updates in the database.
do
if sqlite.is_in_transaction then
sqlite.commit
end
transaction_depth := transaction_depth - 1
debug ("roc_storage")
print ("# sql_commit_transaction (depth="+ transaction_depth.out +").%N")
end
end
sql_post_execution
-- Post database execution.
-- note: execute after each `sql_query' and `sql_change'.
do
debug ("roc_storage")
print ("# sql_post_execution.%N")
end
-- FIXME
if sqlite.has_error then
write_critical_log (generator + ".post_execution Error occurred!")
end
end
feature -- Operation
last_statement: detachable SQLITE_STATEMENT
last_sqlite_result_cursor: detachable SQLITE_STATEMENT_ITERATION_CURSOR
sql_query (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
-- <Precursor>
local
st: SQLITE_QUERY_STATEMENT
do
debug ("roc_storage")
print ("> sql_query (" +a_sql_statement + ").%N")
end
last_sqlite_result_cursor := Void
create st.make (a_sql_statement, sqlite)
last_statement := st
if st.is_compiled then
if a_params /= Void then
check st.has_arguments end
last_sqlite_result_cursor := st.execute_new_with_arguments (sqlite_arguments (a_params))
else
last_sqlite_result_cursor := st.execute_new
end
else
error_handler.add_custom_error (1, "invalid query", "query compilation failed!")
end
debug ("roc_storage")
print ("< sql_query (" +a_sql_statement + ").%N")
end
end
sql_finalize
-- Finalize sql query (i.e destroy previous query statement.
do
debug ("roc_storage")
print ("> sql_finalize.%N")
end
if attached last_statement as st then
st.cleanup
end
if attached last_sqlite_result_cursor as cur then
if cur.statement /= last_statement then
check should_not_occurs: False end
cur.statement.cleanup
end
last_sqlite_result_cursor := Void
end
last_statement := Void
debug ("roc_storage")
print ("< sql_finalize.%N")
end
end
sql_insert (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
-- <Precursor>
local
st: SQLITE_INSERT_STATEMENT
do
debug ("roc_storage")
print ("> sql_insert (" +a_sql_statement + ").%N")
end
last_sqlite_result_cursor := Void
create st.make (a_sql_statement, sqlite)
last_statement := st
if st.is_compiled then
if a_params /= Void then
check st.has_arguments end
last_sqlite_result_cursor := st.execute_new_with_arguments (sqlite_arguments (a_params))
else
last_sqlite_result_cursor := st.execute_new
end
else
error_handler.add_custom_error (1, "invalid query", "query compilation failed!")
end
debug ("roc_storage")
print ("< sql_insert (" +a_sql_statement + ").%N")
end
end
sql_modify (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
-- <Precursor>
local
st: SQLITE_MODIFY_STATEMENT
do
debug ("roc_storage")
print ("> sql_modify (" +a_sql_statement + ").%N")
end
last_sqlite_result_cursor := Void
create st.make (a_sql_statement, sqlite)
last_statement := st
if st.is_compiled then
if a_params /= Void then
check st.has_arguments end
last_sqlite_result_cursor := st.execute_new_with_arguments (sqlite_arguments (a_params))
else
last_sqlite_result_cursor := st.execute_new
end
else
error_handler.add_custom_error (1, "invalid query", "query compilation failed!")
end
debug ("roc_storage")
print ("< sql_modify (" +a_sql_statement + ").%N")
end
end
sqlite_arguments (a_params: STRING_TABLE [detachable ANY]): ARRAYED_LIST [SQLITE_BIND_ARG [ANY]]
local
k: READABLE_STRING_GENERAL
k8: STRING
utf: UTF_CONVERTER
do
create Result.make (a_params.count)
across
a_params as ic
loop
k := ic.key
if k.is_valid_as_string_8 then
k8 := k.as_string_8
else
k8 := utf.utf_32_string_to_utf_8_string_8 (k)
end
if attached {DATE_TIME} ic.item as dt then
Result.force (new_binding_argument (date_time_to_string (dt), ":" + k8))
elseif attached {READABLE_STRING_32} ic.item as s32 then
Result.force (new_binding_argument (utf.utf_32_string_to_utf_8_string_8 (s32), ":" + k8))
else
Result.force (new_binding_argument (ic.item, ":" + k8))
end
end
end
date_time_to_string (dt: DATE_TIME): STRING
do
create Result.make (16)
Result.append_integer (dt.year)
Result.append_character ('-')
if dt.month <= 9 then
Result.append_character ('0')
end
Result.append_integer (dt.month)
Result.append_character ('-')
if dt.day <= 9 then
Result.append_character ('0')
end
Result.append_integer (dt.day)
Result.append_character (' ')
if dt.hour <= 9 then
Result.append_character ('0')
end
Result.append_integer (dt.hour)
Result.append_character (':')
if dt.minute <= 9 then
Result.append_character ('0')
end
Result.append_integer (dt.minute)
Result.append_character (':')
if dt.second <= 9 then
Result.append_character ('0')
end
Result.append_integer (dt.second)
end
string_to_date_time (a_string: READABLE_STRING_GENERAL): DATE_TIME
local
y,m,d: INTEGER
h,min,sec: INTEGER
s: detachable READABLE_STRING_GENERAL
i,j: INTEGER
do
i := 1
-- YYYY
j := a_string.index_of ('-', i)
s := a_string.substring (i, j - 1)
y := s.to_integer
i := j + 1
-- /MM
j := a_string.index_of ('-', i)
s := a_string.substring (i, j - 1)
m := s.to_integer
i := j + 1
-- /DD
j := a_string.index_of (' ', i)
s := a_string.substring (i, j - 1)
d := s.to_integer
i := j + 1
-- %THour
j := a_string.index_of (':', i)
s := a_string.substring (i, j - 1)
h := s.to_integer
i := j + 1
-- :Min
j := a_string.index_of (':', i)
s := a_string.substring (i, j - 1)
min := s.to_integer
i := j + 1
-- :Sec
j := a_string.count + 1
s := a_string.substring (i, j - 1)
sec := s.to_integer
create Result.make (y,m,d,h,min,sec)
end
feature -- Access
sql_start
-- <Precursor>.
do
-- sqlite cursor `last_sqlite_result_cursor', already at first position if any.
end
sql_after: BOOLEAN
-- <Precursor>.
do
if attached last_sqlite_result_cursor as l_cursor then
Result := l_cursor.after
end
end
sql_forth
-- <Precursor>.
do
if attached last_sqlite_result_cursor as l_cursor then
l_cursor.forth
end
end
sql_valid_item_index (a_index: INTEGER): BOOLEAN
local
l_row: SQLITE_RESULT_ROW
do
if attached last_sqlite_result_cursor as l_cursor then
l_row := l_cursor.item
Result := a_index > 0 and a_index.to_natural_32 <= l_row.count
end
end
sql_item (a_index: INTEGER): detachable ANY
local
l_row: SQLITE_RESULT_ROW
do
if attached last_sqlite_result_cursor as l_cursor then
l_row := l_cursor.item
Result := l_row.value (a_index.to_natural_32)
end
end
sql_read_string_32 (a_index: INTEGER): detachable STRING_32
-- <Precursor>
local
utf: UTF_CONVERTER
do
Result := Precursor (a_index)
if Result = Void then
if attached sql_read_string (a_index) as s8 then
Result := utf.utf_8_string_8_to_string_32 (s8)
end
end
end
sql_read_integer_32 (a_index: INTEGER): INTEGER_32
-- Retrieved value at `a_index' position in `item'.
local
l_item: like sql_item
i64: INTEGER_64
do
l_item := sql_item (a_index)
if attached {INTEGER_32} l_item as i then
Result := i
elseif attached {INTEGER_32_REF} l_item as l_value then
Result := l_value.item
else
if attached {INTEGER_64} l_item as i then
i64 := i
elseif attached {INTEGER_64_REF} l_item as l_value then
i64 := l_value.item
else
check is_integer_32: False end
end
if i64 <= {INTEGER_32}.max_value then
Result := i64.to_integer_32
else
check is_integer_32: False end
end
end
end
sql_read_date_time (a_index: INTEGER): detachable DATE_TIME
-- Retrieved value at `a_index' position in `item'.
local
l_item: like sql_item
do
l_item := sql_item (a_index)
if attached {DATE_TIME} l_item as dt then
Result := dt
elseif attached {READABLE_STRING_GENERAL} l_item as s then
Result := string_to_date_time (s)
else
check is_date_time_nor_null: l_item = Void end
end
end
feature -- Conversion
sql_statement (a_statement: STRING): STRING
-- <Precursor>.
local
i: INTEGER
do
Result := a_statement
from
i := 1
until
i = 0
loop
i := a_statement.substring_index ("AUTO_INCREMENT", i)
if i > 0 then
if Result = a_statement then
create Result.make_from_string (a_statement)
end
Result.remove (i + 4)
i := i + 14
end
end
end
end

View File

@@ -0,0 +1,90 @@
note
description: "[
Objects that ...
]"
author: "$Author: jfiat $"
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
class
CMS_STORAGE_SQLITE3_BUILDER
inherit
CMS_STORAGE_SQL_BUILDER
create
make
feature {NONE} -- Initialization
make
-- Initialize `Current'.
do
end
feature -- Factory
storage (a_setup: CMS_SETUP; a_error_handler: ERROR_HANDLER): detachable CMS_STORAGE_SQLITE3
local
s: detachable READABLE_STRING_32
p: PATH
db: detachable SQLITE_DATABASE
l_source: SQLITE_FILE_SOURCE
i,j: INTEGER
do
if
attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (a_setup.environment.application_config_path) as l_database_config
then
if l_database_config.driver.is_case_insensitive_equal ("sqlite3") then
s := l_database_config.database_string
i := s.substring_index ("Database=", 1)
if i > 0 then
i := s.index_of ('=', i) + 1
j := s.index_of (';', i)
if j = 0 then
j := s.count + 1
end
create p.make_from_string (s.substring (i, j - 1))
else
create p.make_from_string (s)
end
if attached reuseable_connection.item as d then
if p.same_as (d.path) then
db := d.database
end
end
if db = Void or else db.is_closed then
create l_source.make (p.name)
create db.make (l_source)
if l_source.exists then
db.open_read_write
else
db.open_create_read_write
end
end
if not db.is_closed then
db.set_busy_timeout (1_000) -- FIXME
create Result.make (db)
-- set_map_zero_null_value (False) --| This way we map 0 to 0, instead of Null as default.
if Result.is_available then
if not Result.is_initialized then
initialize (a_setup, Result)
end
end
else
a_error_handler.add_custom_error (0, "Could not connect to the ODBC storage", Void)
end
else
-- Wrong mapping between storage name and storage builder!
end
end
end
reuseable_connection: CELL [detachable TUPLE [path: PATH; database: SQLITE_DATABASE]]
once
create Result.put (Void)
end
end

View File

@@ -35,6 +35,7 @@ feature -- Factory
if conn.is_connected then
create Result.make (conn)
set_map_zero_null_value (False) --| This way we map 0 to 0, instead of Null as default.
set_use_extended_types (True) --| Use extended types: STRING_32 etc.
if Result.is_available then
if not Result.is_initialized then
initialize (a_setup, Result)

View File

@@ -48,6 +48,7 @@ feature -- Factory
if conn.is_connected then
create Result.make_with_driver (conn, l_database_config.item ("Driver"))
set_map_zero_null_value (False) --| This way we map 0 to 0, instead of Null as default.
set_use_extended_types (True) --| Use extended types: STRING_32 etc.
if Result.is_available then
if not Result.is_initialized then
initialize (a_setup, Result)

View File

@@ -53,6 +53,8 @@ feature -- Access: router
l_user_handler: CMS_USER_HANDLER
l_role_handler: CMS_ROLE_HANDLER
l_admin_cache_handler: CMS_ADMIN_CACHE_HANDLER
l_uri_mapping: WSF_URI_MAPPING
do
create l_admin_handler.make (a_api)
@@ -67,6 +69,10 @@ feature -- Access: router
create l_uri_mapping.make_trailing_slash_ignored ("/admin/roles", l_roles_handler)
a_router.map (l_uri_mapping, a_router.methods_get_post)
create l_admin_cache_handler.make (a_api)
create l_uri_mapping.make_trailing_slash_ignored ("/admin/cache", l_admin_cache_handler)
a_router.map (l_uri_mapping, a_router.methods_get_post)
create l_user_handler.make (a_api)
a_router.handle ("/admin/add/user", l_user_handler, a_router.methods_get_post)
a_router.handle ("/admin/user/{id}", l_user_handler, a_router.methods_get)
@@ -78,6 +84,8 @@ feature -- Access: router
a_router.handle ("/admin/role/{id}", l_role_handler, a_router.methods_get)
a_router.handle ("/admin/role/{id}/edit", l_role_handler, a_router.methods_get_post)
a_router.handle ("/admin/role/{id}/delete", l_role_handler, a_router.methods_get_post)
end
feature -- Security
@@ -120,6 +128,13 @@ feature -- Hooks
lnk.set_permission_arguments (<<"manage " + {CMS_ADMIN_MODULE}.name>>)
a_menu_system.management_menu.extend (lnk)
end
if
a_response.has_permission ("admin cache") -- Note: admin user has all permissions enabled by default.
then
create lnk.make ("Cache", "admin/cache")
lnk.set_permission_arguments (<<"admin cache">>)
a_menu_system.management_menu.extend (lnk)
end
end
note

View File

@@ -0,0 +1,101 @@
note
description: "[
Administrate cache functionality.
]"
date: "$Date$"
revision: "$Revision$"
class
CMS_ADMIN_CACHE_HANDLER
inherit
CMS_HANDLER
WSF_URI_HANDLER
rename
new_mapping as new_uri_mapping
end
WSF_RESOURCE_HANDLER_HELPER
redefine
do_get,
do_post
end
REFACTORING_HELPER
create
make
feature -- Execution
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
do
execute_methods (req, res)
end
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
local
l_response: CMS_RESPONSE
s: STRING
f: CMS_FORM
do
create {GENERIC_VIEW_CMS_RESPONSE} l_response.make (req, res, api)
if l_response.has_permission ("admin cache") then
f := clear_cache_web_form (l_response)
create s.make_empty
f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s)
l_response.set_main_content (s)
else
create {FORBIDDEN_ERROR_CMS_RESPONSE} l_response.make (req, res, api)
end
l_response.execute
end
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
local
l_response: CMS_RESPONSE
s: STRING
f: CMS_FORM
do
create {GENERIC_VIEW_CMS_RESPONSE} l_response.make (req, res, api)
if l_response.has_permission ("admin cache") then
f := clear_cache_web_form (l_response)
f.process (l_response)
if
attached f.last_data as fd and then
fd.is_valid
then
if attached fd.string_item ("op") as l_op and then l_op.same_string (text_clear_all_caches) then
l_response.hooks.invoke_clear_cache (Void, l_response)
l_response.add_notice_message ("Cache cleared!")
else
fd.report_error ("Invalid form data!")
end
end
create s.make_empty
f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s)
l_response.set_main_content (s)
else
create {FORBIDDEN_ERROR_CMS_RESPONSE} l_response.make (req, res, api)
end
l_response.execute
end
feature -- Widget
clear_cache_web_form (a_response: CMS_RESPONSE): CMS_FORM
local
but: WSF_FORM_SUBMIT_INPUT
do
create Result.make (a_response.url (a_response.location, Void), "form_clear_cache")
create but.make_with_text ("op", text_clear_all_caches)
Result.extend (but)
end
feature -- Interface text.
text_clear_all_caches: STRING_32 = "Clear all caches"
end

View File

@@ -93,7 +93,7 @@ feature -- HTTP Methods
s.append ("<a href=%"")
s.append (req.absolute_script_url ("/admin/role/" + u.id.out))
s.append ("%">")
s.append (u.name)
s.append (html_encoded (u.name))
s.append ("</a>")
s.append ("</li>%N")
end

View File

@@ -106,7 +106,7 @@ feature -- HTTP Methods
s.append ("<a href=%"")
s.append (req.absolute_script_url ("/admin/user/"+u.id.out))
s.append ("%">")
s.append (u.name)
s.append (html_encoded (u.name))
s.append ("</a>")
s.append ("</li>%N")
end

View File

@@ -521,26 +521,26 @@ feature {NONE} -- Helpers
feature {NONE} -- Block views
get_block_view_login (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
local
-- vals: CMS_VALUE_TABLE
do
if attached template_block (a_block_id, a_response) as l_tpl_block then
-- create vals.make (1)
-- -- add the variable to the block
-- value_table_alter (vals, a_response)
-- across
-- vals as ic
-- loop
-- l_tpl_block.set_value (ic.item, ic.key)
-- get_block_view_login (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
-- local
---- vals: CMS_VALUE_TABLE
-- do
-- if attached template_block (a_block_id, a_response) as l_tpl_block then
---- create vals.make (1)
---- -- add the variable to the block
---- value_table_alter (vals, a_response)
---- across
---- vals as ic
---- loop
---- l_tpl_block.set_value (ic.item, ic.key)
---- end
-- a_response.put_required_block (l_tpl_block, "content")
-- else
-- debug ("cms")
-- a_response.add_warning_message ("Error with block [" + a_block_id + "]")
-- end
a_response.add_block (l_tpl_block, "content")
else
debug ("cms")
a_response.add_warning_message ("Error with block [" + a_block_id + "]")
end
end
end
-- end
-- end
get_block_view_register (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
do
@@ -579,7 +579,6 @@ feature {NONE} -- Block views
end
end
get_block_view_reactivate (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
do
if a_response.request.is_get_request_method then

View File

@@ -50,10 +50,10 @@ feature -- Access
feature -- Access: node
summary: detachable READABLE_STRING_8
summary: detachable READABLE_STRING_32
-- A short summary of the node.
content: detachable READABLE_STRING_8
content: detachable READABLE_STRING_32
-- Content of the node.
format: detachable READABLE_STRING_8

View File

@@ -83,17 +83,18 @@ feature -- Persistence
if l_update then
if l_has_modif then
sql_change (sql_update_node_data, l_parameters)
sql_modify (sql_update_node_data, l_parameters)
end
else
if l_has_modif then
sql_change (sql_insert_node_data, l_parameters)
sql_insert (sql_insert_node_data, l_parameters)
else
-- no page data, means everything is empty.
-- FOR NOW: always record row
-- sql_change (sql_insert_node_data, l_parameters)
end
end
sql_finalize
end
end
@@ -108,6 +109,19 @@ feature -- Persistence
end
end
delete_node (a_node: CMS_BLOG)
-- <Precursor>
local
l_parameters: STRING_TABLE [ANY]
do
if a_node.has_id then
create l_parameters.make (1)
l_parameters.put (a_node.id, "nid")
sql_modify (sql_delete_node_data, l_parameters)
sql_finalize
end
end
feature {NONE} -- Implementation
node_data (a_node: CMS_NODE): detachable TUPLE [revision: INTEGER_64; tags: READABLE_STRING_32]
@@ -124,18 +138,21 @@ feature {NONE} -- Implementation
l_parameters.put (a_node.revision, "revision")
sql_query (sql_select_node_data, l_parameters)
if not has_error then
n := sql_rows_count
if n = 1 then
if not sql_after then
-- nid, revision, tags
l_rev := sql_read_integer_64 (2)
l_tags := sql_read_string_32 (3)
if l_tags /= Void then
Result := [l_rev, l_tags]
end
else
check unique_data: n = 0 end
sql_forth
if not sql_after then
check unique_data: n = 0 end
Result := Void
end
end
end
sql_finalize
ensure
accepted_revision: Result /= Void implies Result.revision <= a_node.revision
end
@@ -145,5 +162,6 @@ feature -- SQL
sql_select_node_data: STRING = "SELECT nid, revision, tags FROM blog_post_nodes WHERE nid=:nid AND revision<=:revision ORDER BY revision DESC LIMIT 1;"
sql_insert_node_data: STRING = "INSERT INTO blog_post_nodes (nid, revision, tags) VALUES (:nid, :revision, :tags);"
sql_update_node_data: STRING = "UPDATE blog_post_nodes SET nid=:nid, revision=:revision, tags=:tags WHERE nid=:nid AND revision=:revision;"
sql_delete_node_data: STRING = "DELETE FROM blog_post_nodes WHERE nid=:nid;"
end

View File

@@ -230,9 +230,9 @@ feature -- HTML Output
lnk := blog_api.node_api.node_link (n)
a_output.append ("<p class=%"blog_list_summary%">")
if attached api.format (n.format) as f then
a_output.append (f.formatted_output (l_summary))
f.append_formatted_to (l_summary, a_output)
else
a_output.append (page.formats.default_format.formatted_output (l_summary))
page.formats.default_format.append_formatted_to (l_summary, a_output)
end
a_output.append ("<br />")
a_output.append (page.link ("See more...", lnk.location, Void))

View File

@@ -123,7 +123,7 @@ feature -- HTML Output
do
a_output.append ("<h2>Posts from ")
if attached user as l_user then
a_output.append (l_user.name)
a_output.append (html_encoded (l_user.name))
else
a_output.append ("unknown user")
end

View File

@@ -23,9 +23,10 @@ feature -- Access
error_handler.reset
write_information_log (generator + ".blogs_count")
sql_query (sql_select_blog_count, Void)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := sql_read_integer_64 (1)
end
sql_finalize
end
blogs_count_from_user (a_user: CMS_USER) : INTEGER_64
@@ -38,9 +39,10 @@ feature -- Access
create l_parameters.make (2)
l_parameters.put (a_user.id, "user")
sql_query (sql_select_blog_count_from_user, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := sql_read_integer_64 (1)
end
sql_finalize
end
blogs: LIST [CMS_NODE]
@@ -62,6 +64,7 @@ feature -- Access
end
sql_forth
end
sql_finalize
end
blogs_limited (a_limit: NATURAL_32; a_offset: NATURAL_32): LIST [CMS_NODE]
@@ -88,6 +91,7 @@ feature -- Access
end
sql_forth
end
sql_finalize
end
blogs_from_user_limited (a_user: CMS_USER; a_limit: NATURAL_32; a_offset: NATURAL_32): LIST [CMS_NODE]
@@ -115,6 +119,7 @@ feature -- Access
end
sql_forth
end
sql_finalize
end
feature {NONE} -- Queries

View File

@@ -0,0 +1,128 @@
note
description: "Feed aggregation parameters."
date: "$Date$"
revision: "$Revision$"
class
FEED_AGGREGATION
create
make
feature {NONE} -- Initialization
make (a_name: READABLE_STRING_GENERAL)
do
create name.make_from_string_general (a_name)
create {ARRAYED_LIST [READABLE_STRING_8]} locations.make (0)
expiration := 60*60
description_enabled := True
size := 10
end
feature -- Access
name: IMMUTABLE_STRING_32
-- Associated name.
expiration: INTEGER
-- Suggested expiration time in seconds (default: 1 hour).
-- If negative then never expires.
size: INTEGER
-- Number of entries to display per page.
description: detachable IMMUTABLE_STRING_32
-- Optional description.
locations: LIST [READABLE_STRING_8]
-- List of feed location aggregated into current.
included_categories: detachable LIST [READABLE_STRING_32]
-- Optional categories to filter.
-- If Void, include any.
description_enabled: BOOLEAN
-- Display description?
feature -- Status report
has_category_filter: BOOLEAN
-- Is there any category filtering?
-- i.e via `included_categories'
do
Result := attached included_categories as cats and then not cats.is_empty
end
feature -- Element change
set_description (a_desc: detachable READABLE_STRING_GENERAL)
do
if a_desc = Void then
description := Void
else
create description.make_from_string_general (a_desc)
end
end
set_expiration (nb_seconds: INTEGER)
-- Set `expiration' to `nb_seconds'.
do
expiration := nb_seconds
end
set_size (nb: INTEGER)
-- Set `size' to `nb'.
do
size := nb
end
set_description_enabled (b: BOOLEAN)
-- Set `description_enabled' to `b'.
do
description_enabled := b
end
reset_categories
do
included_categories := Void
end
include_category (a_cat: READABLE_STRING_GENERAL)
local
lst: like included_categories
s32: STRING_32
do
lst := included_categories
if lst = Void then
create {ARRAYED_LIST [READABLE_STRING_32]} lst.make (1)
included_categories := lst
lst.compare_objects
end
s32 := a_cat.to_string_32
if not lst.has (s32) then
lst.force (s32)
end
end
feature -- Status report
is_included (e: FEED_ITEM): BOOLEAN
-- Is `e' included in final aggregation?
-- i.e: related to `included_categories'
-- note that if `e' has no category, it is included by default,
-- even if `included_categories' is defined.
do
Result := True
if attached e.categories as e_cats then
if attached included_categories as lst then
Result := across lst as ic some
across e_cats as e_ic some
e_ic.item.same_string (ic.item)
end
end
end
end
end
end

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-0.xsd" name="feed_aggregator" uuid="6A78AB37-9B07-4C42-9E24-0CA7D3C61E12" library_target="feed_aggregator">
<target name="feed_aggregator">
<root all_classes="true"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension-safe.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<library name="cms" location="..\..\cms-safe.ecf"/>
<library name="cms_model" location="..\..\library\model\cms_model-safe.ecf" readonly="false"/>
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
<library name="feed" location="$ISE_LIBRARY\contrib\library\text\parser\feed\feed-safe.ecf"/>
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
<library name="http_client" location="$ISE_LIBRARY\contrib\library\network\http_client\http_client-safe.ecf"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html-safe.ecf" readonly="false"/>
<cluster name="src" location="." recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,153 @@
note
description: "API for Feed aggregator module."
date: "$Date$"
revision: "$Revision$"
class
FEED_AGGREGATOR_API
inherit
CMS_MODULE_API
create
make
feature -- Access
aggregations: HASH_TABLE [FEED_AGGREGATION, STRING]
-- List of feed aggregations.
local
agg: FEED_AGGREGATION
l_feed_id: READABLE_STRING_32
l_title: detachable READABLE_STRING_GENERAL
l_locations: detachable STRING_TABLE [READABLE_STRING_8]
utf: UTF_CONVERTER
l_table: like internal_aggregations
do
l_table := internal_aggregations
if l_table /= Void then
Result := l_table
else
create Result.make (0)
internal_aggregations := Result
if attached cms_api.module_configuration_by_name ({FEED_AGGREGATOR_MODULE}.name, "feeds") as cfg then
if attached cfg.text_list_item ("ids") as l_ids then
across
l_ids as ic
loop
l_feed_id := ic.item
create l_locations.make (1)
if attached cfg.text_list_item ({STRING_32} "feeds." + l_feed_id + ".locations") as l_location_list then
across
l_location_list as loc_ic
loop
l_locations.force (utf.utf_32_string_to_utf_8_string_8 (loc_ic.item), loc_ic.item)
end
end
if attached cfg.text_table_item ({STRING_32} "feeds." + l_feed_id + ".locations") as l_location_table then
across
l_location_table as loc_tb_ic
loop
l_locations.force (utf.utf_32_string_to_utf_8_string_8 (loc_tb_ic.item), loc_tb_ic.key)
end
end
if
attached cfg.text_item ({STRING_32} "feeds." + l_feed_id + ".location") as l_location
then
l_locations.force (utf.utf_32_string_to_utf_8_string_8 (l_location), l_location)
end
if l_locations /= Void and then not l_locations.is_empty then
l_title := cfg.text_item ({STRING_32} "feeds." + l_feed_id + ".title")
if l_title = Void then
l_title := l_feed_id
end
create agg.make (l_title)
if attached cfg.text_item ({STRING_32} "feeds." + l_feed_id + ".expiration") as l_expiration then
if l_expiration.is_integer then
agg.set_expiration (l_expiration.to_integer)
end
end
if attached cfg.text_item ({STRING_32} "feeds." + l_feed_id + ".size") as l_size then
if l_size.is_integer then
agg.set_size (l_size.to_integer)
end
end
if attached cfg.text_item ({STRING_32} "feeds." + l_feed_id + ".option_description") as l_description_opt then
agg.set_description_enabled (not l_description_opt.is_case_insensitive_equal_general ("disabled"))
end
across
l_locations as loc_ic
loop
agg.locations.force (utf.utf_32_string_to_utf_8_string_8 (loc_ic.item))
end
Result.force (agg, l_feed_id)
if attached cfg.text_list_item ({STRING_32} "feeds." + l_feed_id + ".categories") as l_cats then
across
l_cats as cats_ic
loop
agg.include_category (cats_ic.item)
end
end
end
end
end
end
end
end
aggregation (a_name: READABLE_STRING_GENERAL): detachable FEED_AGGREGATION
do
if attached a_name.is_valid_as_string_8 then
Result := aggregations.item (a_name.as_string_8)
end
end
feature {NONE} -- Access: implementation
internal_aggregations: detachable like aggregations
-- Cache value for `aggregations'.
feature -- Operation
feed (a_location: READABLE_STRING_8): detachable FEED
local
fac: FEED_DEFAULT_PARSERS
ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT
do
create fac
if attached new_http_client_session (a_location).get ("", ctx) as res then
if attached res.body as l_content then
Result := fac.feed_from_string (l_content)
end
end
end
aggregation_feed (agg: FEED_AGGREGATION): detachable FEED
-- Feed from aggregation `agg'.
do
across
agg.locations as ic
loop
if attached feed (ic.item) as f then
if Result /= Void then
if f /= Void then
Result := Result + f
end
else
Result := f
end
end
end
end
new_http_client_session (a_url: READABLE_STRING_8): HTTP_CLIENT_SESSION
local
cl: LIBCURL_HTTP_CLIENT
do
create cl.make
Result := cl.new_session (a_url)
Result.set_is_insecure (True)
end
end

View File

@@ -0,0 +1,349 @@
note
description: "CMS module bringing support for feed aggregation."
date: "$Date$"
revision: "$Revision$"
class
FEED_AGGREGATOR_MODULE
inherit
CMS_MODULE
rename
module_api as feed_aggregator_api
redefine
initialize,
register_hooks,
permissions,
feed_aggregator_api
end
CMS_HOOK_BLOCK
CMS_HOOK_RESPONSE_ALTER
CMS_HOOK_MENU_SYSTEM_ALTER
CMS_HOOK_CACHE
create
make
feature {NONE} -- Initialization
make
-- Create Current module, disabled by default.
do
version := "1.0"
description := "Feed aggregation"
package := "feed"
end
feature -- Access
name: STRING = "feed_aggregator"
permissions: LIST [READABLE_STRING_8]
-- List of permission ids, used by this module, and declared.
do
Result := Precursor
Result.force ("manage feed aggregator")
end
feature {CMS_API} -- Module Initialization
initialize (api: CMS_API)
-- <Precursor>
do
Precursor (api)
create feed_aggregator_api.make (api)
end
feature {CMS_API} -- Access: API
feed_aggregator_api: detachable FEED_AGGREGATOR_API
-- Eventual module api.
feature -- Access: router
setup_router (a_router: WSF_ROUTER; a_api: CMS_API)
-- <Precursor>
local
h: WSF_URI_TEMPLATE_HANDLER
do
a_router.handle ("/admin/feed_aggregator/", create {WSF_URI_AGENT_HANDLER}.make (agent handle_feed_aggregator_admin (a_api, ?, ?)), a_router.methods_head_get_post)
create {WSF_URI_TEMPLATE_AGENT_HANDLER} h.make (agent handle_feed_aggregation (a_api, ?, ?))
a_router.handle ("/feed_aggregation/", h, a_router.methods_head_get)
a_router.handle ("/feed_aggregation/{feed_id}", h, a_router.methods_head_get)
end
feature -- Handle
handle_feed_aggregator_admin (a_api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE)
local
nyi: NOT_IMPLEMENTED_ERROR_CMS_RESPONSE
do
create nyi.make (req, res, a_api)
nyi.execute
end
handle_feed_aggregation (a_api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE)
local
r: CMS_RESPONSE
s: STRING
nb: INTEGER
do
if attached {WSF_STRING} req.query_parameter ("size") as p_size and then p_size.is_integer then
nb := p_size.integer_value
else
nb := -1
end
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, a_api)
if attached {WSF_STRING} req.path_parameter ("feed_id") as p_feed_id then
if attached feed_aggregation (p_feed_id.value) as l_agg then
create s.make_empty
s.append ("<h1>")
s.append (r.html_encoded (l_agg.name))
s.append ("</h1>")
if attached l_agg.included_categories as l_categories then
s.append ("<span class=%"category%">")
across
l_categories as cats_ic
loop
s.append (" [")
s.append (r.html_encoded (cats_ic.item))
s.append ("]")
end
s.append ("</span>")
end
if attached l_agg.description as l_desc and then l_desc.is_valid_as_string_8 then
s.append ("<div class=%"description%">")
s.append (l_desc.as_string_8)
s.append ("</div>")
end
s.append ("<ul>")
across
l_agg.locations as ic
loop
s.append ("<li><a href=%"")
s.append (ic.item)
s.append ("%">")
s.append (ic.item)
s.append ("</a></li>")
end
s.append ("</ul>")
if attached feed_to_html (p_feed_id.value, nb, True, r) as l_html then
s.append (l_html)
end
r.set_main_content (s)
else
create {NOT_FOUND_ERROR_CMS_RESPONSE} r.make (req, res, a_api)
end
else
if attached feed_aggregator_api as l_feed_agg_api then
create s.make_empty
across
l_feed_agg_api.aggregations as ic
loop
s.append ("<li>")
s.append (r.link (ic.key, "feed_aggregation/" + r.url_encoded (ic.key), Void))
if attached ic.item.included_categories as l_categories then
s.append ("<span class=%"category%">")
across
l_categories as cats_ic
loop
s.append (" [")
s.append (r.html_encoded (cats_ic.item))
s.append ("]")
end
s.append ("</span>")
end
if attached ic.item.description as l_desc then
if l_desc.is_valid_as_string_8 then
s.append ("<div class=%"description%">")
s.append (l_desc.as_string_8)
s.append ("</div>")
end
end
s.append ("</li>")
end
r.set_main_content (s)
else
create {BAD_REQUEST_ERROR_CMS_RESPONSE} r.make (req, res, a_api)
end
end
r.execute
end
feature -- Hooks configuration
register_hooks (a_response: CMS_RESPONSE)
-- Module hooks configuration.
do
a_response.hooks.subscribe_to_block_hook (Current)
a_response.hooks.subscribe_to_response_alter_hook (Current)
a_response.hooks.subscribe_to_menu_system_alter_hook (Current)
a_response.hooks.subscribe_to_cache_hook (Current)
end
feature -- Hook
clear_cache (a_cache_id_list: detachable ITERABLE [READABLE_STRING_GENERAL]; a_response: CMS_RESPONSE)
-- <Precursor>.
local
p: PATH
dir: DIRECTORY
do
if a_cache_id_list = Void then
-- Clear all cache.
p := a_response.api.files_location.extended (".cache").extended (name)
create dir.make_with_path (p)
if dir.exists then
dir.recursive_delete
end
end
end
block_list: ITERABLE [like {CMS_BLOCK}.name]
-- List of block names, managed by current object.
local
res: ARRAYED_LIST [like {CMS_BLOCK}.name]
l_aggs: HASH_TABLE [FEED_AGGREGATION, STRING_8]
do
if attached feed_aggregator_api as l_feed_api then
l_aggs := l_feed_api.aggregations
create res.make (l_aggs.count)
across
l_aggs as ic
loop
res.force ("?feed." + ic.key)
end
else
create res.make (0)
end
Result := res
end
get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
-- Get block object identified by `a_block_id' and associate with `a_response'.
local
s: READABLE_STRING_8
b: CMS_CONTENT_BLOCK
pref: STRING
nb: INTEGER
do
if attached feed_aggregator_api as l_feed_api then
pref := "feed."
if a_block_id.starts_with (pref) then
s := a_block_id.substring (pref.count + 1, a_block_id.count)
else
s := a_block_id
end
nb := 0
if
attached a_response.block_options (a_block_id) as l_options and then
attached {READABLE_STRING_GENERAL} l_options.item ("size") as l_size and then
l_size.is_integer
then
nb := l_size.to_integer
end
if attached feed_to_html (s, nb, True, a_response) as l_content then
create b.make (a_block_id, Void, l_content, Void)
b.set_is_raw (True)
a_response.add_block (b, "feed_" + s)
end
end
end
feed_aggregation (a_feed_id: READABLE_STRING_GENERAL): detachable FEED_AGGREGATION
do
if attached feed_aggregator_api as l_feed_api then
Result := l_feed_api.aggregation (a_feed_id)
end
end
feed_to_html (a_feed_id: READABLE_STRING_GENERAL; a_count: INTEGER; with_feed_info: BOOLEAN; a_response: CMS_RESPONSE): detachable STRING
local
nb: INTEGER
i: INTEGER
e: FEED_ITEM
l_cache: CMS_FILE_STRING_8_CACHE
lnk: detachable FEED_LINK
vis: FEED_TO_XHTML_VISITOR
s: STRING
do
if attached feed_aggregator_api as l_feed_api then
if attached l_feed_api.aggregation (a_feed_id) as l_agg then
create l_cache.make (a_response.api.files_location.extended (".cache").extended (name).extended ("feed__" + a_feed_id + "__" + a_count.out + "_" + with_feed_info.out))
Result := l_cache.item
if Result = Void or l_cache.expired (Void, l_agg.expiration) then
create Result.make (1024)
Result.append ("<!-- ")
Result.append ("Updated: " + l_cache.cache_date_time.out)
Result.append (" -->")
create vis.make (Result)
if a_count = 0 then
nb := l_agg.size
else
nb := a_count
end
vis.set_limit (nb)
vis.set_description_enabled (l_agg.description_enabled)
if with_feed_info then
create s.make_empty
if attached l_agg.description as l_desc then
s.append ("<div class=%"description%">")
s.append_string_general (l_desc)
s.append ("</div>")
end
vis.set_header (s)
end
create s.make_empty
s.append_string ("<liv class=%"nav%">")
s.append_string (a_response.link ("See more ...", "feed_aggregation/" + a_response.url_encoded (a_feed_id), Void))
s.append_string ("</li>")
vis.set_footer (s)
if attached l_feed_api.aggregation_feed (l_agg) as l_feed then
if l_agg.has_category_filter and attached l_feed.items as lst then
from
lst.start
until
lst.after
loop
if not l_agg.is_included (lst.item_for_iteration) then
lst.remove
else
lst.forth
end
end
end
l_feed.accept (vis)
end
l_cache.put (Result)
end
end
end
end
feature -- Hook
response_alter (a_response: CMS_RESPONSE)
do
a_response.add_style (a_response.url ("/module/" + name + "/files/css/feed_aggregator.css", Void), Void)
end
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
-- Hook execution on collection of menu contained by `a_menu_system'
-- for related response `a_response'.
do
a_menu_system.navigation_menu.extend (create {CMS_LOCAL_LINK}.make ("Feeds", "feed_aggregation/"))
if a_response.has_permission ("manage feed aggregator") then
a_menu_system.management_menu.extend (create {CMS_LOCAL_LINK}.make ("Feeds (admin)", "admin/feed_aggregator/"))
end
end
end

View File

@@ -0,0 +1,28 @@
{
"ids": ["news", "forum"],
"feeds": {
"news": {
"title": "Eiffel related posts",
"expiration": "21600",
"size": 5,
"locations": [
"https://bertrandmeyer.com/feed/",
"https://room.eiffel.com/blog/feed",
"https://room.eiffel.com/article/feed",
"https://room.eiffel.com/library/feed"
]
, "categories": ["Eiffel"]
,"option_description": "enabled"
},
"forum": {
"title": "Eiffel Forum",
"expiration": "21600",
"size": 5,
"locations": [
"https://groups.google.com/forum/feed/eiffel-users/msgs/atom.xml?num=15",
"http://stackoverflow.com/feeds/tag?tagnames=eiffel&sort=newest"
]
,"option_description": "enabled"
}
}
}

View File

@@ -0,0 +1,53 @@
div.feed ul {
list-style: none;
position: relative;
padding: 0;
margin: 0;
width: 99%;
}
div.feed li {
/* border-top: solid 1px #ddd; */
padding: 0;
margin: 0 0 5px 0;
}
div.feed li a {
font-weight: bold;
}
div.feed li .date {
font-weight: bold;
font-size: small;
}
div.feed li .category {
margin-left: 20px;
font-size: 8px;
height: 9px;
overflow: hidden;
color: #999;
}
div.feed li .description {
margin-left: 20px;
font-size: small;
height: 18px;
overflow: hidden;
color: #999;
}
div.feed li:hover {
margin-bottom: 23px;
}
div.feed li:hover .description {
padding: 5px;
position: absolute;
height: auto;
overflow-y: scroll;
overflow-x: scroll;
color: #000;
background-color: #fff;
border: solid 1px #000;
z-index: 10;
}
div.feed li:hover:last-child {
margin-bottom: 28px;
}
div.feed li .description::after {
content: "...";
}

View File

@@ -0,0 +1,54 @@
div.feed {
ul {
list-style: none;
position: relative;
padding: 0;
margin: 0;
width: 99%;
}
li {
/* border-top: solid 1px #ddd; */
padding: 0;
margin: 0 0 5px 0;
a {
font-weight: bold;
}
.date {
font-weight: bold;
font-size: small;
}
.category {
margin-left: 20px;
font-size: 8px;
height: 9px;
overflow: hidden;
color: #999;
}
.description {
margin-left: 20px;
font-size: small;
height: 18px;
overflow: hidden;
color: #999;
}
&:hover {
margin-bottom: 23px;
.description {
padding: 5px;
position: absolute;
height: auto;
overflow-y: scroll;
overflow-x: scroll;
color: #000;
background-color: #fff;
border: solid 1px #000;
z-index: 10;
}
&:last-child {
margin-bottom: 28px;
}
}
.description::after { content: "..."; }
}
}

View File

@@ -244,7 +244,7 @@ feature -- Hooks
block_list: ITERABLE [like {CMS_BLOCK}.name]
-- <Precursor>
do
Result := <<"node-info">>
Result := <<"?node-info">>
end
get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)

View File

@@ -103,12 +103,12 @@ feature -- Access
-- Full title of the node.
-- Required!
summary: detachable READABLE_STRING_8
summary: detachable READABLE_STRING_32
-- A short summary of the node.
deferred
end
content: detachable READABLE_STRING_8
content: detachable READABLE_STRING_32
-- Content of the node.
deferred
end

View File

@@ -33,10 +33,10 @@ feature -- Access: code
feature -- Access: content
summary: detachable READABLE_STRING_8
summary: detachable READABLE_STRING_32
-- A short summary of the node.
content: detachable READABLE_STRING_8
content: detachable READABLE_STRING_32
-- Content of the node.
format: detachable READABLE_STRING_8

View File

@@ -44,10 +44,10 @@ feature -- Access
feature -- Access: content
summary: detachable READABLE_STRING_8
summary: detachable READABLE_STRING_32
-- A short summary of the node.
content: detachable READABLE_STRING_8
content: detachable READABLE_STRING_32
-- Content of the node.
format: detachable READABLE_STRING_8

View File

@@ -100,6 +100,7 @@ feature -- Forms ...
local
ti: WSF_FORM_TEXT_INPUT
l_uri: detachable READABLE_STRING_8
l_iri: detachable READABLE_STRING_32
do
-- Path alias
create ti.make ("path_alias")
@@ -111,7 +112,8 @@ feature -- Forms ...
if attached a_node.link as lnk then
l_uri := lnk.location
else
l_uri := percent_encoder.percent_decoded_string (response.api.location_alias (response.node_api.node_path (a_node)))
l_iri := percent_encoder.percent_decoded_string (response.api.location_alias (response.node_api.node_path (a_node)))
l_uri := l_iri.to_string_8
end
ti.set_text_value (l_uri)
ti.set_description ("Optionally specify an alternative URL path by which this content can be accessed. For example, type 'about' when writing an about page. Use a relative path or the URL alias won't work.")
@@ -151,10 +153,9 @@ feature -- Forms ...
end
end
update_node (response: NODE_RESPONSE; fd: WSF_FORM_DATA; a_node: CMS_NODE)
local
b,s: detachable READABLE_STRING_8
b,s: detachable READABLE_STRING_32
f: detachable CONTENT_FORMAT
do
if attached fd.integer_item ("id") as l_id and then l_id > 0 then
@@ -193,7 +194,7 @@ feature -- Forms ...
new_node (response: NODE_RESPONSE; fd: WSF_FORM_DATA; a_node: detachable CMS_NODE): G
-- <Precursor>
local
b,s: detachable READABLE_STRING_8
b,s: detachable READABLE_STRING_32
f: detachable CONTENT_FORMAT
l_node: detachable like new_node
do
@@ -304,7 +305,7 @@ feature -- Output
s.append ("<div class=%"info%"> ")
if attached a_node.author as l_author then
s.append (" by ")
s.append (l_author.name)
s.append (a_response.html_encoded (l_author.name))
end
if attached a_node.modification_date as l_modified then
s.append (" (modified: ")
@@ -321,9 +322,9 @@ feature -- Output
-- if attached a_node.summary as l_summary then
-- s.append ("<p class=%"summary%">")
-- if attached node_api.cms_api.format (a_node.format) as f then
-- s.append (f.formatted_output (l_summary))
-- append_formatted_output (l_content, f, s)
-- else
-- s.append (a_response.formats.default_format.formatted_output (l_summary))
-- append_formatted_output (l_content, a_response.formats.default_format, s)
-- end
-- s.append ("</p>")
@@ -333,9 +334,9 @@ feature -- Output
if attached a_node.content as l_content then
s.append ("<p class=%"content%">")
if attached node_api.cms_api.format (a_node.format) as f then
s.append (f.formatted_output (l_content))
append_formatted_output (l_content, f, s)
else
s.append (a_response.formats.default_format.formatted_output (l_content))
append_formatted_output (l_content, a_response.formats.default_format, s)
end
s.append ("</p>")
@@ -346,5 +347,15 @@ feature -- Output
a_response.set_main_content (s)
end
append_formatted_output (a_content: READABLE_STRING_GENERAL; a_format: CONTENT_FORMAT; a_output: STRING_8)
-- Format `a_content' with format `a_format'.
do
if a_content.is_valid_as_string_8 then
a_output.append (a_format.formatted_output (a_content.to_string_8))
else
a_format.append_formatted_to (a_content, a_output)
end
end
end

View File

@@ -30,7 +30,7 @@ feature -- Forms ...
local
ti: WSF_FORM_NUMBER_INPUT
fs: WSF_FORM_FIELD_SET
l_parent_id, nid: INTEGER_64
l_parent_id: INTEGER_64
do
Precursor (response, f, a_node)
@@ -102,7 +102,6 @@ feature -- Forms ...
parent_validation (a_response: NODE_RESPONSE; fd: WSF_FORM_DATA)
local
l_selected: BOOLEAN
node_api: CMS_NODE_API
l_parent_id: INTEGER_64
nid: INTEGER_64

View File

@@ -49,6 +49,13 @@ feature -- Persistence
end
end
delete_node (a_node: CMS_NODE)
-- remove node extensions.
require
a_node_accepted: is_accepted (a_node)
deferred
end
feature {NONE} -- Persistence implementation
store (a_node: G)

View File

@@ -44,7 +44,7 @@ feature {NONE} -- Implementation
extended_store (a_node: CMS_NODE)
-- Store extended data from `a_node'.
require
not error_handler.has_error
not_has_error: not error_handler.has_error
do
if attached node_storage_extension (a_node) as ext then
ext.store_node (a_node)
@@ -54,13 +54,23 @@ feature {NONE} -- Implementation
extended_load (a_node: CMS_NODE)
-- Load extended data into `a_node'.
require
not error_handler.has_error
not_has_error: not error_handler.has_error
do
if attached node_storage_extension (a_node) as ext then
ext.load_node (a_node)
end
end
extended_delete (a_node: CMS_NODE)
-- Delete extended data related to node `a_node'.
require
not_has_error: not error_handler.has_error
do
if attached node_storage_extension (a_node) as ext then
ext.delete_node (a_node)
end
end
feature -- Access
nodes_count: NATURAL_64
@@ -165,16 +175,19 @@ feature -- Change: Node
delete_node (a_node: CMS_NODE)
-- Delete `a_node'.
require
valid_node_id: a_node.has_id
do
if a_node.has_id then
delete_node_by_id (a_node.id)
end
-- TODO
-- Check if we need to use a transaction
-- we delete a node
-- node_revisions
-- and extensions (PAGE, BLOG, etc).
delete_node_base (a_node)
end
delete_node_by_id (a_id: INTEGER_64)
-- Remove node by id `a_id'.
require
valid_node_id: a_id > 0
delete_node_base (a_node: CMS_NODE)
-- Remove node `a_node'.
deferred
end

View File

@@ -106,7 +106,7 @@ feature -- Node
do
end
delete_node_by_id (a_id: INTEGER_64)
delete_node_base (a_node: CMS_NODE)
-- <Precursor>
do
end

View File

@@ -28,12 +28,12 @@ feature -- Access
error_handler.reset
write_information_log (generator + ".nodes_count")
sql_query (sql_select_nodes_count, Void)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := sql_read_natural_64 (1)
end
sql_finalize
end
nodes: LIST [CMS_NODE]
-- List of nodes.
do
@@ -53,11 +53,7 @@ feature -- Access
end
sql_forth
end
-- across
-- Result as ic
-- loop
-- fill_node (ic.item)
-- end
sql_finalize
end
node_revisions (a_node: CMS_NODE): LIST [CMS_NODE]
@@ -85,6 +81,7 @@ feature -- Access
end
sql_forth
end
sql_finalize
end
trashed_nodes (a_user: detachable CMS_USER): LIST [CMS_NODE]
@@ -95,7 +92,7 @@ feature -- Access
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
error_handler.reset
write_information_log (generator + ".trash_nodes")
write_information_log (generator + ".trashed_nodes")
from
create l_parameters.make (1)
@@ -114,6 +111,7 @@ feature -- Access
end
sql_forth
end
sql_finalize
end
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
@@ -124,7 +122,7 @@ feature -- Access
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
error_handler.reset
write_information_log (generator + ".nodes")
write_information_log (generator + ".recent_nodes")
from
create l_parameters.make (2)
@@ -140,6 +138,7 @@ feature -- Access
end
sql_forth
end
sql_finalize
end
recent_node_changes_before (a_lower: INTEGER; a_count: INTEGER; a_date: DATE_TIME): LIST [CMS_NODE]
@@ -150,7 +149,7 @@ feature -- Access
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
error_handler.reset
write_information_log (generator + ".nodes")
write_information_log (generator + ".recent_node_changes_before")
from
create l_parameters.make (3)
@@ -168,6 +167,7 @@ feature -- Access
end
sql_forth
end
sql_finalize
end
node_by_id (a_id: INTEGER_64): detachable CMS_NODE
@@ -176,13 +176,14 @@ feature -- Access
l_parameters: STRING_TABLE [ANY]
do
error_handler.reset
write_information_log (generator + ".node")
write_information_log (generator + ".node_by_id")
create l_parameters.make (1)
l_parameters.put (a_id, "nid")
sql_query (sql_select_node_by_id, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := fetch_node
end
sql_finalize
end
node_by_id_and_revision (a_node_id, a_revision: INTEGER_64): detachable CMS_NODE
@@ -191,14 +192,15 @@ feature -- Access
l_parameters: STRING_TABLE [ANY]
do
error_handler.reset
write_information_log (generator + ".node")
write_information_log (generator + ".node_by_id_and_revision")
create l_parameters.make (1)
l_parameters.put (a_node_id, "nid")
l_parameters.put (a_revision, "revision")
sql_query (sql_select_node_by_id_and_revision, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := fetch_node
end
sql_finalize
end
node_author (a_node: CMS_NODE): detachable CMS_USER
@@ -212,9 +214,10 @@ feature -- Access
l_parameters.put (a_node.id, "nid")
l_parameters.put (a_node.revision, "revision")
sql_query (Select_user_author, l_parameters)
if sql_rows_count >= 1 then
if not has_error and not sql_after then
Result := fetch_author
end
sql_finalize
end
last_inserted_node_id: INTEGER_64
@@ -223,9 +226,10 @@ feature -- Access
error_handler.reset
write_information_log (generator + ".last_inserted_node_id")
sql_query (Sql_last_insert_node_id, Void)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := sql_read_integer_64 (1)
end
sql_finalize
end
last_inserted_node_revision (a_node: detachable CMS_NODE): INTEGER_64
@@ -239,15 +243,20 @@ feature -- Access
create l_parameters.make (1)
l_parameters.force (a_node.id, "nid")
sql_query (Sql_last_insert_node_revision_for_nid, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
if sql_item (1) /= Void then
Result := sql_read_integer_64 (1)
end
sql_forth
if not sql_after then
check no_more_than_one: False end
end
end
sql_finalize
end
-- if Result = 0 and not has_error then --| include the case a_node = Void
-- sql_query (Sql_last_insert_node_revision, Void)
-- if sql_rows_count = 1 then
-- if not has_error and not sql_after then
-- if sql_item (1) /= Void then
-- Result := sql_read_integer_64 (1)
-- end
@@ -280,6 +289,7 @@ feature -- Access: outline
end
sql_forth
end
sql_finalize
end
available_parents_for_node (a_node: CMS_NODE): LIST [CMS_NODE]
@@ -305,6 +315,7 @@ feature -- Access: outline
end
sql_forth
end
sql_finalize
end
feature -- Change: Node
@@ -326,29 +337,40 @@ feature -- Change: Node
local
l_parameters: STRING_TABLE [ANY]
do
write_information_log (generator + ".delete_node {" + a_id.out + "}")
write_information_log (generator + ".trash_node_by_id {" + a_id.out + "}")
error_handler.reset
create l_parameters.make (3)
l_parameters.put (create {DATE_TIME}.make_now_utc, "changed")
l_parameters.put ({CMS_NODE_API}.trashed, "status")
l_parameters.put (a_id, "nid")
sql_change (sql_trash_node, l_parameters)
sql_modify (sql_trash_node, l_parameters)
sql_finalize
end
delete_node_by_id (a_id: INTEGER_64)
delete_node_base (a_node: CMS_NODE)
-- <Precursor>
local
l_parameters: STRING_TABLE [ANY]
l_time: DATE_TIME
do
create l_time.make_now_utc
write_information_log (generator + ".trash_node {" + a_id.out + "}")
write_information_log (generator + ".delete_node_base {" + a_node.id.out + "}")
error_handler.reset
create l_parameters.make (1)
l_parameters.put (a_id, "nid")
sql_change (sql_delete_node, l_parameters)
l_parameters.put (a_node.id, "nid")
sql_modify (sql_delete_node, l_parameters)
sql_finalize
-- we remove node_revisions and pages.
-- Check: maybe we need a transaction.
sql_modify (sql_delete_node_revisions, l_parameters)
sql_finalize
if not error_handler.has_error then
extended_delete (a_node)
end
end
restore_node_by_id (a_id: INTEGER_64)
@@ -358,14 +380,15 @@ feature -- Change: Node
l_time: DATE_TIME
do
create l_time.make_now_utc
write_information_log (generator + ".restore_node {" + a_id.out + "}")
write_information_log (generator + ".restore_node_by_id {" + a_id.out + "}")
error_handler.reset
create l_parameters.make (1)
l_parameters.put (l_time, "changed")
l_parameters.put ({CMS_NODE_API}.not_published, "status")
l_parameters.put (a_id, "nid")
sql_change (sql_restore_node, l_parameters)
sql_modify (sql_restore_node, l_parameters)
sql_finalize
end
@@ -409,7 +432,9 @@ feature {NONE} -- Implementation
create l_copy_parameters.make (2)
l_copy_parameters.force (a_node.id, "nid")
-- l_copy_parameters.force (l_rev - 1, "revision")
sql_change (sql_copy_node_to_revision, l_copy_parameters)
sql_insert (sql_copy_node_to_revision, l_copy_parameters)
sql_finalize
if not has_error then
a_node.set_revision (l_rev)
@@ -417,7 +442,8 @@ feature {NONE} -- Implementation
-- Update
l_parameters.put (a_node.id, "nid")
l_parameters.put (a_node.revision, "revision")
sql_change (sql_update_node, l_parameters)
sql_modify (sql_update_node, l_parameters)
sql_finalize
if not error_handler.has_error then
a_node.set_modification_date (now)
@@ -428,7 +454,9 @@ feature {NONE} -- Implementation
l_parameters.put (a_node.creation_date, "created")
l_parameters.put (l_rev, "revision")
sql_change (sql_insert_node, l_parameters)
sql_insert (sql_insert_node, l_parameters)
sql_finalize
if not error_handler.has_error then
a_node.set_modification_date (now)
a_node.set_id (last_inserted_node_id)
@@ -520,6 +548,8 @@ feature {NONE} -- Queries
WHERE pn.parent = :nid AND node.status != -1 GROUP BY node.nid, node.revision;
]"
sql_delete_node_revisions: STRING = "DELETE FROM node_revisions WHERE nid=:nid;"
feature {NONE} -- Sql Queries: USER_ROLES collaborators, author
Select_user_author: STRING = "SELECT uid, name, password, salt, email, users.status, users.created, signed FROM nodes INNER JOIN users ON nodes.author=users.uid AND nodes.nid = :nid AND nodes.revision = :revision;"
@@ -545,7 +575,7 @@ feature {NONE} -- Implementation
if attached sql_read_string_32 (5) as l_summary then
Result.set_summary (l_summary)
end
if attached sql_read_string (6) as l_content then
if attached sql_read_string_32 (6) as l_content then
Result.set_content (l_content)
end
if attached sql_read_string (7) as l_format then

View File

@@ -73,17 +73,18 @@ feature -- Persistence
if l_update then
if l_has_modif then
sql_change (sql_update_node_data, l_parameters)
sql_modify (sql_update_node_data, l_parameters)
end
else
if l_has_modif then
sql_change (sql_insert_node_data, l_parameters)
sql_insert (sql_insert_node_data, l_parameters)
else
-- no page data, means everything is empty.
-- FOR NOW: always record row
sql_change (sql_insert_node_data, l_parameters)
sql_insert (sql_insert_node_data, l_parameters)
end
end
sql_finalize
end
end
@@ -112,6 +113,20 @@ feature -- Persistence
end
end
delete_node (a_node: CMS_PAGE)
-- <Precursor>
local
l_parameters: STRING_TABLE [ANY]
do
if a_node.has_id then
create l_parameters.make (1)
l_parameters.put (a_node.id, "nid")
sql_modify (sql_delete_node_data, l_parameters)
sql_finalize
end
end
feature {NONE} -- Implementation
node_data (a_node: CMS_NODE): detachable TUPLE [revision: INTEGER_64; parent_id: INTEGER_64]
@@ -126,14 +141,19 @@ feature {NONE} -- Implementation
l_parameters.put (a_node.revision, "revision")
sql_query (sql_select_node_data, l_parameters)
if not has_error then
n := sql_rows_count
if n = 1 then
if not sql_after then
-- nid, revision, parent
Result := [sql_read_integer_64 (2), sql_read_integer_64 (3)]
sql_forth
if not sql_after then
check unique_data: n = 0 end
Result := Void
end
else
check unique_data: n = 0 end
end
end
sql_finalize
ensure
accepted_revision: Result /= Void implies Result.revision <= a_node.revision
end
@@ -143,5 +163,6 @@ feature -- SQL
sql_select_node_data: STRING = "SELECT nid, revision, parent FROM page_nodes WHERE nid=:nid AND revision<=:revision ORDER BY revision DESC LIMIT 1;"
sql_insert_node_data: STRING = "INSERT INTO page_nodes (nid, revision, parent) VALUES (:nid, :revision, :parent);"
sql_update_node_data: STRING = "UPDATE page_nodes SET nid=:nid, revision=:revision, parent=:parent WHERE nid=:nid AND revision=:revision;"
sql_delete_node_data: STRING = "DELETE FROM page_nodes WHERE nid=:nid;"
end

View File

@@ -121,6 +121,7 @@ feature {CMS_API} -- Module management
end
l_sql_storage.sql_forth
end
l_sql_storage.sql_finalize
across l_consumers as ic loop
if not l_sql_storage.sql_table_exists (ic.item) then
if attached l_sql_storage.sql_script_content (api.module_resource_location (Current, (create {PATH}.make_from_string ("scripts")).extended ("oauth2_table.sql.tpl"))) as sql then
@@ -131,6 +132,7 @@ feature {CMS_API} -- Module management
end
end
end
l_sql_storage.sql_finalize
Precursor {CMS_MODULE}(api)
end
end

View File

@@ -53,11 +53,15 @@ feature -- Access User Outh
create l_string.make_from_string (select_user_oauth2_template_by_id)
l_string.replace_substring_all ("$table_name", oauth2_sql_table_name (a_consumer))
sql_query (l_string, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := fetch_user
else
check no_more_than_one: sql_rows_count = 0 end
sql_forth
if not sql_after then
check no_more_than_one: False end
Result := Void
end
end
sql_finalize
end
user_oauth2_by_email (a_email: like {CMS_USER}.email; a_consumer: READABLE_STRING_GENERAL): detachable CMS_USER
@@ -73,11 +77,15 @@ feature -- Access User Outh
create l_string.make_from_string (select_user_oauth2_template_by_email)
l_string.replace_substring_all ("$table_name", oauth2_sql_table_name (a_consumer))
sql_query (l_string, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := fetch_user
else
check no_more_than_one: sql_rows_count = 0 end
sql_forth
if not sql_after then
check no_more_than_one: False end
Result := Void
end
end
sql_finalize
end
user_oauth2_by_token (a_token: READABLE_STRING_GENERAL; a_consumer: READABLE_STRING_GENERAL): detachable CMS_USER
@@ -93,11 +101,15 @@ feature -- Access User Outh
create l_string.make_from_string (select_user_by_oauth2_template_token)
l_string.replace_substring_all ("$table_name", oauth2_sql_table_name (a_consumer))
sql_query (l_string, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := fetch_user
else
check no_more_than_one: sql_rows_count = 0 end
sql_forth
if not sql_after then
check no_more_than_one: False end
Result := Void
end
end
sql_finalize
end
@@ -122,6 +134,7 @@ feature --Access: Consumers
sql_forth
end
end
sql_finalize
end
oauth_consumer_by_name (a_name: READABLE_STRING_8): detachable CMS_OAUTH_20_CONSUMER
@@ -134,11 +147,15 @@ feature --Access: Consumers
create l_parameters.make (1)
l_parameters.put (a_name, "name")
sql_query (sql_oauth_consumer_name, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := fetch_consumer
else
check no_more_than_one: sql_rows_count = 0 end
sql_forth
if not sql_after then
check no_more_than_one: False end
Result := Void
end
end
sql_finalize
end
oauth_consumer_by_callback (a_callback: READABLE_STRING_8): detachable CMS_OAUTH_20_CONSUMER
@@ -151,11 +168,15 @@ feature --Access: Consumers
create l_parameters.make (1)
l_parameters.put (a_callback, "name")
sql_query (sql_oauth_consumer_callback, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := fetch_consumer
else
check no_more_than_one: sql_rows_count = 0 end
sql_forth
if not sql_after then
check no_more_than_one: False end
Result := Void
end
end
sql_finalize
end
feature -- Change: User OAuth
@@ -181,8 +202,9 @@ feature -- Change: User OAuth
create l_string.make_from_string (sql_insert_oauth2_template)
l_string.replace_substring_all ("$table_name", oauth2_sql_table_name (a_consumer))
sql_change (l_string, l_parameters)
sql_insert (l_string, l_parameters)
sql_commit_transaction
sql_finalize
end
update_user_oauth2 (a_token: READABLE_STRING_GENERAL; a_user_profile: READABLE_STRING_32; a_user: CMS_USER; a_consumer: READABLE_STRING_GENERAL )
@@ -202,8 +224,9 @@ feature -- Change: User OAuth
create l_string.make_from_string (sql_update_oauth2_template)
l_string.replace_substring_all ("$table_name", oauth2_sql_table_name (a_consumer))
sql_change (l_string, l_parameters)
sql_modify (l_string, l_parameters)
sql_commit_transaction
sql_finalize
end
remove_user_oauth2 (a_user: CMS_USER; a_consumer: READABLE_STRING_GENERAL)
@@ -221,8 +244,9 @@ feature -- Change: User OAuth
create l_string.make_from_string (sql_remove_oauth2_template)
l_string.replace_substring_all ("$table_name", oauth2_sql_table_name (a_consumer))
sql_change (l_string, l_parameters)
sql_modify (l_string, l_parameters)
sql_commit_transaction
sql_finalize
end
feature {NONE} -- Implementation OAuth Consumer
@@ -342,7 +366,7 @@ feature {NONE} -- User OAuth2
Sql_remove_oauth2_template: STRING = "DELETE FROM $table_name WHERE uid =:uid;"
Sql_oauth_consumers: STRING = "SELECT name FROM oauth2_consumers";
Sql_oauth_consumers: STRING = "SELECT name FROM oauth2_consumers;"
Sql_oauth2_table_prefix: STRING = "oauth2_"

View File

@@ -33,11 +33,15 @@ feature -- Access User Outh
l_parameters.put (a_uid, "uid")
l_parameters.put (a_identity, "identity")
sql_query (Select_user_openid_by_id, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := fetch_user
else
check no_more_than_one: sql_rows_count = 0 end
sql_forth
if not sql_after then
check no_more_than_one: False end
Result := Void
end
end
sql_finalize
end
user_openid_by_identity (a_identity: READABLE_STRING_GENERAL): detachable CMS_USER
@@ -50,14 +54,19 @@ feature -- Access User Outh
create l_parameters.make (1)
l_parameters.put (a_identity, "identity")
sql_query (Select_user_by_openid_identity, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := fetch_user
sql_forth
if not sql_after then
check no_more_than_one: False end
Result := Void
end
else
check no_more_than_one: sql_rows_count = 0 end
check no_more_than_one: False end
end
sql_finalize
end
feature --Access: Consumers
openid_consumers: LIST [STRING]
@@ -79,6 +88,7 @@ feature --Access: Consumers
sql_forth
end
end
sql_finalize
end
openid_consumer_by_name (a_name: READABLE_STRING_8): detachable CMS_OPENID_CONSUMER
@@ -91,11 +101,14 @@ feature --Access: Consumers
create l_parameters.make (1)
l_parameters.put (a_name, "name")
sql_query (sql_openid_consumer_name, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := fetch_consumer
else
check no_more_than_one: sql_rows_count = 0 end
sql_forth
if not sql_after then
check no_more_than_one: False end
end
end
sql_finalize
end
feature -- Change: User OAuth
@@ -114,8 +127,9 @@ feature -- Change: User OAuth
l_parameters.put (a_user.id, "uid")
l_parameters.put (a_identity, "identity")
l_parameters.put (create {DATE_TIME}.make_now_utc, "utc_date")
sql_change (Sql_insert_openid, l_parameters)
sql_insert (Sql_insert_openid, l_parameters)
sql_commit_transaction
sql_finalize
end
feature {NONE} -- Implementation OAuth Consumer

View File

@@ -1,5 +1,5 @@
note
description: "CMS module that bring support for recent changes."
description: "CMS module that brings support for recent changes."
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
@@ -19,6 +19,8 @@ inherit
CMS_HOOK_RESPONSE_ALTER
CMS_HOOK_BLOCK
create
make
@@ -49,10 +51,142 @@ feature -- Access: router
-- <Precursor>
do
a_router.handle ("/recent_changes/", create {WSF_URI_AGENT_HANDLER}.make (agent handle_recent_changes (a_api, ?, ?)), a_router.methods_head_get)
a_router.handle ("/recent_changes/feed", create {WSF_URI_AGENT_HANDLER}.make (agent handle_recent_changes_feed (a_api, ?, ?)), a_router.methods_head_get)
end
feature -- Hook
block_list: ITERABLE [like {CMS_BLOCK}.name]
-- List of block names, managed by current object.
-- If prefixed by "?", condition will be check
-- to determine if it should be displayed (and computed) or not.
do
Result := <<"?recent_changes">>
end
get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
-- Get block object identified by `a_block_id' and associate with `a_response'.
local
b: CMS_CONTENT_BLOCK
s, l_content: STRING
gen: FEED_TO_XHTML_VISITOR
nb: NATURAL_32
do
if a_block_id.same_string_general ("recent_changes") then
create l_content.make (1024)
create gen.make (l_content)
create s.make_empty
s.append_string ("<liv class=%"nav%">")
s.append_string (a_response.link ("See more ...", "recent_changes/", Void))
s.append_string ("</li>")
gen.set_footer (s)
nb := 10
if
attached a_response.block_options (a_block_id) as l_options and then
attached {READABLE_STRING_GENERAL} l_options.item ("size") as l_size and then
l_size.is_integer
then
nb := l_size.to_natural_32
end
recent_changes_feed (a_response, nb, Void).accept (gen)
create b.make (a_block_id, Void, l_content, Void)
a_response.put_block (b, Void, False)
end
end
recent_changes_feed (a_response: CMS_RESPONSE; a_size: NATURAL_32; a_source: detachable READABLE_STRING_8): FEED
local
l_changes: CMS_RECENT_CHANGE_CONTAINER
ch: CMS_RECENT_CHANGE_ITEM
l_user: detachable CMS_USER
l_feed: FEED
l_feed_item: FEED_ITEM
lnk: FEED_LINK
nb: NATURAL_32
do
l_user := Void -- Public access for the feed!
create l_changes.make (a_size, create {DATE_TIME}.make_now_utc, a_source)
if attached a_response.hooks.subscribers ({CMS_RECENT_CHANGES_HOOK}) as lst then
across
lst as ic
loop
if attached {CMS_RECENT_CHANGES_HOOK} ic.item as h then
if attached h.recent_changes_sources as h_sources then
if
a_source = Void
or else across h_sources as h_ic some h_ic.item.is_case_insensitive_equal (a_source) end
then
h.populate_recent_changes (l_changes, l_user)
end
end
end
end
end
create l_feed.make ("CMS Recent changes")
l_feed.set_date (create {DATE_TIME}.make_now_utc)
nb := a_size
across
l_changes as ic
until
nb = 0
loop
ch := ic.item
create l_feed_item.make (ch.link.title)
l_feed_item.set_date (ch.date)
l_feed_item.set_description (ch.information)
l_feed_item.set_category (ch.source)
create lnk.make (a_response.absolute_url (ch.link.location, Void))
l_feed_item.links.force (lnk, "")
l_feed.extend (l_feed_item)
nb := nb - 1
end
l_feed.sort
Result := l_feed
end
feature -- Handler
handle_recent_changes_feed (api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE)
local
r: CMS_RESPONSE
htdate: HTTP_DATE
l_content: STRING
l_until_date: detachable DATE_TIME
l_until_date_timestamp: INTEGER_64
l_filter_source: detachable READABLE_STRING_8
l_size: NATURAL_32
mesg: CMS_CUSTOM_RESPONSE_MESSAGE
do
if attached {WSF_STRING} req.query_parameter ("date") as p_until_date then
l_until_date_timestamp := p_until_date.value.to_integer_64
create htdate.make_from_timestamp (l_until_date_timestamp)
l_until_date := htdate.date_time
end
if attached {WSF_STRING} req.query_parameter ("source") as p_filter then
l_filter_source := p_filter.url_encoded_value
if l_filter_source.is_empty then
l_filter_source := Void
end
end
if attached {WSF_STRING} req.query_parameter ("size") as p_size then
l_size := p_size.integer_value.to_natural_32
end
if l_size = 0 then
l_size := 25
end
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
create l_content.make (1024)
recent_changes_feed (r, l_size, l_filter_source).accept (create {ATOM_FEED_GENERATOR}.make (l_content))
create mesg.make ({HTTP_STATUS_CODE}.ok)
mesg.set_payload (l_content)
res.send (mesg)
end
handle_recent_changes (api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE)
local
r: CMS_RESPONSE
@@ -66,8 +200,10 @@ feature -- Handler
l_form: CMS_FORM
l_select: WSF_FORM_SELECT
l_size_field: WSF_FORM_NUMBER_INPUT
l_date_field: WSF_FORM_HIDDEN_INPUT
l_submit: WSF_FORM_SUBMIT_INPUT
l_until_date: detachable DATE_TIME
l_until_date_timestamp: INTEGER_64
l_filter_source: detachable READABLE_STRING_8
l_size: NATURAL_32
l_query: STRING
@@ -76,7 +212,8 @@ feature -- Handler
i: INTEGER
do
if attached {WSF_STRING} req.query_parameter ("date") as p_until_date then
create htdate.make_from_timestamp (p_until_date.value.to_integer_64)
l_until_date_timestamp := p_until_date.value.to_integer_64
create htdate.make_from_timestamp (l_until_date_timestamp)
l_until_date := htdate.date_time
-- l_until_date.second_add (-1)
end
@@ -138,6 +275,12 @@ feature -- Handler
l_size_field.set_size (25)
l_size_field.set_label ("Items per page")
l_form.extend (l_size_field)
if l_until_date /= Void then
create l_date_field.make_with_text ("date", l_until_date_timestamp.out)
l_form.extend (l_date_field)
end
create l_submit.make_with_text ("op", "Filter")
l_form.extend (l_submit)
l_form.extend_html_text ("<br/>")
@@ -234,7 +377,7 @@ feature -- Handler
end
l_content.append ("<a href=%"")
l_content.append (r.url (r.location, create {CMS_API_OPTIONS}.make_from_manifest (<<["query", l_query]>>)))
l_content.append ("%">More ...</a>")
l_content.append ("%">See more ...</a>")
end
end
@@ -259,6 +402,7 @@ feature -- Hooks configuration
do
a_response.hooks.subscribe_to_menu_system_alter_hook (Current)
a_response.hooks.subscribe_to_response_alter_hook (Current)
a_response.hooks.subscribe_to_block_hook (Current)
end
feature -- Hook

View File

@@ -16,6 +16,7 @@
<library name="cms" location="..\..\cms-safe.ecf"/>
<library name="cms_model" location="..\..\library\model\cms_model-safe.ecf" readonly="false"/>
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
<library name="feed" location="$ISE_LIBRARY\contrib\library\text\parser\feed\feed-safe.ecf"/>
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="recent_changes" uuid="1C3893A3-46FC-4E60-86AE-37CB7939BC7F" library_target="recent_changes">
<target name="recent_changes">
<root all_classes="true"/>
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" void_safety="none" syntax="transitional">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
<library name="cms" location="..\..\cms.ecf"/>
<library name="cms_model" location="..\..\library\model\cms_model.ecf" readonly="false"/>
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error.ecf"/>
<library name="feed" location="$ISE_LIBRARY\contrib\library\text\parser\feed\feed.ecf"/>
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http.ecf"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension.ecf" readonly="false"/>
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html.ecf" readonly="false"/>
<cluster name="src" location=".\" recursive="true"/>
</target>
</system>

View File

@@ -1,4 +1,4 @@
package ROC_cms
package ROC
project
cms = "cms-safe.ecf"
@@ -19,6 +19,21 @@ project
basic_auth = "modules/basic_auth/basic_auth.ecf"
node = "modules/node/node-safe.ecf"
node = "modules/node/node.ecf"
demo = "examples/demo/demo-safe.ecf"
cms_demo_module = "examples/demo/modules/demo/cms_demo_module-safe.ecf"
config_tests = "library/configuration/tests/config_tests-safe.ecf"
email_service = "library/email/email-safe.ecf"
persistence_sqlite3 = "library/persistence/sqlite3/persistence_sqlite3-safe.ecf"
store_mysql = "library/persistence/store_mysql/store_mysql-safe.ecf"
persistence_store_odbc = "library/persistence/store_odbc/store_odbc-safe.ecf"
tests_store_odbc = "library/persistence/store_odbc/tests/tests-safe.ecf"
admin = "modules/admin/admin-safe.ecf"
auth_module = "modules/auth/auth-safe.ecf"
cms_blog_module = "modules/blog/cms_blog_module-safe.ecf"
feed_aggregator = "modules/feed_aggregator/feed_aggregator-safe.ecf"
oauth_module = "modules/oauth20/oauth20-safe.ecf"
openid_module = "modules/openid/openid-safe.ecf"
recent_changes = "modules/recent_changes/recent_changes-safe.ecf"
note
title: ROC CMS
@@ -27,5 +42,6 @@ note
license: Eiffel Forum v2
copyright: Jocelyn Fiat, Javier Velilla, Eiffel Software
link[source]: "Github" https://github.com/EiffelWebFramework/ROC.git
-- link[doc]: "Documentation" http://
end

94
src/cache/cms_cache.e vendored Normal file
View File

@@ -0,0 +1,94 @@
note
description: "Abstract interface for cache of value conforming to formal {G}."
date: "$Date: 2014-12-03 16:12:08 +0100 (mer., 03 déc. 2014) $"
revision: "$Revision: 96232 $"
deferred class
CMS_CACHE [G -> ANY]
feature -- Status report
exists: BOOLEAN
-- Do associated cache file exists?
deferred
end
expired (a_reference_date: detachable DATE_TIME; a_duration_in_seconds: INTEGER): BOOLEAN
-- Is associated cached item expired?
-- If `a_reference_date' is attached, cache is expired if `a_reference' is more recent than cached item.
local
d1, d2: DATE_TIME
do
if exists then
if
a_reference_date /= Void and then
a_reference_date > cache_date_time
then
Result := True
else
if a_duration_in_seconds = -1 then
Result := False -- Never expires
elseif a_duration_in_seconds = 0 then
Result := True -- Always expires
elseif a_duration_in_seconds > 0 then
d1 := cache_date_time
d2 := current_date_time
d2.second_add (- a_duration_in_seconds) --| do not modify `cache_date_time'
Result := d2 > d1 -- cached date + duration is older than current date
else
-- Invalid expiration value
-- thus always expired.
Result := True
end
end
else
Result := True
end
end
feature -- Access
item: detachable G
-- Value from the cache.
deferred
end
cache_date_time: DATE_TIME
-- Date time for current cache if exists.
-- Note: it may be UTC or not , depending on cache type.
deferred
end
cache_duration_in_seconds: INTEGER_64
-- Number of seconds since cache was set.
require
exists: exists
local
d1, d2: DATE_TIME
do
d1 := cache_date_time
d2 := current_date_time
Result := d2.relative_duration (d1).seconds_count
end
current_date_time: DATE_TIME
-- Current date time for relative duration with cache_date_time.
deferred
end
feature -- Element change
delete
-- Remove cache.
deferred
end
put (g: G)
-- Put `g' into cache.
deferred
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

150
src/cache/cms_file_cache.e vendored Normal file
View File

@@ -0,0 +1,150 @@
note
description: "Cache using a local file."
date: "$Date: 2015-09-24 18:24:06 +0200 (jeu., 24 sept. 2015) $"
revision: "$Revision: 97926 $"
deferred class
CMS_FILE_CACHE [G -> ANY]
inherit
CMS_CACHE [G]
feature {NONE} -- Initialization
make (a_cache_filename: PATH)
do
path := a_cache_filename
end
path: PATH
feature -- Status report
exists: BOOLEAN
-- Do associated cache file exists?
local
ut: FILE_UTILITIES
do
Result := ut.file_path_exists (path)
end
feature -- Access
cache_date_time: DATE_TIME
-- <Precursor>
local
f: RAW_FILE
do
create f.make_with_path (path)
if f.exists then
Result := utc_file_date_time (f)
else
create Result.make_now_utc
end
end
current_date_time: DATE_TIME
-- <Precursor>
do
-- UTC, since `cache_date_time' is UTC!
create Result.make_now_utc
end
file_size: INTEGER
-- Associated file size.
require
exists: exists
local
f: RAW_FILE
do
create f.make_with_path (path)
if f.exists and then f.is_access_readable then
Result := f.count
end
end
item: detachable G
local
f: RAW_FILE
retried: BOOLEAN
do
if not retried then
create f.make_with_path (path)
if f.exists and then f.is_access_readable then
f.open_read
Result := file_to_item (f)
f.close
end
end
rescue
retried := True
retry
end
feature -- Element change
delete
-- <Precursor>
local
f: RAW_FILE
retried: BOOLEAN
do
if not retried then
create f.make_with_path (path)
-- Create recursively parent directory if it does not exists.
if f.exists and then f.is_access_writable then
f.delete
end
end
rescue
retried := True
retry
end
put (g: G)
-- <Precursor>
local
f: RAW_FILE
d: DIRECTORY
do
create f.make_with_path (path)
-- Create recursively parent directory if it does not exists.
create d.make_with_path (path.parent)
if not d.exists then
d.recursive_create_dir
end
if not f.exists or else f.is_access_writable then
f.open_write
item_to_file (g, f)
f.close
end
end
feature -- Helpers
utc_file_date_time (f: FILE): DATE_TIME
-- Last change date for file `f'.
require
f.exists
do
create Result.make_from_epoch (f.date.as_integer_32)
end
feature {NONE} -- Implementation
file_to_item (f: FILE): detachable G
require
is_open_write: f.is_open_read
deferred
end
item_to_file (g: G; f: FILE)
require
is_open_write: f.is_open_write
deferred
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

49
src/cache/cms_file_object_cache.e vendored Normal file
View File

@@ -0,0 +1,49 @@
note
description: "Cache for value conforming to formal {G}, and implemented using local file."
date: "$Date: 2014-10-30 12:13:25 +0100 (jeu., 30 oct. 2014) $"
revision: "$Revision: 96016 $"
class
CMS_FILE_OBJECT_CACHE [G -> ANY]
inherit
CMS_FILE_CACHE [G]
SED_STORABLE_FACILITIES
create
make
feature {NONE} -- Implementation
file_to_item (f: FILE): detachable G
local
retried: BOOLEAN
l_reader: SED_MEDIUM_READER_WRITER
l_void: detachable G
do
if retried then
Result := l_void
else
create l_reader.make_for_reading (f)
if attached {G} retrieved (l_reader, True) as l_data then
Result := l_data
end
end
rescue
retried := True
retry
end
item_to_file (a_data: G; f: FILE)
local
l_writer: SED_MEDIUM_READER_WRITER
do
create l_writer.make_for_writing (f)
basic_store (a_data, l_writer, True)
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

69
src/cache/cms_file_string_8_cache.e vendored Normal file
View File

@@ -0,0 +1,69 @@
note
description: "Cache system for STRING_8 value."
date: "$Date: 2014-10-30 12:13:25 +0100 (jeu., 30 oct. 2014) $"
revision: "$Revision: 96016 $"
class
CMS_FILE_STRING_8_CACHE
inherit
CMS_FILE_CACHE [STRING]
create
make
feature -- Access
append_to (a_output: STRING)
-- Append `item' to `a_output'.
local
f: RAW_FILE
retried: BOOLEAN
do
if not retried then
create f.make_with_path (path)
if f.exists and then f.is_access_readable then
f.open_read
if attached file_to_item (f) as s then
a_output.append (s)
end
f.close
end
end
rescue
retried := True
retry
end
feature {NONE} -- Implementation
file_to_item (f: FILE): detachable STRING
local
retried: BOOLEAN
do
if retried then
Result := Void
else
from
create Result.make_empty
until
f.exhausted or f.end_of_file
loop
f.read_stream_thread_aware (1_024)
Result.append (f.last_string)
end
end
rescue
retried := True
retry
end
item_to_file (a_data: STRING; f: FILE)
do
f.put_string (a_data)
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

61
src/cache/cms_memory_cache.e vendored Normal file
View File

@@ -0,0 +1,61 @@
note
description: "Cache relying on memory."
date: "$Date: 2014-12-03 16:57:00 +0100 (mer., 03 déc. 2014) $"
revision: "$Revision: 96234 $"
deferred class
CMS_MEMORY_CACHE [G -> ANY]
inherit
CMS_CACHE [G]
feature {NONE} -- Initialization
make
do
cache_date_time := current_date_time
end
feature -- Status report
exists: BOOLEAN
-- Do associated cache memory exists?
do
Result := item /= Void
end
feature -- Access
cache_date_time: DATE_TIME
current_date_time: DATE_TIME
-- <Precursor>
do
create Result.make_now_utc
end
item: detachable G
feature -- Element change
delete
-- <Precursor>
local
l_default: detachable G
do
item := l_default
cache_date_time := current_date_time
end
put (g: G)
-- <Precursor>
do
item := g
cache_date_time := current_date_time
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -68,6 +68,18 @@ feature -- Access
Result := configuration.resolved_text_item (a_name)
end
text_list_item (a_name: READABLE_STRING_GENERAL): detachable LIST [READABLE_STRING_32]
-- Configuration values associated with `a_name', if any.
do
Result := configuration.text_list_item (a_name)
end
text_table_item (a_name: READABLE_STRING_GENERAL): detachable STRING_TABLE [READABLE_STRING_32]
-- Configuration indexed values associated with `a_name', if any.
do
Result := configuration.text_table_item (a_name)
end
string_8_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_8
-- String 8 configuration value associated with `a_name', if any.
local
@@ -86,13 +98,19 @@ feature -- Access
local
retried: BOOLEAN
f: FILE
l_chain: NOTIFICATION_CHAIN_MAILER
l_storage_mailer: NOTIFICATION_STORAGE_MAILER
l_mailer: detachable NOTIFICATION_MAILER
do
if not retried then
if attached text_item ("mailer.smtp") as l_smtp then
create {NOTIFICATION_SMTP_MAILER} mailer.make (l_smtp)
create {NOTIFICATION_SMTP_MAILER} l_mailer.make (l_smtp)
elseif attached text_item ("mailer.sendmail") as l_sendmail then
create {NOTIFICATION_SENDMAIL_MAILER} mailer.make_with_location (l_sendmail)
elseif attached text_item ("mailer.output") as l_output then
create {NOTIFICATION_SENDMAIL_MAILER} l_mailer.make_with_location (l_sendmail)
end
-- If a mailer.ouput is set, set a notification chain with potential previous mailer
-- and file storage.
if attached text_item ("mailer.output") as l_output then
if l_output.is_case_insensitive_equal ("@stderr") then
f := io.error
elseif l_output.is_case_insensitive_equal ("@stdout") then
@@ -104,10 +122,18 @@ feature -- Access
f.close
end
end
create {NOTIFICATION_STORAGE_MAILER} mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (f))
else
create {NOTIFICATION_STORAGE_MAILER} mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (io.error))
create {NOTIFICATION_STORAGE_MAILER} l_storage_mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (f))
if l_mailer /= Void then
create l_chain.make (l_mailer)
l_chain.set_next (l_storage_mailer)
l_mailer := l_chain
else
l_mailer := l_storage_mailer
end
elseif l_mailer = Void then
create {NOTIFICATION_STORAGE_MAILER} l_mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (io.error))
end
mailer := l_mailer
else
check valid_mailer: False end
-- FIXME: should we report persistent error message? If yes, see how.

View File

@@ -196,6 +196,16 @@ feature -- Query
deferred
end
text_list_item (a_name: READABLE_STRING_GENERAL): detachable LIST [READABLE_STRING_32]
-- Configuration values associated with `a_name', if any.
deferred
end
text_table_item (a_name: READABLE_STRING_GENERAL): detachable STRING_TABLE [READABLE_STRING_32]
-- Configuration indexed values associated with `a_name', if any.
deferred
end
text_item_or_default (a_name: READABLE_STRING_GENERAL; a_default_value: READABLE_STRING_GENERAL): READABLE_STRING_32
-- `text_item' associated with `a_name' or if none, `a_default_value'.
do

View File

@@ -15,6 +15,8 @@ feature -- Hook
block_list: ITERABLE [like {CMS_BLOCK}.name]
-- List of block names, managed by current object.
-- If prefixed by "?", condition will be check
-- to determine if it should be displayed (and computed) or not.
deferred
end
@@ -23,4 +25,7 @@ feature -- Hook
deferred
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -0,0 +1,31 @@
note
description: "[
Hook providing cache related management facilities.
]"
date: "$Date: 2014-11-19 20:00:19 +0100 (mer., 19 nov. 2014) $"
revision: "$Revision: 96123 $"
deferred class
CMS_HOOK_CACHE
inherit
CMS_HOOK
feature -- Hook
clear_cache (a_cache_id_list: detachable ITERABLE [READABLE_STRING_GENERAL]; a_response: CMS_RESPONSE)
-- Clear caches identified by `a_cache_id_list',
-- or clear all caches if `a_cache_id_list' is Void.
deferred
end
cache_identifiers: detachable ITERABLE [like {CMS_BLOCK}.name]
-- Optional list of cache id, if any.
do
-- To redefine if needed.
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -104,7 +104,6 @@ feature -- Hook: menu_alter
end
end
feature -- Hook: form_alter
subscribe_to_form_alter_hook (h: CMS_HOOK_FORM_ALTER)
@@ -138,8 +137,16 @@ feature -- Hook: block
invoke_block (a_response: CMS_RESPONSE)
-- Invoke block hook for response `a_response' in order to get block from modules.
local
bl, l_alias: READABLE_STRING_8
bl_optional: BOOLEAN
l_block_cache: detachable TUPLE [block: CMS_CACHE_BLOCK; region: READABLE_STRING_8; expired: BOOLEAN]
l_alias_table: detachable STRING_TABLE [LIST [READABLE_STRING_8]] --| block_id => [alias_ids..]
l_origin_block: detachable CMS_BLOCK
do
if attached subscribers ({CMS_HOOK_BLOCK}) as lst then
l_alias_table := a_response.block_alias_table
across
lst as c
loop
@@ -147,13 +154,75 @@ feature -- Hook: block
across
h.block_list as blst
loop
h.get_block_view (blst.item, a_response)
bl := blst.item
bl_optional := bl.count > 0 and bl[1] = '?'
if bl_optional then
bl := bl.substring (2, bl.count)
end
if a_response.is_block_included (bl, not bl_optional) then
l_block_cache := a_response.block_cache (bl)
if l_block_cache /= Void and then not l_block_cache.expired then
a_response.add_block (l_block_cache.block, l_block_cache.region)
else
h.get_block_view (bl, a_response)
end
end
if
l_alias_table /= Void and then
attached l_alias_table.item (bl) as l_aliases
then
across
l_aliases as aliases_ic
loop
l_alias := aliases_ic.item
l_origin_block := a_response.blocks.item (bl)
if l_origin_block = Void then
h.get_block_view (bl, a_response)
l_origin_block := a_response.blocks.item (bl)
if l_origin_block /= Void then
-- Previously, it was not included.
-- Computed only to include alias
-- then remove `l_origin_block'.
a_response.remove_block (l_origin_block)
end
end
if l_origin_block /= Void then
a_response.add_block (create {CMS_ALIAS_BLOCK}.make_with_block (l_alias, l_origin_block), Void)
end
end
end
end
end
end
end
end
feature -- Hook: cache
subscribe_to_cache_hook (h: CMS_HOOK_CACHE)
-- Add `h' as subscriber of cache hooks CMS_HOOK_CACHE,
-- and response `a_response'.
do
subscribe_to_hook (h, {CMS_HOOK_CACHE})
end
invoke_clear_cache (a_cache_id_list: detachable ITERABLE [READABLE_STRING_GENERAL]; a_response: CMS_RESPONSE)
-- Invoke cache hook for identifiers `a_cache_id_list'.
do
if attached subscribers ({CMS_HOOK_CACHE}) as lst then
across
lst as c
loop
if attached {CMS_HOOK_CACHE} c.item as h then
h.clear_cache (a_cache_id_list, a_response)
end
end
a_response.clear_block_caches (a_cache_id_list)
end
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -0,0 +1,24 @@
note
description: "Condition for block to be displayed."
date: "$Date$"
revision: "$Revision$"
deferred class
CMS_BLOCK_CONDITION
feature -- Access
description: READABLE_STRING_32
deferred
end
feature -- Evaluation
satisfied_for_response (res: CMS_RESPONSE): BOOLEAN
deferred
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -0,0 +1,72 @@
note
description: "Condition for block to be displayed."
date: "$Date$"
revision: "$Revision$"
class
CMS_BLOCK_EXPRESSION_CONDITION
inherit
CMS_BLOCK_CONDITION
create
make,
make_none
feature {NONE} -- Initialization
make (a_exp: READABLE_STRING_8)
do
expression := a_exp
end
make_none
do
make ("<none>")
end
feature -- Access
description: STRING_32
do
create Result.make_from_string_general ("Expression: %"")
Result.append_string_general (expression)
Result.append_character ('%"')
end
expression: STRING
feature -- Evaluation
satisfied_for_response (res: CMS_RESPONSE): BOOLEAN
local
exp: like expression
l_path: READABLE_STRING_8
kmp: KMP_WILD
do
exp := expression
if exp.same_string ("is_front") then
Result := res.is_front
elseif exp.same_string ("*") then
Result := True
elseif exp.same_string ("<none>") then
Result := False
elseif exp.starts_with ("path:") then
l_path := exp.substring (6, exp.count)
if l_path.has ('*') then
if l_path.index_of ('*', 1) = l_path.count then
Result := res.location.starts_with_general (l_path.substring (1, l_path.count - 1))
else
create kmp.make (l_path, res.location)
Result := kmp.pattern_matches
end
else
Result := res.location.same_string (l_path)
end
end
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -0,0 +1,43 @@
note
description: "Condition for block to be displayed based on location."
date: "$Date$"
revision: "$Revision$"
class
CMS_BLOCK_LOCATION_CONDITION
inherit
CMS_BLOCK_CONDITION
create
make_with_location
feature {NONE} -- Initialization
make_with_location (a_location: READABLE_STRING_8)
do
location := a_location
end
feature -- Access
description: STRING_32
do
create Result.make_from_string_general ("Location: %"")
Result.append_string_general (location)
Result.append_character ('%"')
end
location: READABLE_STRING_8
feature -- Evaluation
satisfied_for_response (res: CMS_RESPONSE): BOOLEAN
do
Result := res.location.same_string (location)
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -0,0 +1,59 @@
note
description: "[
Block being an alias of other block.
Mainly to avoid multiple region for a block content.
]"
date: "$Date$"
revision: "$Revision$"
class
CMS_ALIAS_BLOCK
inherit
CMS_BLOCK
create
make_with_block
feature {NONE} -- Initialization
make_with_block (a_name: READABLE_STRING_8; a_block: CMS_BLOCK)
do
name := a_name
origin := a_block
title := a_block.title
end
feature -- Access
origin: CMS_BLOCK
name: READABLE_STRING_8
feature -- Status report
is_empty: BOOLEAN
-- <Precursor>
do
Result := origin.is_empty
end
is_raw: BOOLEAN
-- <Precursor>
do
Result := origin.is_raw
end
feature -- Conversion
to_html (a_theme: CMS_THEME): STRING_8
-- HTML representation of Current block.
do
Result := origin.to_html (a_theme)
end
;note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -6,7 +6,17 @@ deferred class
CMS_BLOCK
inherit
CMS_BLOCK_SETUP
undefine
is_equal
end
COMPARABLE
DEBUG_OUTPUT
undefine
is_equal
end
feature -- Access
@@ -15,11 +25,6 @@ feature -- Access
deferred
end
title: detachable READABLE_STRING_32
-- Optional title.
deferred
end
html_options: detachable CMS_HTML_OPTIONS
-- Optional addition html options.
@@ -39,6 +44,14 @@ feature -- Status report
deferred
end
feature -- Comparison
is_less alias "<" (other: like Current): BOOLEAN
-- <Precursor>.
do
Result := weight < other.weight
end
feature -- Element change
add_css_class (a_class: READABLE_STRING_8)

View File

@@ -41,6 +41,16 @@ feature -- Element change
blocks.prune_all (b)
end
feature -- Sort
sort
local
cmp: QUICK_SORTER [CMS_BLOCK]
do
create cmp.make (create {COMPARABLE_COMPARATOR [CMS_BLOCK]})
cmp.sort (blocks)
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -0,0 +1,55 @@
note
description: "Settings for CMS_BLOCK, that could be set and overwritten via CMS configuration."
date: "$Date$"
revision: "$Revision$"
class
CMS_BLOCK_SETUP
feature -- Access
title: detachable READABLE_STRING_32
-- Optional title.
weight: INTEGER
-- Weight used to order blocks.
-- Default: 0.
conditions: detachable LIST [CMS_BLOCK_CONDITION]
-- Optional block condition to be enabled.
feature -- Element change
set_title (a_title: detachable READABLE_STRING_GENERAL)
-- Set `title' with `a_title'.
do
if a_title = Void then
title := Void
else
title := a_title.as_string_32
end
end
set_weight (w: like weight)
-- Set `weight' to `w'.
do
weight := w
end
add_condition (a_condition: CMS_BLOCK_CONDITION)
-- Add condition `a_condition'.
local
l_conditions: like conditions
do
l_conditions := conditions
if l_conditions = Void then
create {ARRAYED_LIST [CMS_BLOCK_CONDITION]} l_conditions.make (1)
conditions := l_conditions
end
l_conditions.force (a_condition)
end
;note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -0,0 +1,90 @@
note
description: "[
CMS_BLOCK implemented with a `cache'
as caching solution.
]"
date: "$Date: 2014-11-18 10:13:13 +0100 (mar., 18 nov. 2014) $"
revision: "$Revision: 96110 $"
class
CMS_CACHE_BLOCK
inherit
CMS_BLOCK
create
make
feature {NONE} -- Initialization
make (a_name: like name; a_cache: like cache)
require
a_name_not_blank: not a_name.is_whitespace
do
is_enabled := True
name := a_name
cache := a_cache
set_is_raw (True)
end
feature -- Access
name: READABLE_STRING_8
-- <Precursor>
cache: CMS_CACHE [READABLE_STRING_8]
-- Cache content.
feature -- Status report
is_empty: BOOLEAN
-- Is current block empty?
do
Result := is_raw and not cache.exists
end
is_raw: BOOLEAN assign set_is_raw
-- Is raw?
-- If True, do not get wrapped it with block specific div
feature -- Element change
set_is_raw (b: BOOLEAN)
do
is_raw := b
end
set_name (n: like name)
-- Set `name' to `n'.
require
not n.is_whitespace
do
name := n
end
feature -- Conversion
to_html (a_theme: CMS_THEME): STRING_8
do
debug
print ("REUSE CACHE for [" + name + "]!!!%N")
end
-- Why in this particular case theme is not used to generate the content?
if attached cache.item as l_content then
Result := l_content
else
Result := ""
check exists: False end
end
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -39,9 +39,6 @@ feature -- Access
name: READABLE_STRING_8
-- <Precursor>
title: detachable READABLE_STRING_32
-- <Precursor>
content: READABLE_STRING_8
format: detachable CONTENT_FORMAT
@@ -74,12 +71,6 @@ feature -- Element change
name := n
end
set_title (a_title: like title)
-- Set `title' to `a_title'.
do
title := a_title
end
feature -- Conversion
to_html (a_theme: CMS_THEME): STRING_8

View File

@@ -48,9 +48,6 @@ feature -- Access
name: READABLE_STRING_8
-- <Precursor>
title: detachable READABLE_STRING_32
-- <Precursor>
location: PATH
-- Location of file.
@@ -105,12 +102,6 @@ feature -- Element change
name := n
end
set_title (a_title: like title)
-- Set `title' to `a_title'.
do
title := a_title
end
feature -- Conversion
to_html (a_theme: CMS_THEME): STRING_8

View File

@@ -27,8 +27,6 @@ feature -- Access
name: READABLE_STRING_8
title: detachable READABLE_STRING_32
feature -- Status report
is_empty: BOOLEAN
@@ -53,12 +51,6 @@ feature -- Element change
name := n
end
set_title (a_title: like title)
-- Set `title' to `a_title'.
do
title := a_title
end
set_is_horizontal (b: BOOLEAN)
-- Set `is_horizontal' to `b'.
do

View File

@@ -15,9 +15,12 @@ inherit
select
out
end
SHARED_TEMPLATE_CONTEXT
rename
out as tpl_out
undefine
is_equal
end
create
@@ -55,9 +58,6 @@ feature -- Access
name: READABLE_STRING_8
-- <Precursor>
title: detachable READABLE_STRING_32
-- <Precursor>
location: PATH
-- Location of template file.
@@ -91,12 +91,6 @@ feature -- Element change
name := n
end
set_title (a_title: like title)
-- Set `title' to `a_title'.
do
title := a_title
end
set_value (v: detachable ANY; k: READABLE_STRING_GENERAL)
-- Associate value `v' with key `k'.
do

View File

@@ -58,7 +58,7 @@ feature -- Hooks
block_list: ITERABLE [like {CMS_BLOCK}.name]
do
Result := <<"debug-info">>
Result := <<"?debug-info">>
end
get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
@@ -67,14 +67,13 @@ feature -- Hooks
dbg: WSF_DEBUG_INFORMATION
s: STRING
do
if a_response.theme.has_region ("debug") then
create dbg.make
create s.make_empty
dbg.append_information_to (a_response.request, a_response.response, s)
append_info_to ("Storage", a_response.api.storage.generator, a_response, s)
create b.make ("debug-info", "Debug", s, a_response.formats.plain_text)
a_response.add_block (b, "footer")
end
create dbg.make
create s.make_empty
dbg.append_information_to (a_response.request, a_response.response, s)
append_info_to ("Storage", a_response.api.storage.generator, a_response, s)
create b.make ("debug-info", "Debug", s, a_response.formats.plain_text)
b.add_condition (create {CMS_BLOCK_EXPRESSION_CONDITION}.make_none)
a_response.add_block (b, "footer")
end
feature -- Handler

View File

@@ -37,7 +37,8 @@ feature -- URL aliases
error_handler.add_custom_error (0, "alias exists", "Path alias %"" + a_alias + "%" already exists!")
end
else
sql_change (sql_insert_path_alias, l_parameters)
sql_insert (sql_insert_path_alias, l_parameters)
sql_finalize
end
end
@@ -63,7 +64,8 @@ feature -- URL aliases
l_parameters.put (l_previous_alias, "old")
l_parameters.put (a_alias, "alias")
sql_change (sql_update_path_alias, l_parameters)
sql_modify (sql_update_path_alias, l_parameters)
sql_finalize
end
end
@@ -79,7 +81,8 @@ feature -- URL aliases
-- Found
create l_parameters.make (1)
l_parameters.put (a_alias, "alias")
sql_change (sql_delete_path_alias, l_parameters)
sql_modify (sql_delete_path_alias, l_parameters)
sql_finalize
else
error_handler.add_custom_error (0, "alias mismatch", "Path alias %"" + a_alias + "%" is not related to source %"" + a_source + "%"!")
end
@@ -97,11 +100,12 @@ feature -- URL aliases
create l_parameters.make (1)
l_parameters.put (a_source, "source")
sql_query (sql_select_path_source, l_parameters)
if not has_error then
if sql_rows_count = 1 then
Result := sql_read_string (1)
end
if not has_error and not sql_after then
Result := sql_read_string (1)
sql_forth
check one_row: sql_after end
end
sql_finalize
end
source_of_path_alias (a_alias: READABLE_STRING_8): detachable READABLE_STRING_8
@@ -114,10 +118,13 @@ feature -- URL aliases
l_parameters.put (a_alias, "alias")
sql_query (sql_select_path_alias, l_parameters)
if not has_error then
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := sql_read_string (1)
sql_forth
check one_row: sql_after end
end
end
sql_finalize
end
sql_select_path_alias: STRING = "SELECT source FROM path_aliases WHERE alias=:alias ;"
@@ -166,7 +173,8 @@ feature -- Logs
l_parameters.put (Void, "link")
end
l_parameters.put (now, "date")
sql_change (sql_insert_log, l_parameters)
sql_insert (sql_insert_log, l_parameters)
sql_finalize
end
sql_insert_log: STRING = "INSERT INTO logs (category, level, uid, message, info, link, date) VALUES (:category, :level, :uid, :message, :info, :link, :date);"
@@ -193,10 +201,12 @@ feature -- Misc
if a_value.same_string (l_value) then
-- already up to date
else
sql_change (sql_update_custom_value, l_parameters)
sql_modify (sql_update_custom_value, l_parameters)
sql_finalize
end
else
sql_change (sql_insert_custom_value, l_parameters)
sql_insert (sql_insert_custom_value, l_parameters)
sql_finalize
end
end
@@ -214,7 +224,8 @@ feature -- Misc
l_parameters.put (a_type, "default")
end
l_parameters.put (a_name, "name")
sql_change (sql_delete_custom_value, l_parameters)
sql_modify (sql_delete_custom_value, l_parameters)
sql_finalize
end
custom_value (a_name: READABLE_STRING_GENERAL; a_type: detachable READABLE_STRING_8): detachable READABLE_STRING_32
@@ -232,11 +243,12 @@ feature -- Misc
end
l_parameters.put (a_name, "name")
sql_query (sql_select_custom_value, l_parameters)
if not has_error then
if sql_rows_count = 1 then
Result := sql_read_string_32 (1)
end
if not has_error and not sql_after then
Result := sql_read_string_32 (1)
sql_forth
check one_row: sql_after end
end
sql_finalize
end
sql_select_custom_value: STRING = "SELECT value FROM custom_values WHERE type=:type AND name=:name;"
@@ -252,4 +264,7 @@ feature -- Misc
-- SQL delete custom value;
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -68,19 +68,24 @@ feature -- Operation
sql_storage.sql_query (a_sql_statement, a_params)
end
sql_change (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
sql_finalize
-- Finalize sql query (i.e destroy previous query statement.
do
sql_storage.sql_change (a_sql_statement, a_params)
sql_storage.sql_finalize
end
sql_insert (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
do
sql_storage.sql_insert (a_sql_statement, a_params)
end
sql_modify (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
do
sql_storage.sql_modify (a_sql_statement, a_params)
end
feature -- Access
sql_rows_count: INTEGER
-- Number of rows for last sql execution.
do
Result := sql_storage.sql_rows_count
end
sql_start
-- Set the cursor on first element.
do
@@ -109,6 +114,16 @@ feature -- Access
Result:= sql_storage.sql_item (a_index)
end
sql_read_integer_32 (a_index: INTEGER_32): INTEGER_32
do
Result := sql_storage.sql_read_integer_32 (a_index)
end
sql_read_date_time (a_index: INTEGER_32): detachable DATE_TIME
do
Result := sql_storage.sql_read_date_time (a_index)
end
feature -- Conversion
sql_statement (a_statement: STRING): STRING
@@ -117,4 +132,7 @@ feature -- Conversion
Result := sql_storage.sql_statement (a_statement)
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -119,12 +119,22 @@ feature -- Operation
end
sql_query (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
-- <Precursor>
-- Execute sql query `a_sql_statement' with optional parameters `a_params'.
deferred
end
sql_change (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
-- <Precursor>
sql_finalize
-- Finalize sql query (i.e destroy previous query statement.
deferred
end
sql_insert (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
-- Execute sql insert `a_sql_statement' with optional parameters `a_params'.
deferred
end
sql_modify (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
-- Execute sql modify `a_sql_statement' with optional parameters `a_params'.
deferred
end
@@ -179,7 +189,11 @@ feature -- Helper
loop
if attached next_sql_statement (a_sql_script, i, cl) as s then
if not s.is_whitespace then
sql_change (sql_statement (s), a_params)
if s.starts_with ("INSERT") then
sql_insert (sql_statement (s), a_params)
else
sql_modify (sql_statement (s), a_params)
end
err := err or has_error
reset_error
end
@@ -193,6 +207,7 @@ feature -- Helper
else
sql_commit_transaction
end
sql_finalize
end
sql_table_exists (a_table_name: READABLE_STRING_8): BOOLEAN
@@ -202,6 +217,7 @@ feature -- Helper
sql_query ("SELECT count(*) FROM " + a_table_name + " ;", Void)
Result := not has_error
-- FIXME: find better solution
sql_finalize
reset_error
end
@@ -213,15 +229,11 @@ feature -- Helper
if not has_error then
Result := sql_read_integer_64 (1)
end
sql_finalize
end
feature -- Access
sql_rows_count: INTEGER
-- Number of rows for last sql execution.
deferred
end
sql_start
-- Set the cursor on first element.
deferred
@@ -279,17 +291,7 @@ feature -- Access
sql_read_integer_32 (a_index: INTEGER): INTEGER_32
-- Retrieved value at `a_index' position in `item'.
local
l_item: like sql_item
do
l_item := sql_item (a_index)
if attached {INTEGER_32} l_item as i then
Result := i
elseif attached {INTEGER_32_REF} l_item as l_value then
Result := l_value.item
else
check is_integer_32: False end
end
deferred
end
sql_read_string (a_index: INTEGER): detachable STRING
@@ -300,6 +302,11 @@ feature -- Access
l_item := sql_item (a_index)
if attached {READABLE_STRING_8} l_item as l_string then
Result := l_string
elseif
attached {READABLE_STRING_32} l_item as l_string_32 and then
l_string_32.is_valid_as_string_8
then
Result := l_string_32.to_string_8
elseif attached {BOOLEAN} l_item as l_boolean then
Result := l_boolean.out
elseif attached {BOOLEAN_REF} l_item as l_boolean_ref then
@@ -313,11 +320,14 @@ feature -- Access
-- Retrieved value at `a_index' position in `item'.
local
l_item: like sql_item
utf: UTF_CONVERTER
do
-- FIXME: handle string_32 !
l_item := sql_item (a_index)
if attached {READABLE_STRING_32} l_item as l_string then
Result := l_string
elseif attached {READABLE_STRING_8} l_item as l_string_8 then
Result := utf.utf_8_string_8_to_string_32 (l_string_8)
else
if attached sql_read_string (a_index) as s8 then
Result := s8.to_string_32 -- FIXME: any escape?
@@ -329,15 +339,7 @@ feature -- Access
sql_read_date_time (a_index: INTEGER): detachable DATE_TIME
-- Retrieved value at `a_index' position in `item'.
local
l_item: like sql_item
do
l_item := sql_item (a_index)
if attached {DATE_TIME} l_item as dt then
Result := dt
else
check is_date_time_nor_null: l_item = Void end
end
deferred
end
sql_read_boolean (a_index: INTEGER): detachable BOOLEAN

View File

@@ -30,10 +30,12 @@ feature -- Access: user
write_information_log (generator + ".user_count")
sql_query (select_users_count, Void)
if sql_rows_count = 1 then
Result := sql_read_integer_32 (1)
if not has_error and then not sql_after then
Result := sql_read_integer_64 (1).to_integer_32
sql_forth
check one_row: sql_after end
end
error_handler.reset
sql_finalize
end
users: LIST [CMS_USER]
@@ -47,13 +49,14 @@ feature -- Access: user
sql_query (select_users, Void)
sql_start
until
sql_after
sql_after or has_error
loop
if attached fetch_user as l_user then
Result.force (l_user)
end
sql_forth
end
sql_finalize
end
user_by_id (a_id: like {CMS_USER}.id): detachable CMS_USER
@@ -66,11 +69,12 @@ feature -- Access: user
create l_parameters.make (1)
l_parameters.put (a_id, "uid")
sql_query (select_user_by_id, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := fetch_user
else
check no_more_than_one: sql_rows_count = 0 end
sql_forth
check one_row: sql_after end
end
sql_finalize
end
user_by_name (a_name: like {CMS_USER}.name): detachable CMS_USER
@@ -83,11 +87,12 @@ feature -- Access: user
create l_parameters.make (1)
l_parameters.put (a_name, "name")
sql_query (select_user_by_name, l_parameters)
if sql_rows_count = 1 then
if not sql_after then
Result := fetch_user
else
check no_more_than_one: sql_rows_count = 0 end
sql_forth
check one_row: sql_after end
end
sql_finalize
end
user_by_email (a_email: like {CMS_USER}.email): detachable CMS_USER
@@ -100,11 +105,12 @@ feature -- Access: user
create l_parameters.make (1)
l_parameters.put (a_email, "email")
sql_query (select_user_by_email, l_parameters)
if sql_rows_count = 1 then
if not sql_after then
Result := fetch_user
else
check no_more_than_one: sql_rows_count = 0 end
sql_forth
check one_row: sql_after end
end
sql_finalize
end
user_by_activation_token (a_token: READABLE_STRING_32): detachable CMS_USER
@@ -117,11 +123,12 @@ feature -- Access: user
create l_parameters.make (1)
l_parameters.put (a_token, "token")
sql_query (select_user_by_activation_token, l_parameters)
if sql_rows_count = 1 then
if not sql_after then
Result := fetch_user
else
check no_more_than_one: sql_rows_count = 0 end
sql_forth
check one_row: sql_after end
end
sql_finalize
end
user_by_password_token (a_token: READABLE_STRING_32): detachable CMS_USER
@@ -134,11 +141,12 @@ feature -- Access: user
create l_parameters.make (1)
l_parameters.put (a_token, "token")
sql_query (select_user_by_password_token, l_parameters)
if sql_rows_count = 1 then
if not sql_after then
Result := fetch_user
else
check no_more_than_one: sql_rows_count = 0 end
sql_forth
check one_row: sql_after end
end
sql_finalize
end
is_valid_credential (l_auth_login, l_auth_password: READABLE_STRING_32): BOOLEAN
@@ -160,7 +168,6 @@ feature -- Access: user
write_information_log (generator + ".is_valid_credential User:" + l_auth_login + "does not exist" )
end
end
end
recent_users (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_USER]
@@ -187,6 +194,7 @@ feature -- Access: user
end
sql_forth
end
sql_finalize
end
feature -- Change: user
@@ -216,7 +224,7 @@ feature -- Change: user
l_parameters.put (create {DATE_TIME}.make_now_utc, "created")
l_parameters.put (a_user.status, "status")
sql_change (sql_insert_user, l_parameters)
sql_insert (sql_insert_user, l_parameters)
if not error_handler.has_error then
a_user.set_id (last_inserted_user_id)
update_user_roles (a_user)
@@ -226,6 +234,7 @@ feature -- Change: user
else
sql_rollback_transaction
end
sql_finalize
else
-- set error
error_handler.add_custom_error (-1, "bad request" , "Missing password or email")
@@ -265,7 +274,8 @@ feature -- Change: user
l_parameters.put (l_email, "email")
l_parameters.put (a_user.status, "status")
sql_change (sql_update_user, l_parameters)
sql_modify (sql_update_user, l_parameters)
sql_finalize
if not error_handler.has_error then
update_user_roles (a_user)
end
@@ -274,6 +284,7 @@ feature -- Change: user
else
sql_rollback_transaction
end
sql_finalize
else
-- set error
error_handler.add_custom_error (-1, "bad request" , "Missing password or email")
@@ -290,8 +301,9 @@ feature -- Change: user
write_information_log (generator + ".delete_user")
create l_parameters.make (1)
l_parameters.put (a_user.id, "uid")
sql_change (sql_delete_user, l_parameters)
sql_modify (sql_delete_user, l_parameters)
sql_commit_transaction
sql_finalize
end
update_user_roles (a_user: CMS_USER)
@@ -347,6 +359,7 @@ feature -- Change: user
else
sql_rollback_transaction
end
sql_finalize
end
assign_role_to_user (a_role: CMS_USER_ROLE; a_user: CMS_USER)
@@ -356,7 +369,8 @@ feature -- Change: user
create l_parameters.make (2)
l_parameters.put (a_user.id, "uid")
l_parameters.put (a_role.id, "rid")
sql_change (sql_insert_role_to_user, l_parameters)
sql_insert (sql_insert_role_to_user, l_parameters)
sql_finalize
end
unassign_role_from_user (a_role: CMS_USER_ROLE; a_user: CMS_USER)
@@ -366,7 +380,8 @@ feature -- Change: user
create l_parameters.make (2)
l_parameters.put (a_user.id, "uid")
l_parameters.put (a_role.id, "rid")
sql_change (sql_delete_role_from_user, l_parameters)
sql_modify (sql_delete_role_from_user, l_parameters)
sql_finalize
end
feature -- Access: roles and permissions
@@ -380,14 +395,16 @@ feature -- Access: roles and permissions
create l_parameters.make (1)
l_parameters.put (a_id, "rid")
sql_query (select_user_role_by_id, l_parameters)
if sql_rows_count = 1 then
if not sql_after then
Result := fetch_user_role
sql_forth
check one_row: sql_after end
sql_finalize
if Result /= Void and not has_error then
fill_user_role (Result)
end
else
check no_more_than_one: sql_rows_count = 0 end
end
sql_finalize
end
user_role_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_USER_ROLE
@@ -400,14 +417,16 @@ feature -- Access: roles and permissions
create l_parameters.make (1)
l_parameters.put (a_name, "name")
sql_query (select_user_role_by_name, l_parameters)
if sql_rows_count = 1 then
if not sql_after then
Result := fetch_user_role
sql_forth
check one_row: sql_after end
sql_finalize
if Result /= Void and not has_error then
fill_user_role (Result)
end
else
check no_more_than_one: sql_rows_count = 0 end
end
sql_finalize
end
user_roles_for (a_user: CMS_USER): LIST [CMS_USER_ROLE]
@@ -431,6 +450,7 @@ feature -- Access: roles and permissions
end
sql_forth
end
sql_finalize
if not has_error then
across Result as ic loop
fill_user_role (ic.item)
@@ -458,6 +478,7 @@ feature -- Access: roles and permissions
end
sql_forth
end
sql_finalize
if not has_error then
across Result as ic loop
fill_user_role (ic.item)
@@ -501,6 +522,7 @@ feature -- Access: roles and permissions
-- end
sql_forth
end
sql_finalize
end
role_permissions: LIST [READABLE_STRING_8]
@@ -522,6 +544,7 @@ feature -- Access: roles and permissions
end
sql_forth
end
sql_finalize
end
feature -- Change: roles and permissions
@@ -550,7 +573,8 @@ feature -- Change: roles and permissions
create l_parameters.make (2)
l_parameters.put (a_user_role.id, "rid")
l_parameters.put (a_user_role.name, "name")
sql_change (sql_update_user_role, l_parameters)
sql_modify (sql_update_user_role, l_parameters)
sql_finalize
end
if not a_user_role.permissions.is_empty then
-- FIXME: check if this is non set permissions,or none ...
@@ -596,7 +620,8 @@ feature -- Change: roles and permissions
else
create l_parameters.make (1)
l_parameters.put (a_user_role.name, "name")
sql_change (sql_insert_user_role, l_parameters)
sql_insert (sql_insert_user_role, l_parameters)
sql_finalize
if not error_handler.has_error then
a_user_role.set_id (last_inserted_user_role_id)
across
@@ -619,7 +644,8 @@ feature -- Change: roles and permissions
l_parameters.put (a_role_id, "rid")
l_parameters.put (a_permission, "permission")
l_parameters.put (Void, "module") -- FIXME: unsupported for now!
sql_change (sql_insert_user_role_permission, l_parameters)
sql_insert (sql_insert_user_role_permission, l_parameters)
sql_finalize
end
unset_permission_for_role_id (a_permission: READABLE_STRING_8; a_role_id: INTEGER)
@@ -633,7 +659,8 @@ feature -- Change: roles and permissions
create l_parameters.make (2)
l_parameters.put (a_role_id, "rid")
l_parameters.put (a_permission, "permission")
sql_change (sql_delete_user_role_permission, l_parameters)
sql_modify (sql_delete_user_role_permission, l_parameters)
sql_finalize
end
last_inserted_user_role_id: INTEGER_32
@@ -642,9 +669,12 @@ feature -- Change: roles and permissions
error_handler.reset
write_information_log (generator + ".last_inserted_user_role_id")
sql_query (Sql_last_insert_user_role_id, Void)
if sql_rows_count = 1 then
Result := sql_read_integer_32 (1)
if not sql_after then
Result := sql_read_integer_64 (1).to_integer_32
sql_forth
check one_row: sql_after end
end
sql_finalize
end
@@ -658,9 +688,11 @@ feature -- Change: roles and permissions
write_information_log (generator + ".delete_role")
create l_parameters.make (1)
l_parameters.put (a_role.id, "rid")
sql_change (sql_delete_role_permissions_by_role_id, l_parameters)
sql_change (sql_delete_role_by_id, l_parameters)
sql_modify (sql_delete_role_permissions_by_role_id, l_parameters)
sql_finalize
sql_modify (sql_delete_role_by_id, l_parameters)
sql_commit_transaction
sql_finalize
end
@@ -676,9 +708,12 @@ feature -- Access: User activation
create l_parameters.make (1)
l_parameters.put (a_token, "token")
sql_query (sql_select_activation_expiration, l_parameters)
if sql_rows_count = 1 then
if not sql_after then
Result := sql_read_integer_32 (1)
sql_forth
check one_row: sql_after end
end
sql_finalize
end
user_id_by_activation (a_token: READABLE_STRING_32): INTEGER_64
@@ -691,9 +726,12 @@ feature -- Access: User activation
create l_parameters.make (1)
l_parameters.put (a_token, "token")
sql_query (sql_select_userid_activation, l_parameters)
if sql_rows_count = 1 then
if not sql_after then
Result := sql_read_integer_32 (1)
sql_forth
check one_row: sql_after end
end
sql_finalize
end
feature -- Change: User activation
@@ -712,8 +750,9 @@ feature -- Change: User activation
l_parameters.put (a_token, "token")
l_parameters.put (a_id, "uid")
l_parameters.put (l_utc_date, "utc_date")
sql_change (sql_insert_activation, l_parameters)
sql_insert (sql_insert_activation, l_parameters)
sql_commit_transaction
sql_finalize
end
remove_activation (a_token: READABLE_STRING_32)
@@ -726,8 +765,9 @@ feature -- Change: User activation
write_information_log (generator + ".remove_activation")
create l_parameters.make (1)
l_parameters.put (a_token, "token")
sql_change (sql_remove_activation, l_parameters)
sql_modify (sql_remove_activation, l_parameters)
sql_commit_transaction
sql_finalize
end
feature -- Change: User password recovery
@@ -746,8 +786,9 @@ feature -- Change: User password recovery
l_parameters.put (a_token, "token")
l_parameters.put (a_id, "uid")
l_parameters.put (l_utc_date, "utc_date")
sql_change (sql_insert_password, l_parameters)
sql_insert (sql_insert_password, l_parameters)
sql_commit_transaction
sql_finalize
end
remove_password (a_token: READABLE_STRING_32)
@@ -760,8 +801,9 @@ feature -- Change: User password recovery
write_information_log (generator + ".remove_password")
create l_parameters.make (1)
l_parameters.put (a_token, "token")
sql_change (sql_remove_password, l_parameters)
sql_modify (sql_remove_password, l_parameters)
sql_commit_transaction
sql_finalize
end
feature {NONE} -- Implementation: User
@@ -776,11 +818,14 @@ feature {NONE} -- Implementation: User
create l_parameters.make (1)
l_parameters.put (a_username, "name")
sql_query (select_salt_by_username, l_parameters)
if sql_rows_count = 1 then
if not sql_after then
if attached sql_read_string (1) as l_salt then
Result := l_salt
end
sql_forth
check one_row: sql_after end
end
sql_finalize
end
fetch_user: detachable CMS_USER
@@ -826,9 +871,12 @@ feature {NONE} -- Implementation: User
error_handler.reset
write_information_log (generator + ".last_inserted_user_id")
sql_query (Sql_last_insert_user_id, Void)
if sql_rows_count = 1 then
if not sql_after then
Result := sql_read_integer_64 (1)
sql_forth
check one_row: sql_after end
end
sql_finalize
end
feature {NONE} -- Implementation: User role

Some files were not shown because too many files have changed in this diff Show More