|
1 | | -Code Bank (Server) |
2 | | -================= |
3 | | -[](https://packagist.org/packages/undefinedoffset/silverstripe-codebank) [](https://packagist.org/packages/undefinedoffset/silverstripe-codebank) [](https://packagist.org/packages/undefinedoffset/silverstripe-codebank) [](https://packagist.org/packages/undefinedoffset/silverstripe-codebank) [](https://travis-ci.org/UndefinedOffset/silverstripe-codebank) |
4 | | - |
5 | | -Code Bank is a code snippet manager with syntax highlighting for multiple languages including C++, ActionScript, Flex, HTML and SQL to name a few. Code Bank also has a simple revision history with a compare viewer so you can see the changes side-by-side between two revisions. |
6 | | - |
7 | | - |
8 | | -###Requirements: |
9 | | -* SilverStripe Framework 3.1.x (See http://www.silverstripe.org/system-requirements/ for SilverStripe requirements) |
10 | | -* PHP Zip extension (See http://ca1.php.net/manual/en/book.zip.php for installation instructions) |
11 | | - |
12 | | - |
13 | | -###Installation (Module) |
14 | | -``` |
15 | | -composer require undefinedoffset/silverstripe-codebank |
16 | | -``` |
17 | | - |
18 | | -####Manual Install (Module only) |
19 | | -1. Download and extract the latest Code Bank module release from here http://programs.edchipman.ca/applications/code-bank/ |
20 | | -2. Extract the module archive to the root of your SilverStripe installation, opening the extracted folder should contain _config.php in the root along with other files/folders |
21 | | -3. Hit http://{your domain}/{path to root of code bank server folder}/dev/build?flush=all in your browser |
22 | | -4. You will now see a Code Bank option in the CMS Menu |
23 | | - |
24 | | - |
25 | | -###Installation (Standalone) |
26 | | -1. Download and extract the latest Code Bank release from here http://programs.edchipman.ca/applications/code-bank/ |
27 | | -2. Extract the Code Bank to a location on your SilverStripe compatible web server, you should now see a Code Bank folder and a framework folder among others |
28 | | -3. Follow the installation instructions at http://doc.silverstripe.org/framework/en/installation/ |
29 | | -4. If the installer completes successfully you will now be able to use the remote server in Code Bank's desktop client. Just set the server path to be http://{your domain}/{path to root of code bank server folder} |
30 | | -5. You should make sure that the SilverStripe installer removed the install files install.php, and install-frameworkmissing.html |
31 | | - |
32 | | - |
33 | | -###Upgrading to new versions: |
34 | | -####Module Only (with composer, recommended): |
35 | | -``` |
36 | | -composer update --no-dev undefinedoffset/silverstripe-codebank |
37 | | -``` |
38 | | - |
39 | | -#####Module Only (without composer) |
40 | | -1. Download the latest Code Bank release here http://programs.edchipman.ca/applications/code-bank/ |
41 | | -2. Extract the archive to into the same folder as your SilverStripe Framework |
42 | | -3. Hit http://{your domain}/{path to root of code bank server folder}/dev/build?flush=all in your browser |
43 | | - |
44 | | - |
45 | | -####Stand Alone (with composer, recommended) |
46 | | -``` |
47 | | -composer update --no-dev |
48 | | -``` |
49 | | - |
50 | | -#####Stand Alone (without composer) |
51 | | -1. Download and extract the latest Code Bank release from http://programs.edchipman.ca/applications/code-bank/ overwriting the Code Bank and themes folders |
52 | | -2. Download and extact just the CodeBank, framework and themes folders replacing only those folders and their children |
53 | | -3. Hit http://{your domain}/{path to root of code bank server folder}/dev/build?flush=all in your browser, then you may use Code Bank normally |
54 | | - |
55 | | - |
56 | | -###Custom Languages with Brushes |
57 | | -Code Bank uses [SyntaxHighlighter](https://github.com/alexgorbatchev/SyntaxHighlighter) to highlight code snippets, to provide a language with syntax highlighting you must add to your [yml configs](http://doc.silverstripe.org/framework/en/topics/configuration#setting-configuration-via-yaml-files) the following then run dev/build?flush=all. |
58 | | -```yml |
59 | | -CodeBank: |
60 | | - extra_languages: |
61 | | - - Name: "Example Language" #Name of the language |
62 | | - HighlightCode: "example" #Highlighter code |
63 | | - FileName: "ex" #File extension |
64 | | - Brush: "mysite/javascript/shBrushEx.js" #Relative Path to the snippet highlighter brush |
65 | | -``` |
66 | | -
|
67 | | -
|
68 | | -###Switching the search engine |
69 | | -By default Code Bank uses MySQL's fulltext searching and on databases like Postgres it uses a partial match filtering for searching both from the client and in the web interface. Code Bank provides support for switching the engine to Solr if you have the [silverstripe/fulltextsearch](https://github.com/silverstripe-labs/silverstripe-fulltextsearch) installed and a Solr server available. You may switch the search engine by adding the following to your mysite/_config/config.yml after add flush=1 to the url to update the config cache. |
70 | | -```yml |
71 | | -CodeBank: |
72 | | - snippet_search_engine: "SolrCodeBankSearchEngine" |
73 | | -``` |
74 | | -
|
75 | | -####Writing your own engine |
76 | | -Code Bank provides an api for you to hook in your own engine, you simply need to implement the [ICodeBankSearchEngine](https://github.com/UndefinedOffset/silverstripe-codebank/blob/master/code/search/ICodeBankSearchEngine.php) interface and define the methods in the interface. The key thing to remember is that the doSnippetSearch() method takes 3 parameters the first $keyword, is the term/keyword the user is searching for (this maybe empty), the second ($langugeID) is the database ID of the language the user is filtering to. The last parameter ($folderID) is the ID of the folder the system is requesting matches for. The method itself should always return a SS_List subclass typically it should be DataList containing or pointing to only snippets. To enable your custom engine follow the [steps above](#switching-the-search-engine). |
77 | | -
|
78 | | -
|
79 | | -###Attribution: |
80 | | -* Some Icons are from the Fudge Icon Set http://p.yusukekamiyamane.com/ |
81 | | -* Code Bank Logo is derived from the Tango Desktop Project http://tango.freedesktop.org |
82 | | -* Other icons are from the noun project http://thenounproject.com/ |
83 | | -* Code Bank is powered by the SilverStripe framework http://www.silverstripe.org |
84 | | -* Code Bank uses portions of the Zend Framework http://framework.zend.com/ |
85 | | -* Syntax highlighting provided by SyntaxHighlighter https://github.com/alexgorbatchev/SyntaxHighlighter |
| 1 | +Code Bank (Server) |
| 2 | +================= |
| 3 | +[](https://packagist.org/packages/undefinedoffset/silverstripe-codebank) [](https://packagist.org/packages/undefinedoffset/silverstripe-codebank) [](https://packagist.org/packages/undefinedoffset/silverstripe-codebank) [](https://packagist.org/packages/undefinedoffset/silverstripe-codebank) [](https://travis-ci.org/UndefinedOffset/silverstripe-codebank) |
| 4 | + |
| 5 | +Code Bank is a code snippet manager with syntax highlighting for multiple languages including C++, ActionScript, Flex, HTML and SQL to name a few. Code Bank also has a simple revision history with a compare viewer so you can see the changes side-by-side between two revisions. |
| 6 | + |
| 7 | + |
| 8 | +###Requirements: |
| 9 | +* SilverStripe Framework 3.1.x (See http://www.silverstripe.org/system-requirements/ for SilverStripe requirements) |
| 10 | +* PHP Zip extension (See http://ca1.php.net/manual/en/book.zip.php for installation instructions) |
| 11 | + |
| 12 | + |
| 13 | +###Installation (Module) |
| 14 | +``` |
| 15 | +composer require undefinedoffset/silverstripe-codebank 3.*@stable |
| 16 | +``` |
| 17 | + |
| 18 | +####Manual Install (Module only) |
| 19 | +1. Download and extract the latest Code Bank module release from here http://programs.edchipman.ca/applications/code-bank/ |
| 20 | +2. Extract the module archive to the root of your SilverStripe installation, opening the extracted folder should contain _config.php in the root along with other files/folders |
| 21 | +3. Hit http://{your domain}/{path to root of code bank server folder}/dev/build?flush=all in your browser |
| 22 | +4. You will now see a Code Bank option in the CMS Menu |
| 23 | + |
| 24 | + |
| 25 | +###Installation (Standalone) |
| 26 | +1. Download and extract the latest Code Bank release from here http://programs.edchipman.ca/applications/code-bank/ |
| 27 | +2. Extract the Code Bank to a location on your SilverStripe compatible web server, you should now see a Code Bank folder and a framework folder among others |
| 28 | +3. Follow the installation instructions at http://doc.silverstripe.org/framework/en/installation/ |
| 29 | +4. If the installer completes successfully you will now be able to use the remote server in Code Bank's desktop client. Just set the server path to be http://{your domain}/{path to root of code bank server folder} |
| 30 | +5. You should make sure that the SilverStripe installer removed the install files install.php, and install-frameworkmissing.html |
| 31 | + |
| 32 | + |
| 33 | +###Upgrading to new versions: |
| 34 | +####Module Only (with composer, recommended): |
| 35 | +``` |
| 36 | +composer update --no-dev undefinedoffset/silverstripe-codebank |
| 37 | +``` |
| 38 | + |
| 39 | +#####Module Only (without composer) |
| 40 | +1. Download the latest Code Bank release here http://programs.edchipman.ca/applications/code-bank/ |
| 41 | +2. Extract the archive to into the same folder as your SilverStripe Framework |
| 42 | +3. Hit http://{your domain}/{path to root of code bank server folder}/dev/build?flush=all in your browser |
| 43 | + |
| 44 | + |
| 45 | +####Stand Alone (with composer, recommended) |
| 46 | +``` |
| 47 | +composer update --no-dev |
| 48 | +``` |
| 49 | + |
| 50 | +#####Stand Alone (without composer) |
| 51 | +1. Download and extract the latest Code Bank release from http://programs.edchipman.ca/applications/code-bank/ overwriting the Code Bank and themes folders |
| 52 | +2. Download and extact just the CodeBank, framework and themes folders replacing only those folders and their children |
| 53 | +3. Hit http://{your domain}/{path to root of code bank server folder}/dev/build?flush=all in your browser, then you may use Code Bank normally |
| 54 | + |
| 55 | + |
| 56 | +###Custom Languages with Brushes |
| 57 | +Code Bank uses [SyntaxHighlighter](https://github.com/alexgorbatchev/SyntaxHighlighter) to highlight code snippets, to provide a language with syntax highlighting you must add to your [yml configs](http://doc.silverstripe.org/framework/en/topics/configuration#setting-configuration-via-yaml-files) the following then run dev/build?flush=all. |
| 58 | +```yml |
| 59 | +CodeBank: |
| 60 | + extra_languages: |
| 61 | + - Name: "Example Language" #Name of the language |
| 62 | + HighlightCode: "example" #Highlighter code |
| 63 | + FileName: "ex" #File extension |
| 64 | + Brush: "mysite/javascript/shBrushEx.js" #Relative Path to the snippet highlighter brush |
| 65 | +``` |
| 66 | +
|
| 67 | +
|
| 68 | +###Switching the search engine |
| 69 | +By default Code Bank uses MySQL's fulltext searching and on databases like Postgres it uses a partial match filtering for searching both from the client and in the web interface. Code Bank provides support for switching the engine to Solr if you have the [silverstripe/fulltextsearch](https://github.com/silverstripe-labs/silverstripe-fulltextsearch) installed and a Solr server available. You may switch the search engine by adding the following to your mysite/_config/config.yml after add flush=1 to the url to update the config cache. |
| 70 | +```yml |
| 71 | +CodeBank: |
| 72 | + snippet_search_engine: "SolrCodeBankSearchEngine" |
| 73 | +``` |
| 74 | +
|
| 75 | +####Writing your own engine |
| 76 | +Code Bank provides an api for you to hook in your own engine, you simply need to implement the [ICodeBankSearchEngine](https://github.com/UndefinedOffset/silverstripe-codebank/blob/master/code/search/ICodeBankSearchEngine.php) interface and define the methods in the interface. The key thing to remember is that the doSnippetSearch() method takes 3 parameters the first $keyword, is the term/keyword the user is searching for (this maybe empty), the second ($langugeID) is the database ID of the language the user is filtering to. The last parameter ($folderID) is the ID of the folder the system is requesting matches for. The method itself should always return a SS_List subclass typically it should be DataList containing or pointing to only snippets. To enable your custom engine follow the [steps above](#switching-the-search-engine). |
| 77 | +
|
| 78 | +
|
| 79 | +###Attribution: |
| 80 | +* Some Icons are from the Fudge Icon Set http://p.yusukekamiyamane.com/ |
| 81 | +* Code Bank Logo is derived from the Tango Desktop Project http://tango.freedesktop.org |
| 82 | +* Other icons are from the noun project http://thenounproject.com/ |
| 83 | +* Code Bank is powered by the SilverStripe framework http://www.silverstripe.org |
| 84 | +* Code Bank uses portions of the Zend Framework http://framework.zend.com/ |
| 85 | +* Syntax highlighting provided by SyntaxHighlighter https://github.com/alexgorbatchev/SyntaxHighlighter |
0 commit comments