Skip to content

Commit

Permalink
Closes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
ram-g-athreya committed Nov 10, 2017
1 parent 1c8a24f commit 1451fc1
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 18 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ For more information about this project and **GSoC Progress** please refer to **
## Environment Configurations
When running locally or in development include the following configuration as a properties file in the `src/main/resources` folder.

In case you don't have a proper CouchDB instance or API keys please use the following **[dummy configuration file](https://github.com/dbpedia/chatbot/wiki/Chatbot-Dummy-Configuration)**.
In case you do not have a proper CouchDB instance or API keys please use the following **[dummy configuration file](https://github.com/dbpedia/chatbot/wiki/Chatbot-Dummy-Configuration)**.

*Please note that using the dummy configuration file can result in some features being unavailable since they may require the requisite API services.*

admin.username = <admin-username>
admin.password = <admin-password>
chatbot.baseUrl = <https-url-to-access-the-bot>
chatbot.gaID = <google-analytics-id>
chatbot.fb.appSecret = <secret>
chatbot.fb.verifyToken = <token>
Expand Down Expand Up @@ -46,7 +47,7 @@ In case you don't have a proper CouchDB instance or API keys please use the foll

## Development
mvn spring-boot:run
node/node node_modules/.bin/webpack --watch
node/node node_modules/.bin/webpack --env.NODE_ENV=dev --watch

## Embed Code
Add the following snippet to the `<head>` section of the webpage where you want to embed the ChatBot.
Expand Down
2 changes: 1 addition & 1 deletion app/src/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import React from 'react';
import ReactDOM from 'react-dom';
import Admin from './components/admin/Admin.jsx';

ReactDOM.render('<Admin />', document.getElementById('admin-container'));
ReactDOM.render(<Admin />, document.getElementById('admin-container'));
2 changes: 1 addition & 1 deletion app/src/js/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import React from 'react';
import ReactDOM from 'react-dom';
import Embed from './components/embed/Embed.jsx';

ReactDOM.render('<Embed />', document.getElementById('embed-container'));
ReactDOM.render(<Embed />, document.getElementById('embed-container'));
2 changes: 1 addition & 1 deletion app/src/js/feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import React from 'react';
import ReactDOM from 'react-dom';
import Feedback from './components/chat/Feedback.jsx';

ReactDOM.render('<Feedback isOpen={true} />', document.getElementById('feedback-container'));
ReactDOM.render(<Feedback isOpen={true} />, document.getElementById('feedback-container'));
2 changes: 1 addition & 1 deletion app/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import React from 'react';
import ReactDOM from 'react-dom';
import ChatApp from './components/chat/ChatApp.jsx';

ReactDOM.render('<ChatApp />', document.getElementById('chat-container'));
ReactDOM.render(<ChatApp />, document.getElementById('chat-container'));
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/main/java/chatbot/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
@Configuration
@EnableWebSecurity
static class WebSecurityConfig extends WebSecurityConfigurerAdapter {

protected static String baseUrl;

@Override
protected void configure(HttpSecurity http) throws Exception {
http
Expand All @@ -85,7 +88,8 @@ protected void configure(HttpSecurity http) throws Exception {
}

@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth, @Value("${admin.username}") String username, @Value("${admin.password}") String password) throws Exception {
protected void configureGlobal(AuthenticationManagerBuilder auth, @Value("${admin.username}") String username, @Value("${admin.password}") String password, @Value("${chatbot.baseUrl}") String baseUrl) throws Exception {
this.baseUrl = baseUrl;
auth
.inMemoryAuthentication()
.withUser(username).password(password).roles("ADMIN");
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/chatbot/DemoConfiguration.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package chatbot.platforms.web.controllers;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

Expand All @@ -10,8 +14,12 @@
*/
@Controller
public class IndexController {
private static final Logger logger = LoggerFactory.getLogger(IndexController.class);

@RequestMapping(method=GET, path="/")
public String actionIndex() {
return "index";
public ModelAndView actionIndex(@Value("${chatbot.gaID}") String gaID) {
ModelAndView model = new ModelAndView("index");
model.addObject("gaID", gaID);
return model;
}
}
11 changes: 11 additions & 0 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@
<script type="text/javascript" src="assets/bootstrap-material-design/dist/js/ripples.min.js"></script>
<script type="text/javascript" src="assets/bootstrap-material-design/dist/js/material.min.js"></script>
<script type="text/javascript" src="assets/snackbarjs/dist/snackbar.min.js"></script>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script type="text/javascript" async="true" src="https://www.googletagmanager.com/gtag/js?id=UA-109517818-2"></script>
<script th:inline="javascript">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

gtag('js', new Date());
gtag('config', /*[[${gaID}]]*/);
</script>

</head>
<body>
<div class="container full-height" style="padding: 20px 5px;">
Expand Down

0 comments on commit 1451fc1

Please sign in to comment.