-
Notifications
You must be signed in to change notification settings - Fork 62
Why? What? How? #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
After running all the schema generators (above), 10 of the default tests are failing: |
Continue: https://hexdocs.pm/phoenix/contexts.html |
lib/hits_web/templates/layout/app.html.eex <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Hits</title>
<!-- <link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/> -->
<link rel="stylesheet" href="https://unpkg.com/tachyons@4.8.0/css/tachyons.min.css"/>
</head>
<body class="">
<main role="main"">
<!-- <p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p> -->
<%= render @view_module, @view_template, assigns %>
</main>
<script type="text/javascript" src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script>
</body>
</html> lib/hits_web/templates/page/index.html.eex <h2 class="bg-teal white h-25 tc ttu f1 lh-title lh-solid mt0 pa2 pb3 mb0 pb0">
Hits!
<a href="http://hits.dwyl.io/" >
<img src="http://hits.dwyl.io/homepage.svg" alt="Hit Count" class="pa0 ba bw1 b--white">
</a>
</h2>
<h4 class="mt0 tc fw5 f5 teal pa2 mb0">
The <em>easy</em> way to know how many people are
<strong><em>viewing</em></strong> your GitHub projects!
</h4>
<h2 class="mt0 fw5 tc f2 bg-teal white pa2"><em>How?</em></h2>
<div id="how" class="dn pa3">
<table class="collapse pv2 ph3 w-100 pa4">
<tr class="bb-0">
<td class="pv2 ph3 w-30">
Input your <strong class="fw5">GitHub Username</strong>
(<em> <strong class="u">or</strong> org name</em>):
</td>
<td class="pv2 ph3 w-30">
<input class="input-reset f4 pa2 ba mr5 w-80" type="text"
id="username" name="username" placeholder="username" autofocus maxlength="50">
</td>
</tr>
<tr class="">
<td class="pv2 ph3 w-40">
Input the <strong class="fw5">GitHub Project/Repository</strong>
name:
</td>
<td class="pv2 ph3 w-40">
<input class="input-reset f4 pa2 ba mr5 w-80" type="text"
id="repo" name="repo" placeholder="repo/project" maxlength="100">
</td>
</tr>
</table>
</div>
<h3 class="mt3 fw5 tc db f3 bg-teal white pa2">Your Badge <em>Markdown:</em></h3>
<pre id="badge" class="fw4 ba bw1 pa3 ma2" style="white-space: pre-wrap; word-break: keep-all;">
[](http://hits.dwyl.io/{username}/{repo})
</pre>
<p class="pl2" id="nojs">
Using the above markdown as a template, <br />
<em>Replace</em> the <strong class="code">{username}</strong> with <em>your</em> GitHub username <br />
<em>Replace</em> the <strong class="code">{repo}</strong> with the repo name.
</p>
<p class="pl2 ml2">
<em>Copy</em> the markdown snippet and <em>Paste</em> it into your
<strong class="code">README.md</strong> file <br />
to start tracking the view count on your GitHub project!
</p>
<h2 class="mt0 fw5 tc f4 bg-teal white pa2 mt5"><em>Recently</em> Viewed Projects (<em>tracked by Hits</em>)</h2>
<div class="h5 pl2" id='hits'>
<div style="display:none">Dummy Child Node for insertBefore to work</div>
</div>
<style>
.teal {
color: #4DB6AC;
}
.bg-teal {
background: #4DB6AC;
}
body { /* dwyl font */
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
</style> app.js // Markdown Template
var mt = '[](http://hits.dwyl.io/{user}/{repo})';
function generate_markdown () {
var user = document.getElementById("username").value || '{username}';
var repo = document.getElementById("repo").value || '{project}';
// console.log('user: ', user, 'repo: ', repo);
user = user.replace(/[.*+?^$<>()|[\]\\]/g, '');
repo = repo.replace(/[.*+?^$<>()|[\]\\]/g, '');
return mt.replace(/{user}/g, user).replace(/{repo}/g, repo);
}
function display_badge_markdown () {
var md = generate_markdown()
var pre = document.getElementById("badge").innerHTML = md;
}
setTimeout(function () {
// show form if JS available (progressive enhancement)
document.getElementById("how").classList.remove('dn');
document.getElementById("nojs").classList.add('dn');
display_badge_markdown(); // render initial markdown template
var get = document.getElementsByTagName('input');
for (var i = 0; i < get.length; i++) {
get[i].addEventListener('keyup', display_badge_markdown, false);
get[i].addEventListener('keyup', display_badge_markdown, false);
}
}, 500); Start from scratch (keeping meta files and
|
…ode which is not being executed ... 🙄 #66
…o that its easier to see which lines are not covered ... #66
If you are interested in a step-by-step tutorial/example, leave a comment on #74 |
This issue is now complete. Closing. ✅ |
Why?
Phoenix is awesome and a phoenix/elixir implementation will be far more stable than the current (node.js) version which keeps crashing.
see: dwyl/product-roadmap#7 and #62, #63, #64 & #65
What?
Migrate the
node.js
Hits app https://github.com/dwyl/hitsto Phoenix using code written for https://github.com/dwyl/hits-elixir
Use a PostgreSQL database to store data so that we can run more interesting/advanced queries
How?
Going to document this as go but the the outline is:
see: https://hexdocs.pm/phoenix/installation.html#phoenix
mix phx.new hits
users
schema for storinguser
data:repos
schema for storingrepo
data:useragents
schema for storing user agent data:and HTML (views+templates)hits
for storing and viewing hit data:Create endpoint for "happy path"
/:user/:repository
Extract the metadata (
useragent
andip
address) from theconn
headers:https://github.com/dwyl/hits-elixir/blob/b2ed9c10aabc20a36f24c185a5f2a9831b1652d3/lib/hits.ex#L45-L54
INSERT
thehit
into the dabaseQuery PostgreSQL for the hit count for that repo How to SELECT COUNT(*) FROM hits WHERE repo_id = $1 #71
Create the SVG using string interpolation:
https://github.com/dwyl/hits-elixir/blob/b2ed9c10aabc20a36f24c185a5f2a9831b1652d3/lib/hits.ex#L29-L31
Return the SVG
Update screenshots to reflect change in TCP Port
8080
>4000
The text was updated successfully, but these errors were encountered: