-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from codeeshop-oc/update
initial add
- Loading branch information
Showing
29 changed files
with
30,455 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
.thumbs.db | ||
node_modules | ||
*.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,75 @@ | ||
# oc-ces_ocmod | ||
## ocmod module | ||
|
||
> **Auto Refresh Modification (Install)** | ||
Upon installing an extension containing an ocmod.xml file, the modification cache is automatically refreshed. | ||
|
||
> **Auto Refresh Modification (Uninstall)** | ||
Upon uninstalling an extension containing an ocmod.xml file, the modification cache is automatically refreshed. | ||
|
||
> **Modification** | ||
Modification generated files will be available in path | ||
``` | ||
____ROOT_PATH____/system/storage/ocmod/modification/ | ||
``` | ||
|
||
> **Ocmod Install Files for Developers** | ||
``` | ||
____ROOT_PATH____/extension/____MODULE_NAME____/system/install.ocmod.xml | ||
``` | ||
|
||
You can add multiple ocmod files (with a .ocmod.xml extension) to modify your OpenCart store. | ||
Ocmod files will be searched for in the following directory structure: ```extension folder > module name > system folder > *.ocmod.xml``` | ||
|
||
## Installation | ||
|
||
1. Open `Upload` folder | ||
2. Zip all the files | ||
3. Name the zip file as `ces_ocmod.ocmod.zip` | ||
4. Upload the Zip file in your opencart store | ||
`Extensions > Installer` | ||
5. Install `Ces OCMOD` | ||
6. Open `Extensions > Extensions > Modules` | ||
Install `Ces OCMOD` | ||
7. Configure the module status or other settings as per needed | ||
|
||
![image](https://github.com/user-attachments/assets/e05849cb-9304-483f-a157-532a4fb148b4) | ||
![image](https://github.com/user-attachments/assets/9cf3fcdd-f765-48f0-8e2b-3a00bad7c201) | ||
![image](https://github.com/user-attachments/assets/200c93ea-feab-4ad1-8e56-33aa6e390e58) | ||
|
||
|
||
## Upload modules ocmod files | ||
> For admin | ||
1. Create a `index.xml` file | ||
2. Zip `index.xml` and name it as `upload.ocmod.xml` | ||
3. Upload Zip File in `Ces OCMOD > Installer` | ||
4. Refresh Modifications in `Ces OCMOD > Modifications` | ||
|
||
> For developers | ||
> | ||
``` | ||
/opt/lampp/htdocs/oc/4023/extension/____MODULE_NAME____/system/install.ocmod.xml | ||
``` | ||
You can add multiple ocmod files (with a `.ocmod.xml` extension) to modify your OpenCart store. | ||
Ocmod files will be searched for in the following directory structure: `extension folder > module name > system folder > *.ocmod.xml` | ||
|
||
## Bundle | ||
|
||
```sh | ||
cd bundle | ||
``` | ||
|
||
```sh | ||
npm install | ||
``` | ||
|
||
```sh | ||
rollup -c | ||
``` | ||
|
||
Replace Bundle generated <code>editor.bundle.js</code> file with [old file](./4.x.x.x/admin/view/javascript/) | ||
|
||
Extension is free for use. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
import { basicSetup, EditorView } from "codemirror"; | ||
import { keymap } from "@codemirror/view"; | ||
import { autocompletion } from "@codemirror/autocomplete"; | ||
import { xml } from "@codemirror/lang-xml"; | ||
import { tags } from "@lezer/highlight"; | ||
|
||
import { syntaxHighlighting, HighlightStyle } from "@codemirror/language"; | ||
import { | ||
standardKeymap, | ||
defaultKeymap, | ||
indentWithTab, | ||
} from "@codemirror/commands"; | ||
|
||
const myHighlightStyle = HighlightStyle.define([ | ||
{ tag: tags.keyword, color: "#fc6" }, | ||
{ tag: tags.comment, color: "#f5d", fontStyle: "italic" }, | ||
]); | ||
|
||
// Our list of completions (can be static, since the editor | ||
/// will do filtering based on context). | ||
const completions = [ | ||
{ label: 'property="', type: "constant" }, | ||
{ label: 'offset="', type: "constant" }, | ||
{ label: 'position="after"', type: "constant" }, | ||
{ label: 'position="before"', type: "constant" }, | ||
{ label: 'offset="1"', type: "constant" }, | ||
{ label: 'path="', type: "constant" }, | ||
{ label: 'modification="', type: "constant" }, | ||
{ label: 'name="', type: "constant" }, | ||
{ label: 'code="', type: "constant" }, | ||
{ label: 'version="', type: "constant" }, | ||
{ label: 'link="', type: "constant" }, | ||
{ label: 'author="', type: "constant" }, | ||
{ label: 'operation="', type: "constant" }, | ||
{ label: 'search="', type: "constant" }, | ||
{ label: 'regex="', type: "constant" }, | ||
{ label: 'add="', type: "constant" }, | ||
{ label: 'error="', type: "constant" }, | ||
{ label: 'error="skip"', type: "constant" }, | ||
{ label: "skip", type: "constant" }, | ||
{ label: "system/", type: "constant" }, | ||
{ label: "admin/view/template/", type: "constant" }, | ||
{ label: "system/library", type: "constant" }, | ||
{ label: "catalog/controller/", type: "constant" }, | ||
{ label: "catalog/model/", type: "constant" }, | ||
{ label: "catalog/language/", type: "constant" }, | ||
{ label: "catalog/view/template/", type: "constant" }, | ||
{ label: '<xml version="1.0" encoding="utf-8"?>', type: "constant" }, | ||
{ | ||
label: | ||
'\t<file path="">\n\t\t<operation>\n\t\t\t<search>\n\t\t\t\t<![CDATA[]]>\n\t\t\t</search>\n\t\t\t<add position="after">\n\t\t\t\t<![CDATA[]]>\n\t\t\t</add>\n\t\t</operation>\n\t</file>', | ||
type: "constant", | ||
info: "after", | ||
}, | ||
{ | ||
label: | ||
'\t<file path="">\n\t\t<operation>\n\t\t\t<search>\n\t\t\t\t<![CDATA[]]>\n\t\t\t</search>\n\t\t\t<add position="before">\n\t\t\t\t<![CDATA[]]>\n\t\t\t</add>\n\t\t</operation>\n\t</file>', | ||
type: "constant", | ||
info: "before", | ||
}, | ||
{ | ||
label: | ||
'\t<file path="">\n\t\t<operation>\n\t\t\t<search>\n\t\t\t\t<![CDATA[]]>\n\t\t\t</search>\n\t\t\t<add position="replace">\n\t\t\t\t<![CDATA[]]>\n\t\t\t</add>\n\t\t</operation>\n\t</file>', | ||
type: "constant", | ||
info: "replace", | ||
}, | ||
{ | ||
label: | ||
'<?xml version="1.0" encoding="utf-8"?>\n<modification>\n\t<name>default</name>\n\t<code>default</code>\n\t<version>1.0.0</version>\n\t<author>CodeEshop</author>\n\t<link>https://codeeshop.com</link>\n\t<file path="">\n\t\t<operation>\n\t\t\t<search>\n\t\t\t\t<![CDATA[]]>\n\t\t\t</search>\n\t\t\t<add position="after">\n\t\t\t\t<![CDATA[]]>\n\t\t\t</add>\n\t\t</operation>\n\t</file>\n</modification>', | ||
type: "constant", | ||
info: "replace", | ||
}, | ||
]; | ||
|
||
let myTheme = EditorView.theme( | ||
{ | ||
"&": { | ||
color: "white", | ||
backgroundColor: "#034", | ||
}, | ||
".cm-content": { | ||
caretColor: "#0e9", | ||
}, | ||
"&.cm-focused .cm-cursor": { | ||
borderLeftColor: "#0e9", | ||
}, | ||
"&.cm-focused .cm-selectionBackground, ::selection": { | ||
backgroundColor: "#074", | ||
}, | ||
".cm-gutters": { | ||
backgroundColor: "#045", | ||
color: "#ddd", | ||
border: "none", | ||
}, | ||
".cm-content, .cm-gutter": { minHeight: "200px" }, | ||
}, | ||
{ dark: true } | ||
); | ||
|
||
function myCompletions(context) { | ||
let before = context.matchBefore(/(<)?(\w+)/); | ||
// If completion wasn't explicitly started and there | ||
// is no word before the cursor, don't open completions. | ||
if (!context.explicit && !before) return null; | ||
return { | ||
from: before ? before.from : context.pos, | ||
options: completions, | ||
validFor: /^\w*$/, | ||
}; | ||
} | ||
|
||
function CodeMirrorWrapper(elementId, args) { | ||
const { updateElementId, initXmlValue, indent_size } = args; | ||
|
||
let view = new EditorView({ | ||
doc: initXmlValue | ||
? initXmlValue | ||
: "// Modification File https://codemirror.net/ \n", | ||
extensions: [ | ||
myTheme, | ||
basicSetup, | ||
xml(), | ||
syntaxHighlighting(myHighlightStyle), | ||
autocompletion({ override: [myCompletions] }), | ||
keymap.of([defaultKeymap, standardKeymap, indentWithTab]), | ||
EditorView.updateListener.of((v) => { | ||
if (v.docChanged && updateElementId) { | ||
setUpdateElement(); | ||
} | ||
}), | ||
], | ||
parent: document.querySelector(elementId), | ||
}); | ||
|
||
function setUpdateElement() { | ||
document.querySelector(updateElementId).innerHTML = | ||
view.state.doc.toString(); | ||
} | ||
|
||
setUpdateElement(); | ||
|
||
// Function to return the current editor value | ||
function getValue() { | ||
return view.state.doc.toString(); | ||
} | ||
|
||
// Function to return the current editor view | ||
function getView() { | ||
return view; | ||
} | ||
|
||
// Function to return the current editor view | ||
function setValue(xmlValue) { | ||
view.dispatch({ | ||
selection: { from: 0, to: view.state.doc.length }, | ||
changes: { from: 0, to: view.state.doc.length, insert: xmlValue }, | ||
}); | ||
} | ||
|
||
// Function to destroy the CodeMirror instance | ||
function destroy() { | ||
view.destroy(); | ||
} | ||
|
||
// Return an object with getValue and destroy methods | ||
return { | ||
setValue, | ||
getValue, | ||
getView, | ||
destroy, | ||
}; | ||
} | ||
|
||
window.CodeMirror = CodeMirrorWrapper; |
Oops, something went wrong.