Skip to content
Browse files

check rule's availability before matching & replacing

  • Loading branch information...
1 parent 47ab8bd commit 940dc28f9e9a7b68209abfd212382d284b57dc8f @moscartong moscartong committed Feb 23, 2012
Showing with 51 additions and 108 deletions.
  1. +22 −25 RythemManagerUI/.idea/workspace.xml
  2. +16 −17 RythemTimes/.idea/workspace.xml
  3. +3 −58 configs.txt
  4. +10 −8 ryrulegroup.cpp
View
47 RythemManagerUI/.idea/workspace.xml
@@ -42,14 +42,14 @@
</provider>
</entry>
</file>
- <file leaf-file-name="rules.js" pinned="false" current="false" current-in-tab="true">
+ <file leaf-file-name="rules.js" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/js/rules.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="248" column="9" selection-start="8058" selection-end="8058" vertical-scroll-proportion="0.53509784">
+ <state line="14" column="16" selection-start="417" selection-end="417" vertical-scroll-proportion="0.3338633">
<folding>
- <marker date="1329289690000" expanded="true" signature="923:1306" placeholder="..." />
- <marker date="1329289690000" expanded="true" signature="7157:7272" placeholder="..." />
- <marker date="1329289690000" expanded="true" signature="7469:7639" placeholder="..." />
+ <marker date="1329967375000" expanded="true" signature="923:1306" placeholder="..." />
+ <marker date="1329967375000" expanded="true" signature="7415:7530" placeholder="..." />
+ <marker date="1329967375000" expanded="true" signature="7727:7897" placeholder="..." />
</folding>
</state>
</provider>
@@ -68,10 +68,10 @@
</split-first>
<split-second>
<leaf>
- <file leaf-file-name="rules.css" pinned="false" current="true" current-in-tab="true">
+ <file leaf-file-name="rules.css" pinned="false" current="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/css/rules.css">
<provider selected="true" editor-type-id="text-editor">
- <state line="177" column="0" selection-start="2835" selection-end="2835" vertical-scroll-proportion="0.58573073">
+ <state line="177" column="0" selection-start="2835" selection-end="2835" vertical-scroll-proportion="0.42766297">
<folding />
</state>
</provider>
@@ -102,10 +102,9 @@
</option>
</component>
<component name="ProjectFrameBounds">
- <option name="x" value="306" />
<option name="y" value="22" />
- <option name="width" value="1473" />
- <option name="height" value="1004" />
+ <option name="width" value="1280" />
+ <option name="height" value="735" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
@@ -140,8 +139,8 @@
<property name="options.lastSelected" value="editor.preferences.tabs" />
<property name="FullScreen" value="false" />
<property name="DefaultHtmlFileTemplate" value="Html5" />
- <property name="options.splitter.details.proportions" value="0.2" />
<property name="options.searchVisible" value="true" />
+ <property name="options.splitter.details.proportions" value="0.2" />
</component>
<component name="RunManager">
<configuration default="true" type="JavascriptDebugSession" factoryName="Local">
@@ -181,7 +180,7 @@
<servers />
</component>
<component name="ToolWindowManager">
- <frame x="306" y="22" width="1473" height="1004" extended-state="0" />
+ <frame x="0" y="22" width="1280" height="735" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
@@ -257,31 +256,29 @@
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/rules.html">
<provider selected="true" editor-type-id="text-editor">
- <state line="19" column="16" selection-start="477" selection-end="477" vertical-scroll-proportion="0.0">
- <folding />
- </state>
+ <state line="19" column="16" selection-start="477" selection-end="477" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/jo2/jo2.dom.js">
<provider selected="true" editor-type-id="text-editor">
<state line="371" column="36" selection-start="13136" selection-end="13136" vertical-scroll-proportion="0.0" />
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/js/rules.js">
+ <entry file="file://$PROJECT_DIR$/css/rules.css">
<provider selected="true" editor-type-id="text-editor">
- <state line="248" column="9" selection-start="8058" selection-end="8058" vertical-scroll-proportion="0.53509784">
- <folding>
- <marker date="1329289690000" expanded="true" signature="923:1306" placeholder="..." />
- <marker date="1329289690000" expanded="true" signature="7157:7272" placeholder="..." />
- <marker date="1329289690000" expanded="true" signature="7469:7639" placeholder="..." />
- </folding>
+ <state line="130" column="1" selection-start="2057" selection-end="2057" vertical-scroll-proportion="0.0">
+ <folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/css/rules.css">
+ <entry file="file://$PROJECT_DIR$/js/rules.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="177" column="0" selection-start="2835" selection-end="2835" vertical-scroll-proportion="0.58573073">
- <folding />
+ <state line="14" column="16" selection-start="417" selection-end="417" vertical-scroll-proportion="0.3338633">
+ <folding>
+ <marker date="1329967375000" expanded="true" signature="923:1306" placeholder="..." />
+ <marker date="1329967375000" expanded="true" signature="7415:7530" placeholder="..." />
+ <marker date="1329967375000" expanded="true" signature="7727:7897" placeholder="..." />
+ </folding>
</state>
</provider>
</entry>
View
33 RythemTimes/.idea/workspace.xml
@@ -25,7 +25,7 @@
<file leaf-file-name="index.html" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/index.html">
<provider selected="true" editor-type-id="text-editor">
- <state line="26" column="34" selection-start="713" selection-end="713" vertical-scroll-proportion="-14.25">
+ <state line="26" column="34" selection-start="713" selection-end="713" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -34,10 +34,11 @@
<file leaf-file-name="times.js" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/js/times.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="396" column="61" selection-start="10962" selection-end="10962" vertical-scroll-proportion="0.35612082">
+ <state line="396" column="61" selection-start="10962" selection-end="10962" vertical-scroll-proportion="0.13551402">
<folding>
<marker date="1329899356000" expanded="true" signature="7125:7189" placeholder="..." />
<marker date="1329899356000" expanded="true" signature="7125:7151" placeholder="..." />
+ <marker date="1329899356000" expanded="true" signature="7125:7151" placeholder="..." />
<marker date="1329899356000" expanded="true" signature="7627:7652" placeholder="..." />
<marker date="1329899356000" expanded="true" signature="7627:7683" placeholder="..." />
<marker date="1329899356000" expanded="true" signature="7627:7716" placeholder="..." />
@@ -111,7 +112,6 @@
<sortByType />
</navigator>
<panes>
- <pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<PATH>
@@ -126,10 +126,12 @@
</PATH>
</subPane>
</pane>
+ <pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
+ <property name="FullScreen" value="false" />
<property name="DefaultHtmlFileTemplate" value="Html5" />
</component>
<component name="RunManager">
@@ -171,12 +173,12 @@
</component>
<component name="ToolWindowManager">
<frame x="0" y="22" width="1280" height="735" extended-state="0" />
- <editor active="true" />
+ <editor active="false" />
<layout>
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
- <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24980111" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
+ <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24980111" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
@@ -251,31 +253,23 @@
</entry>
<entry file="file://$PROJECT_DIR$/lib/jo2.dom.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="62" column="22" selection-start="1963" selection-end="1963" vertical-scroll-proportion="0.3323782">
- <folding />
- </state>
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/css/times.css">
- <provider selected="true" editor-type-id="text-editor">
- <state line="94" column="11" selection-start="1282" selection-end="1282" vertical-scroll-proportion="0.0">
- <folding />
- </state>
+ <state line="62" column="22" selection-start="1963" selection-end="1963" vertical-scroll-proportion="0.3323782" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.html">
<provider selected="true" editor-type-id="text-editor">
- <state line="26" column="34" selection-start="713" selection-end="713" vertical-scroll-proportion="-14.25">
+ <state line="26" column="34" selection-start="713" selection-end="713" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/times.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="396" column="61" selection-start="10962" selection-end="10962" vertical-scroll-proportion="0.35612082">
+ <state line="396" column="61" selection-start="10962" selection-end="10962" vertical-scroll-proportion="0.13551402">
<folding>
<marker date="1329899356000" expanded="true" signature="7125:7189" placeholder="..." />
<marker date="1329899356000" expanded="true" signature="7125:7151" placeholder="..." />
+ <marker date="1329899356000" expanded="true" signature="7125:7151" placeholder="..." />
<marker date="1329899356000" expanded="true" signature="7627:7652" placeholder="..." />
<marker date="1329899356000" expanded="true" signature="7627:7683" placeholder="..." />
<marker date="1329899356000" expanded="true" signature="7627:7716" placeholder="..." />
@@ -286,6 +280,11 @@
</state>
</provider>
</entry>
+ <entry file="file://$PROJECT_DIR$/css/times.css">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="94" column="11" selection-start="1282" selection-end="1282" vertical-scroll-proportion="0.0" />
+ </provider>
+ </entry>
</component>
</project>
View
61 configs.txt
@@ -1,70 +1,15 @@
{"groups":[
{
- "name":"group1",
+ "name":"test",
"enable":1,
"rules":[
{
- "name":"local file example",
- "type":6,
- "enable":1,
- "rule":{"pattern":"http://abc.com/b.html",
- "replace":"/Users/emrelax/qt-projects/Rythem-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK____/Rythem.app/Contents/Resources/"}
- },
- {
- "name":"local files example",
- "type":5,
- "enable":1,
- "rule":{"pattern":"http://abc.com/c.html",
- "replace":"C:/a.html.qzmin"}
- },
- {
- "name":"local directory example",
- "type":6,
- "enable":1,
- "rule":{"pattern":"http://abc.com/mydir/",
- "replace":"C:/replacement/"}
- },
- {
- "name":"",
- "type":5,
- "enable":1,
- "rule":{"pattern":"oh yeah",
- "replace":"wa"}
- },
- {
- "name":"",
- "type":4,
- "enable":1,
- "rule":{"pattern":"wa",
- "replace":"wa"}
- },
- {
"name":"",
"type":4,
"enable":1,
- "rule":{"pattern":"hey",
- "replace":"hey"}
+ "rule":{"pattern":"http://im.qq.com",
+ "replace":"/User /tongoscar/Dropbox/project&nbsp;/Rythem/Rythem/RythemManagerUI/j&nbsp;/rule&nbsp;.j"}
}
]
- },
- {
- "name":"wa",
- "enable":1,
- "rules":[
- {
- "name":"",
- "type":4,
- "enable":1,
- "rule":{"pattern":"hey",
- "replace":"123"}
- }
- ]
- },
- {
- "name":"wwa",
- "enable":0,
- "rules":[
-
- ]
}
]}
View
18 ryrulegroup.cpp
@@ -122,14 +122,16 @@ void QiRuleGroup2::removeRuleAt(const int index){
//判斷一下返回結果的isNull()
void QiRuleGroup2::match(QList<RyRule *> *result, const QString &url) const{
- int i, length = _rules.length();
- for(i=0; i<length; i++){
- RyRule *rule = _rules.at(i);
- //qDebug()<<rule->toJSON();
- if(rule->match(url)){
- result->append(rule);
- }
- }
+ if(this->isEnable()){
+ int i, length = _rules.length();
+ for(i=0; i<length; i++){
+ RyRule *rule = _rules.at(i);
+ //qDebug()<<rule->toJSON();
+ if(rule->isEnable() && rule->match(url)){
+ result->append(rule);
+ }
+ }
+ }
}
QString QiRuleGroup2::toJSON(int tabCount, bool withName) const{

0 comments on commit 940dc28

Please sign in to comment.
Something went wrong with that request. Please try again.