Skip to content

Commit

Permalink
Merge pull request #20 from funktechno/f/updates
Browse files Browse the repository at this point in the history
F/updates 0.0.7 bug and submit for example
  • Loading branch information
lastlink authored Mar 6, 2021
2 parents a446721 + a4b8642 commit 4878e82
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 27 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
library/connections.php
config/connections.php
.DS_Store
vendor
mail/mailConfig.php
library/mailFunctions.php
library/connections-*.php
config/connections-*.php
library/sso
3 changes: 2 additions & 1 deletion accounts/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
}
$GLOBALS['root'] = "../";
// Get the database connection file
require_once '../library/connections.php';
require_once '../config/connections.php';
require_once '../library/functions.php';
// Get the acme model for use as needed
require_once '../model/form-model.php';
require_once '../model/accounts-model.php';
require_once '../model/pages-model.php';
require_once '../model/reviews-model.php';
Expand Down
2 changes: 1 addition & 1 deletion comments/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}
$GLOBALS['root'] = "../";
// Get the database connection file
require_once '../library/connections.php';
require_once '../config/connections.php';
require_once '../library/functions.php';
require_once '../model/reviews-model.php';
require_once '../model/accounts-model.php';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// change document root if serving from somewhere else such as /
// copy this file to connections.php w/ proper info
$GLOBALS['documentRoot'] = '/';
require_once 'Core.php';
require_once $GLOBALS['root'] .'library/Core.php';

// require '../vendor/autoload.php';
define('Allowed_Origins','*');
Expand Down
35 changes: 33 additions & 2 deletions examples/js/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ var app = new Vue({
pageSlug: "test",
newComment: {},
comments: [],
loading: false,
example: "comments",
status: null,
form: {},
loading: {
general: false,
comments: false
comments: false,
form: false
},
userForm: {},
modal: {
Expand All @@ -50,6 +53,34 @@ var app = new Vue({
logout() {
this.userData = null
this.isGuest = false
},
submitMessage() {
if (this.loading.form) {
return;
}
this.errors = null;
this.status = null;
let request = JSON.parse(JSON.stringify(this.form));
this.loading.form = true;
this.$http.post("/form/?action=submit", request).then((response) => {
this.loading.form = false;
console.log(response)
// this.message = response.data.message;
if (response.status == 201) {
this.form = {};
console.log(response.data);
this.status = "Message Sent"
} else {
this.errors = "Failed to submit message"
}
}).catch((error) => {
this.errors = error.data
console.log(error)
this.loading.form = null;

});


},
addComment() {
// don't run if not logged in or loading
Expand Down
64 changes: 50 additions & 14 deletions examples/vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,54 @@ <h2>Comment Press Vue Example</h2>
<div v-show="errors" style="display: none;">
{{ errors }}
</div>
<div class="auth-panel auth-panel_theme_light auth-panel_logged-in" v-show="userData!=null || isGuest"
style="display: none;">
<div class="auth-panel__column" v-if="userData!=null || isGuest">You logged in as <div class="dropdown dropdown_theme_light">
<div v-show="status" style="display: none;">
{{ status }}
</div>
<div v-show="example == 'form'" style="display: none;">
<h3>Contact Form Example</h3>
<div class="lds-ellipsis" v-show="loading.form" style="display: none;">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<button v-on:click="example = 'comments'">Comments</button>

<label>Subject</label>
<br>
<input type="text" v-model="form.subject" name="subject" id="subject" required>
<br>
<label>Email</label>
<br>
<input type="email" v-model="form.email" name="email" id="email" required>
<br>
<label>Message</label>
<br>
<textarea v-model="form.body" name="message" id="message" required>
</textarea>
<br>
<button v-on:click="submitMessage()">Submit</button>

</div>
<div v-show="example=='comments' && (userData!=null || isGuest)"
class=" auth-panel auth-panel_theme_light auth-panel_logged-in" style="display: none;">

<div class=" auth-panel__column" v-if="userData!=null || isGuest">You logged in as <div
class="dropdown dropdown_theme_light">
<span v-if="isGuest">Guest</span>
<button v-else
class="button button_kind_link button_theme_light dropdown__title auth-panel__user-dropdown-title"
type="button" aria-haspopup="listbox" aria-expanded="false">{{ userData.userInfo.displayName }}</button>
type="button" aria-haspopup="listbox" aria-expanded="false">
{{ userData.userInfo.displayName }}
</button>
</div> <button class="button button_kind_link button_theme_light" type="button"
v-on:click="logout()">Logout?</button></div>
v-on:click="logout()">Logout?</button>
</div>
<div class="auth-panel__column"><button class="button button_kind_link auth-panel__admin-action"
type="button" role="link" tabindex="0">Show settings</button><span
class="auth-panel__sort">Sort by <span class="auth-panel__select-label"><span
class="auth-panel__select-label-value">Recently updated</span><select
class="auth-panel__select">
class="auth-panel__sort">Sort
by <span class="auth-panel__select-label"><span class="auth-panel__select-label-value">Recently
updated</span><select class="auth-panel__select">
<option value="-score">Best</option>
<option value="+score">Worst</option>
<option value="-time">Newest</option>
Expand All @@ -59,7 +93,9 @@ <h2>Comment Press Vue Example</h2>
<option value="+controversy">Least controversial</option>
</select></span></span></div>
</div>
<div class="root__main">
<div v-show="example=='comments'" class="root__main">
<button v-on:click="example = 'form'">Contact Form</button>

<div class="comment-form__control-panel">

</div>
Expand All @@ -74,8 +110,7 @@ <h2>Comment Press Vue Example</h2>
class="button button_kind_secondary button_size_large button_theme_light comment-form__button"
type="button">Preview</button>
<button class="button button_kind_primary button_size_large comment-form__button"
v-on:click="addComment"
type="submit">Send</button>
v-on:click="addComment" type="submit">Send</button>
</div>
<div class="auth auth-module__root_641f4" v-show="!(isGuest || userData != null)">
<button v-on:click="modal.signIn = !modal.signIn"
Expand Down Expand Up @@ -145,7 +180,7 @@ <h5 class="auth-form-title auth-module__title_f76db">Use Social Network</h5>
</div>
</div>
<!-- <div class="comment-form__markdown">Styling with <a class="comment-form__markdown-link"
target="_blank" href="markdown-help.html">Markdown</a> is supported</div> -->
target="_blank" href="markdown-help.html">Markdown</a> is supported</div> -->
</div>
<div class="root__pinned-comments" role="region" aria-label="Pinned comments">
<article
Expand Down Expand Up @@ -187,11 +222,12 @@ <h5 class="auth-form-title auth-module__title_f76db">Use Social Network</h5>
</div>
</div>
<div class="root__threads" role="list">
<comment-thread v-show="comments.length > 0" :isGuest="isGuest" :userData="userData" v-for="c in comments" :comment="c" level=0
style="display: none;" />
<comment-thread v-show="comments.length > 0" :isGuest="isGuest" :userData="userData"
v-for="c in comments" :comment="c" level=0 style="display: none;" />
</div>

</div>
<!-- end root main -->
</div>
</div>
<script src="./js/vue.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions form/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
$GLOBALS['root'] = "../";
// Get the database connection file
require_once '../library/connections.php';
require_once '../config/connections.php';
require_once '../library/functions.php';
require_once '../model/form-model.php';
require_once '../library/error_responses.php';
Expand Down Expand Up @@ -34,7 +34,7 @@
$checkEmail = checkEmail($email);

if (empty($checkEmail)) {
$errorStatus->response(400, "Please provide valid email" . $email);
$errorStatus->response(400, "Please provide valid email:" . $email);
}

if (empty($email) || empty($body) || empty($subject)) {
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
$GLOBALS['root'] = "";
// Get the database connection file
require_once 'library/connections.php';
require_once 'config/connections.php';
require_once 'library/functions.php';

// Build a navigation bar using the $categories array
Expand Down
2 changes: 1 addition & 1 deletion library/Core.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
//should contain app meta data such as version
define('APP_VERSION', '0.0.6');
define('APP_VERSION', '0.0.7');

define('APP_Name','CommentsPress');
// comment out this line if you don't want this meta response header
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* run `sql/acme-db.sql` CAREFUL TO NOT RESET EXISTING DATA against chosen mysql db
* may want to change the admin user w/ your email
* copy all most files excluding `assets,rest,mail` folders
* copy `cp ./library/connections-backup.php ./library/connections.php`
* copy `cp ./config/connections-backup.php ./config/connections.php`
* fill out database settings, mail provider, jwt secret
* test working mail form server in `mail` folder
* copy `mailConfig-back.php mailConfig.php`
Expand Down
2 changes: 1 addition & 1 deletion users/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}
$GLOBALS['root'] = "../";
// Get the database connection file
require_once '../library/connections.php';
require_once '../config/connections.php';
require_once '../library/functions.php';

// require_once '../library/jwt/ValidatesJWT.php';
Expand Down

0 comments on commit 4878e82

Please sign in to comment.