forked from Detachment/Build-vue-hackernews-2.0-from-scratch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
150 lines (140 loc) · 6.61 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Zero edition of Vue-HN</title>
<script src="https://www.gstatic.com/firebasejs/3.6.5/firebase.js"></script>
<script src="https://unpkg.com/[email protected]/dist/vue.js" charset="utf-8"></script>
<script src="https://unpkg.com/[email protected]/dist/vue-router.js" charset="utf-8"></script>
<script src="https://unpkg.com/[email protected]" charset="utf-8"></script>
<script src="./api.js"></script>
<script src="./sync.js"></script>
<!-- <link href='https://fonts.googleapis.com/css?family=Roboto:300,400,700' rel='stylesheet' type='text/css'> -->
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div id="app">
<div class="header">
<div class="inner">
<a href="javascript:;">
<img src="../../website-icon/logo.png" alt="logo" class="logo">
</a>
<router-link to="/top">Top</router-link>
<router-link to="/new">New</router-link>
<router-link to="/show">Show</router-link>
<router-link to="/ask">Ask</router-link>
<router-link to="/job">Jobs</router-link>
<a href="https://github.com/vuejs/vue-hackernews-2.0" target="_blank" class="github">
Bulid with Vue.js
</a>
</div>
</div>
<router-view class="view"></router-view>
</div>
<script type="text/x-template" id="itemlist">
<div class="top">
<div class="nav">
<div class="pages">
<router-link v-if='page > 1' :to="'/' + type + '/' + (page - 1)">< prev</router-link>
<a v-else class="disabled">< prev</a>
<span>{{ page }}/{{ maxPage }}</span>
<router-link v-if="hasMore" :to="'/' + type + '/' + (page + 1)">more ></router-link>
<a v-else class="disabled">more ></a>
</div>
</div>
<transition :name="transition">
<div class="news-list" :key="displayedPage" v-if="true">
<transition-group tag="ul" name="item">
<li v-for="item in displayedItems" :key="item.id" class="news-item">
<span class="score">{{ item.score }}</span>
<span class="title">
<template v-if="item.url">
<a :href="item.url" target="_blank">{{ item.title }}</a>
<span class="host">({{ item.url | host }})</span>
</template>
<template v-else>
<router-link :to="'/item/' + item.id">{{ item.title }}</router-link>
</template>
</span>
<br>
<span class="meta">
<span v-if="item.type !== 'job'" class="by">
by <router-link :to="'/user/' + item.by">{{ item.by }}</router-link>
</span>
<span class="time">
{{ item.time | timeAgo }} ago
</span>
<span v-if="item.type !== 'job'" class="comments-link">
| <router-link :to="'/item/' + item.id ">{{ item.descendants }} comments</router-link>
</span>
</span>
<span class="label" v-if="item.type !== 'story'">{{ item.type }}</span>
</li>
</transition-group>
</div>
</transition>
</div>
</script>
<script type="text/x-template" id="userview">
<div class="user-view">
<template v-if="user">
<h1>User : {{ user.id }} </h1>
<ul class="meta">
<li><span class="label">Created:</span> {{ user.created | timeAgo }} ago </li>
<li><span class="label">Karma:</span> {{ user.karma }}</li>
<li v-if="user.about" v-html="user.about" class="about"></li>
</ul>
<p class="links">
<a :href="'https://news.ycombinator.com/submitted?id=' + user.id">submissions</a> |
<a :href="'https://news.ycombinator.com/threads?id=' + user.id">comments</a>
</p>
</template>
</div>
</script>
<script type="text/x-template" id="itemview">
<div class="item-view" v-if="item">
<template v-if="item">
<div class="item-view-header">
<a :href="item.url" target="_blank">
<h1>{{ item.title }}</h1>
</a>
<span v-if="item.url" class="host">
({{ item.url | host }})
</span>
<p class="meta">
{{ item.score }} points
| by <router-link :to="'/user/' + item.by">{{ item.by }}</router-link>
{{ item.time | timeAgo }} ago
</p>
</div>
<div class="item-view-comments">
<p class="item-view-comments-header">
{{ item.kids ? item.descendants + ' comments' : 'No comment yet.'}}
</p>
<ul v-if="item.kids" class="comment-children">
<CommentView v-for="id in item.kids" :id="id"></CommentView>
</ul>
</div>
</template>
</div>
</script>
<script type="text/x-template" id="commentview">
<li v-if="comment" class="comment">
<div class="by">
<router-link :to="'/user/' + comment.by">{{ comment.by }}</router-link>
{{ comment.time | timeAgo }} ago
<span v-if="comment.kids && comment.kids.length">
| <a @click="open = !open" class="expand">
{{ pluralize(comment.kids.length) + (open ? ' collapse ' : ' expand ') }}
</a>
</span>
</div>
<div class="text" v-html="comment.text"></div>
<ul class="comment-children" v-show="open">
<comment v-for="id in comment.kids" :id="id"></comment>
</ul>
</li>
</script>
<script src="./app.js"></script>
</body>
</html>