|
1 | 1 | <template>
|
2 |
| - <div class="hello"> |
3 |
| - <h1>{{ msg }}</h1> |
4 |
| - <h2>Essential Links</h2> |
5 |
| - <ul> |
6 |
| - <li><a href="https://vuejs.org" target="_blank">Core Docs</a></li> |
7 |
| - <li><a href="https://forum.vuejs.org" target="_blank">Forum</a></li> |
8 |
| - <li><a href="https://chat.vuejs.org" target="_blank">Community Chat</a></li> |
9 |
| - <li><a href="https://twitter.com/vuejs" target="_blank">Twitter</a></li> |
10 |
| - <br> |
11 |
| - <li><a href="http://vuejs-templates.github.io/webpack/" target="_blank">Docs for This Template</a></li> |
12 |
| - </ul> |
13 |
| - <h2>Ecosystem</h2> |
14 |
| - <ul> |
15 |
| - <li><a href="http://router.vuejs.org/" target="_blank">vue-router</a></li> |
16 |
| - <li><a href="http://vuex.vuejs.org/" target="_blank">vuex</a></li> |
17 |
| - <li><a href="http://vue-loader.vuejs.org/" target="_blank">vue-loader</a></li> |
18 |
| - <li><a href="https://github.com/vuejs/awesome-vue" target="_blank">awesome-vue</a></li> |
19 |
| - </ul> |
| 2 | + <div class="home container"> |
| 3 | + <h1>{{msg}}</h1> |
| 4 | + <vue-markdown>This app features |
| 5 | + |
| 6 | +* [Vue.js]() - a frontend framework |
| 7 | +* [Webpack]() - a tool to bundle your files |
| 8 | +* [vue-router]() - client-side routing |
| 9 | +* [Axios]() - a library to call your REST api |
| 10 | +* [vue-bootstrap]() which adds [Twitter bootstrap v4]() styling to the site |
| 11 | +* Authentication with [GitHub]() |
| 12 | + |
| 13 | +### Getting started |
| 14 | + |
| 15 | +First make sure you have [`npm` and `node.js`](https://nodejs.org/en/download/) installed |
| 16 | + |
| 17 | +Next, clone the boilerplate from GitHub: |
| 18 | + |
| 19 | +```bash |
| 20 | +git clone https://github.com/akeshavan/vue-auth-boilerplate |
| 21 | +``` |
| 22 | + |
| 23 | +Then install all `npm` packages: |
| 24 | + |
| 25 | +```bash |
| 26 | +cd vue-auth-boilerplate/my-app |
| 27 | +npm install |
| 28 | +``` |
| 29 | + |
| 30 | +To run the app, do: |
| 31 | + |
| 32 | +```bash |
| 33 | +npm run dev |
| 34 | +``` |
| 35 | + |
| 36 | +And navigate to [http://localhost:8080](http://localhost:8080) (or wherever npm starts the server). As you make changes to your app, the browser will reload so you don't have to keep refreshing the page. |
| 37 | + |
| 38 | +### Setting up OAuth: |
| 39 | + |
| 40 | +You need to set up oauth to your own server in order for this boilerplate to work. |
| 41 | + |
| 42 | +#### Register a new application on GitHub |
| 43 | + |
| 44 | +On your GitHub account, go to Settings > Developer Settings > OAuth Apps > New OAuth App. |
| 45 | +Fill out the form, making sure that your **Authorization callback URL** is `http://localhost:8080`. |
| 46 | +Take note of the `client_id` and `client_secret` of your app. |
| 47 | + |
| 48 | +#### Server side |
| 49 | + |
| 50 | +Your server endpoint should be something like `http://your_rest_api.com/authenticate/code`, where code is a string from GitHub that's procided by the client. |
| 51 | + |
| 52 | +The server should return a JSON that looks like: |
| 53 | + |
| 54 | +```js |
| 55 | +{"token": "secret_token_from_the_server"} |
| 56 | +``` |
| 57 | + |
| 58 | +This token will be used for all future calls to your server. In this example, our server is the GitHub api. |
| 59 | + |
| 60 | +If you don't have a server, then set one up with [prose/gatekeeper and heroku](https://github.com/prose/gatekeeper#heroku-button) |
| 61 | + |
| 62 | +Your server needs to have the `client_secret` handy. |
| 63 | + |
| 64 | +#### Client side |
| 65 | + |
| 66 | +In the `src/config.js` file of this boilerplate app, edit it so that your `client_id` and authentication endpoint `authUrl` are correct. |
| 67 | + |
| 68 | +```js |
| 69 | +export default { |
| 70 | + authUrl: 'https://your_authentication_endpoint/', |
| 71 | + clientId: 'your github client id', |
| 72 | + redirectUri: 'http://localhost:8080', //eventually this will become your production url |
| 73 | +}; |
| 74 | +``` |
| 75 | + |
| 76 | +### Production |
| 77 | + |
| 78 | +To build the app for production, do: |
| 79 | + |
| 80 | +```bash |
| 81 | +npm run build |
| 82 | +``` |
| 83 | + |
| 84 | +Everything in the `dist/` folder is your production app. |
| 85 | + |
| 86 | + </vue-markdown> |
| 87 | + |
20 | 88 | </div>
|
| 89 | + |
| 90 | + |
21 | 91 | </template>
|
22 | 92 |
|
23 | 93 | <script>
|
| 94 | +import VueMarkdown from 'vue-markdown' |
| 95 | +
|
24 | 96 | export default {
|
25 | 97 | name: 'Home',
|
| 98 | + components: { |
| 99 | + VueMarkdown, |
| 100 | + }, |
26 | 101 | data() {
|
27 | 102 | return {
|
28 |
| - msg: 'Welcome to Your Vue.js App', |
| 103 | + msg: 'Welcome to your Vue app boilerplate', |
| 104 | + content: '\ni am a ~~tast~~ **test**. `foo = bar`', |
29 | 105 | };
|
30 | 106 | },
|
31 | 107 | };
|
|
47 | 123 | a {
|
48 | 124 | color: #42b983;
|
49 | 125 | }
|
| 126 | +.home { |
| 127 | + text-align: left; |
| 128 | +} |
| 129 | +
|
| 130 | +.home h1 { |
| 131 | + text-align: center; |
| 132 | +} |
| 133 | +
|
50 | 134 | </style>
|
0 commit comments