Skip to content

Commit

Permalink
Install packages
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoluoboding committed Aug 17, 2016
1 parent 7af337f commit 2b1408c
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 24 deletions.
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -5,7 +5,7 @@
<title>repository-tree</title>
</head>
<body>
<app></app>
<div id="root"></div>
<script src="dist/build.js"></script>
</body>
</html>
13 changes: 11 additions & 2 deletions package.json
Expand Up @@ -3,12 +3,20 @@
"description": "Pretty display directory tree view of a GitHub repository.",
"author": "xiaoluoboding <xiaoluoboding@gmail.com>",
"scripts": {
"dev": "webpack-dev-server --inline --hot",
"dev": "webpack-dev-server --inline --hot --port 9876",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"babel-runtime": "^6.0.0",
"github-api": "^2.3.0",
"octicons": "^4.3.0",
"primer-css": "^4.1.0",
"superagent": "^2.2.0",
"treeify": "^1.0.1",
"vue": "^1.0.0",
"babel-runtime": "^6.0.0"
"vue-resource": "^0.9.3",
"vue-router": "^0.7.13",
"vuex": "^1.0.0-rc.2"
},
"devDependencies": {
"babel-core": "^6.0.0",
Expand All @@ -18,6 +26,7 @@
"babel-preset-stage-2": "^6.0.0",
"cross-env": "^1.0.6",
"css-loader": "^0.23.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.4",
"json-loader": "^0.5.4",
"url-loader": "^0.5.7",
Expand Down
39 changes: 22 additions & 17 deletions src/App.vue
@@ -1,25 +1,30 @@
<template>
<div id="app">
<h1>{{ msg }}</h1>
</div>
</template>

<script>
import NavBar from './components/NavBar.vue'
import Main from './components/Main.vue'
import store from './vuex/store'
export default {
data () {
return {
// note: changing this line won't causes changes
// with hot-reload because the reloaded component
// preserves its current state and we are modifying
// its initial state.
msg: 'Hello Vue!'
}
name: 'App',
store,
components: {
NavBar,
Main
}
}
</script>

<template>
<div id="app">
<header>
<nav-bar></nav-bar>
</header>
<main></main>
</div>
</template>

<style>
body {
font-family: Helvetica, sans-serif;
}
@import '~primer-css/build/build.css';
@import '~octicons/build/font/octicons.min.css';
</style>
62 changes: 62 additions & 0 deletions src/components/NavBar.vue
@@ -0,0 +1,62 @@
<script>
import { setFullRepoName } from '../vuex/actions'
export default {
name: 'NavBar',
vuex: {
getters: {
fullRepoName: ({ main }) => main.fullRepoName
},
actions: {
setFullRepoName
}
},
computed: {
inputValue: {
get () {
return this.fullRepoName
},
set (val) {
this.setFullRepoName(val)
}
}
}
}
</script>

<template>
<div class="header">
<div class="container">
<div class="header-logo">
<a href="#!"><span class="mega-octicon octicon-mark-github"></span></a>
</div>
<form>
<label for="fullRepoName">Full Repo Name:</label>
<input id="fullRepoName" class="form-control" type="text"
placeholder="xiaoluoboding/repository-tree"
v-model="inputValue">
<span class="input-group-button">
<button type="button" class="btn btn-primary">Generate</button>
</span>
</form>
</div>
</div>
</template>

<style>
.header {
padding: 10px;
background-color: #f5f5f5;
border-bottom: 1px solid #e5e5e5;
}
.header-logo {
float: left;
margin-right: 10px;
}
#fullRepoName {
width: 480px;
}
</style>
54 changes: 54 additions & 0 deletions src/components/main.vue
@@ -0,0 +1,54 @@
<script>
export default {
name: 'Main'
}
</script>

<template>
<div class="container page-content">
<h1 class="public">
<span class="octicon octicon-repo"></span>
<span class="author" itemprop="author">
<a href="/xiaoluoboding" rel="author">xiaoluoboding</a>
</span>
<span class="path-divider">/</span>
<strong itemprop="name">
<a href="/xiaoluoboding/astrolabe">astrolabe</a>
</strong>
</h1>
<div class="blankslate blankslate-spacious blankslate-large">
<h3>Welcome to GitHub repository tree view generater</h3>
<p>Copy your github repository link and <kbd>click</kbd> the <code>Generate</code> button, then you will see the pretty display of tree view.</p>
</div>
</div>
</template>

<style>
.page-content {
padding-top: 20px;
}
.page-content h1 {
position: relative;
max-width: 635px;
padding-left: 18px;
padding-bottom: 20px;
font-size: 16px;
line-height: 26px;
color: #666;
}
.boxed-header {
position: relative;
padding: 10px;
margin-bottom: -1px;
font-size: 13px;
line-height: 20px;
color: #68777d;
background-color: #f2f9fc;
border: 1px solid #c9e6f2;
border-radius: 3px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
</style>
23 changes: 20 additions & 3 deletions src/main.js
@@ -1,7 +1,24 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import Router from './router'
import App from './App.vue'

new Vue({
el: 'body',
components: { App }
Vue.use(VueRouter)

// Set up a new router
const router = new VueRouter()

Router(router)

// For every new route scroll to the top of the page
router.beforeEach(function() {
window.scrollTo(0, 0)
})

// If no route is matched redirect home
router.redirect({
'*': '/'
})

// Start up our app
router.start(App, '#root')
8 changes: 8 additions & 0 deletions src/router.js
@@ -0,0 +1,8 @@
// Route config
export default function(router) {
router.map({
'/': {
component: require("./App.vue")
}
})
}
6 changes: 6 additions & 0 deletions src/vuex/actions.js
@@ -0,0 +1,6 @@
// index actions
export const setFullRepoName = makeAction('SET_FULLREPONAME')

function makeAction (type) {
return ({ dispatch }, ...args) => dispatch(type, ...args)
}
19 changes: 19 additions & 0 deletions src/vuex/modules/main.js
@@ -0,0 +1,19 @@
// vuex/modules/main.js
import { SET_FULLREPONAME } from '../mutation-types'

// 该模块的初始状态
const state = {
fullRepoName: ''
}

// 相关的 mutations
const mutations = {
[SET_FULLREPONAME] (state, fullRepoName) {
state.fullRepoName = fullRepoName
}
}

export default {
state,
mutations
}
2 changes: 2 additions & 0 deletions src/vuex/mutation-types.js
@@ -0,0 +1,2 @@
// index mutation types
export const SET_FULLREPONAME = 'SET_FULLREPONAME'
12 changes: 12 additions & 0 deletions src/vuex/store.js
@@ -0,0 +1,12 @@
// vuex/store.js
import Vue from 'vue'
import Vuex from 'vuex'
import main from './modules/main'

Vue.use(Vuex)

export default new Vuex.Store({
modules: {
main
}
})
6 changes: 5 additions & 1 deletion webpack.config.js
Expand Up @@ -31,7 +31,11 @@ module.exports = {
loader: 'vue-html'
},
{
test: /\.(png|jpg|gif|svg)$/,
test: /\.scss$/,
loader: 'style!css!sass'
},
{
test: /\.(png|jpg|gif|svg|woff2?|eot|ttf)(\?.*)?$/,
loader: 'url',
query: {
limit: 10000,
Expand Down

0 comments on commit 2b1408c

Please sign in to comment.