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.
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.
composer require undefinedoffset/silverstripe-codebank 3.*@stable
composer update --no-dev undefinedoffset/silverstripe-codebank
composer update --no-dev
Code Bank uses SyntaxHighlighter to highlight code snippets, to provide a language with syntax highlighting you must add to your yml configs the following then run dev/build?flush=all.
CodeBank:
extra_languages:
- Name: "Example Language" #Name of the language
HighlightCode: "example" #Highlighter code
FileName: "ex" #File extension
Brush: "mysite/javascript/shBrushEx.js" #Relative Path to the snippet highlighter brush
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 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.
CodeBank:
snippet_search_engine: "SolrCodeBankSearchEngine"
Code Bank provides an api for you to hook in your own engine, you simply need to implement the ICodeBankSearchEngine 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.
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem