Skip to content

Commit b58e1f7

Browse files
montymxbflovilmart
authored andcommitted
Changes references to api.parse.com and /1/ (#458)
* Changes references to api.parse.com and /1/ * Mention we use https in our examples * Adds ability to set url/mount shown on page * Moves customization into a section on the main page. Adds protocol/appId/clientKey. Fixes some raw html spitting out in replacement. * Updated with some additional validation on the user provided fields * Disabled autocorrect on all fields * Remove spellcheck
1 parent 59482bc commit b58e1f7

30 files changed

+1850
-1577
lines changed

_app/main.js

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,9 @@ App.Views = {};
650650
// deal with common-lang-blocks
651651
this.toggleCommonLangBlocks();
652652

653+
// setup the server/mount path editor
654+
this.setupServerFieldCustomization();
655+
653656
// add toggles to code blocks if necessary
654657
if (this.platform === "ios" || this.platform === "osx" || this.platform === "macos") {
655658
new App.Views.Docs.Toggle({
@@ -729,6 +732,123 @@ App.Views = {};
729732
}
730733
},
731734

735+
setupServerFieldCustomization: function setupServerFieldCustomization() {
736+
737+
if(!document.getElementById('parse-server-custom-url')) {
738+
// no customization available on this page
739+
return;
740+
}
741+
742+
if (typeof(Storage) !== "undefined") {
743+
// apply previous values from local storage
744+
const _url = localStorage.getItem('parse-server-custom-url');
745+
const _mount = localStorage.getItem('parse-server-custom-mount');
746+
const _protocol = localStorage.getItem('parse-server-custom-protocol');
747+
const _appId = localStorage.getItem('parse-server-custom-appid');
748+
const _clientKey = localStorage.getItem('parse-server-custom-clientkey');
749+
750+
// set existing entries
751+
if (_url) {
752+
$(".custom-parse-server-url").html(_url);
753+
$("#parse-server-custom-url").val(_url);
754+
}
755+
if (_mount) {
756+
$(".custom-parse-server-mount").html(_mount);
757+
$("#parse-server-custom-mount").val(_mount);
758+
}
759+
if (_protocol) {
760+
$(".custom-parse-server-protocol").html(_protocol);
761+
$("#parse-server-custom-protocol").val(_protocol);
762+
}
763+
if (_appId) {
764+
$(".custom-parse-server-appid").html(_appId);
765+
$("#parse-server-custom-appid").val(_appId);
766+
}
767+
if (_clientKey) {
768+
$(".custom-parse-server-clientkey").html(_clientKey);
769+
$("#parse-server-custom-clientkey").val(_clientKey);
770+
}
771+
}
772+
773+
// set url listener
774+
$('#parse-server-custom-url').keyup(function() {
775+
const url = $('#parse-server-custom-url').val();
776+
if(!url.match(/^[-_a-z0-9\.]+(?::[0-9]+)?$/i)) {
777+
// not a valid url
778+
return;
779+
}
780+
$(".custom-parse-server-url").html(url);
781+
if (typeof(Storage) !== "undefined") {
782+
localStorage.setItem('parse-server-custom-url', url);
783+
}
784+
});
785+
786+
// set mount listener
787+
$('#parse-server-custom-mount').keyup(function() {
788+
var mount = $('#parse-server-custom-mount').val();
789+
if(!mount.match(/^[-_a-z0-9\/]+$/i) && mount !== '') {
790+
// not a valid mount path, and not empty
791+
return;
792+
}
793+
if(!mount.match(/^\//)) {
794+
// add leading slash
795+
mount = '/'+mount;
796+
}
797+
if(!mount.match(/\/$/)) {
798+
// add trailing slash
799+
mount = mount+'/';
800+
}
801+
$(".custom-parse-server-mount").html(mount);
802+
if (typeof(Storage) !== "undefined") {
803+
localStorage.setItem('parse-server-custom-mount', mount);
804+
}
805+
});
806+
807+
// set protocol listener
808+
$('#parse-server-custom-protocol').change(function() {
809+
const protocol = $('#parse-server-custom-protocol').val();
810+
if(!protocol.match(/^[a-z]+$/)) {
811+
// not a valid protocol
812+
return;
813+
}
814+
$(".custom-parse-server-protocol").html(protocol);
815+
if (typeof(Storage) !== "undefined") {
816+
localStorage.setItem('parse-server-custom-protocol', protocol);
817+
}
818+
});
819+
820+
// set appId listener
821+
$('#parse-server-custom-appid').keyup(function() {
822+
var appId = $('#parse-server-custom-appid').val();
823+
if(!appId.match(/^[^\s]+$/i)) {
824+
// not a valid appId
825+
return;
826+
}
827+
// encode any html
828+
appId = appId.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
829+
$(".custom-parse-server-appid").html(appId);
830+
if (typeof(Storage) !== "undefined") {
831+
localStorage.setItem('parse-server-custom-appid', appId);
832+
}
833+
});
834+
835+
// set clientKey listener
836+
$('#parse-server-custom-clientkey').keyup(function() {
837+
var clientKey = $('#parse-server-custom-clientkey').val();
838+
if(!clientKey.match(/^[^\s]+$/i)) {
839+
// not a valid appId
840+
return;
841+
}
842+
// encode any html
843+
clientKey = clientKey.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
844+
$(".custom-parse-server-clientkey").html(clientKey);
845+
if (typeof(Storage) !== "undefined") {
846+
localStorage.setItem('parse-server-custom-clientkey', clientKey);
847+
}
848+
});
849+
850+
},
851+
732852
// we recalculate the header heights for the TOC
733853
// highlighting when the height of the content changes
734854
handleToggleChange: function() {
@@ -753,7 +873,7 @@ $('pre code').each(function(i, block) {
753873
hljs.highlightBlock(block);
754874
});
755875

756-
var platform = window.location.pathname.split('/')[2];
876+
var platform = window.location.pathname.split('/')[1];
757877
if (platform) {
758878
new App.Views.Docs.Main({
759879
language: 'en',

_includes/android/push-notifications.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ curl -X GET \
494494
-G \
495495
--data-urlencode 'limit=1000' \
496496
--data-urlencode 'where={ "city": "San Francisco", "deviceType": { "$in": [ "ios", "android", "winphone", "embedded" ] } }' \
497-
https://api.parse.com/1/installations
497+
https://YOUR.PARSE-SERVER.HERE/parse/installations
498498
```
499499

500500
If you type the above into a console, you should be able to see the first 1,000 objects that match your query. Note that constraints are always ANDed, so if you want to further reduce the search scope, you can add a constraint that matches the specific installation for your device:
@@ -507,7 +507,7 @@ curl -X GET \
507507
-G \
508508
--data-urlencode 'limit=1' \
509509
--data-urlencode 'where={ “objectId”: {YOUR_INSTALLATION_OBJECT_ID}, "city": "San Francisco", "deviceType": { "$in": [ "ios", "android", "winphone", "embedded" ] } }' \
510-
https://api.parse.com/1/installations
510+
https://YOUR.PARSE-SERVER.HERE/parse/installations
511511
```
512512

513513
If the above query returns no results, it is likely that your installation does not meet the targeting criteria for your campaign.

_includes/arduino/other.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Because the Arduino SDK was designed to minimize memory footprint, it doesn't pr
55
For example, you could sign up a user from Arduino through a REST call:
66

77
```cpp
8-
ParseResponse response = Parse.sendRequest("POST", "/1/users", "{\"username\":\"cooldude6\",\"password\":\"p_n7!-e8\"}", "");
8+
ParseResponse response = Parse.sendRequest("POST", "/parse/users", "{\"username\":\"cooldude6\",\"password\":\"p_n7!-e8\"}", "");
99
```
1010

1111
In this case, the response will contain the objectId of the created user, assuming it was created successfully.

_includes/arduino/requests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Because the Arduino SDK was designed to minimize memory footprint, it doesn't pr
55
For example, you could sign up a user from Arduino through a REST call:
66

77
```cpp
8-
ParseResponse response = Parse.sendRequest("POST", "/1/users", "{\"username\":\"cooldude6\",\"password\":\"p_n7!-e8\"}", "");
8+
ParseResponse response = Parse.sendRequest("POST", "/parse/users", "{\"username\":\"cooldude6\",\"password\":\"p_n7!-e8\"}", "");
99
```
1010

1111
In this case, the response will contain the objectId of the created user, assuming it was created successfully.

_includes/cloudcode/cloud-code.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ curl -X POST \
9898
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
9999
-H "Content-Type: application/json" \
100100
-d '{ "movie": "The Matrix" }' \
101-
https://api.parse.com/1/functions/averageStars
101+
https://YOUR.PARSE-SERVER.HERE/parse/functions/averageStars
102102
```
103103

104104
And finally, to call the same function from a JavaScript app:

_includes/common/security.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,9 +456,9 @@ There are some special classes in Parse that don't follow all of the same securi
456456
|Delete|normal behavior [5]|master key only [7]|
457457
|Add Field|normal behavior|normal behavior|
458458

459-
1. Logging in, or `/1/login` in the REST API, does not respect the Get CLP on the user class. Login works just based on username and password, and cannot be disabled using CLPs.
459+
1. Logging in, or `/parse/login` in the REST API, does not respect the Get CLP on the user class. Login works just based on username and password, and cannot be disabled using CLPs.
460460

461-
2. Retrieving the current user, or becoming a User based on a session token, which are both `/1/users/me` in the REST API, do not respect the Get CLP on the user class.
461+
2. Retrieving the current user, or becoming a User based on a session token, which are both `/parse/users/me` in the REST API, do not respect the Get CLP on the user class.
462462

463463
3. Read ACLs do not apply to the logged in user. For example, if all users have ACLs with Read disabled, then doing a find query over users will still return the logged in user. However, if the Find CLP is disabled, then trying to perform a find on users will still return an error.
464464

_includes/common/server-customize.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Your Configuration
2+
3+
<noscript>
4+
<p style='padding:8px;color:#fff;background:#f06;border-radius:4px;font-weight:bold'>Customization requires Javascript to be enabled!</p>
5+
</noscript>
6+
Customize our docs with your server configuration.
7+
8+
Protocol:<br/>
9+
<select id='parse-server-custom-protocol' class='custom-server-option' style='border:none' title='Set your access protocol here.'>
10+
<option value='https'>https</option>
11+
<option value='http'>http</option>
12+
</select><br/>
13+
Domain:
14+
<input id='parse-server-custom-url' class='custom-server-option' type='text' placeholder='your.domain.com, your.domain.com:1337' value='YOUR.PARSE-SERVER.HERE' title='Set your parse server domain here.' autocorrect='off' spellcheck='false'>
15+
Mount Path:
16+
<input id='parse-server-custom-mount' class='custom-server-option' type='text' placeholder='your-mount-path, /your-mount-path/' value='parse' title='Set your mount path here.' autocorrect='off' spellcheck='false'>
17+
App Id:
18+
<input id='parse-server-custom-appid' class='custom-server-option' type='text' placeholder='your-app-id-here' value='APPLICATION_ID' title='Set your app id here.' autocorrect='off' spellcheck='false'>
19+
Client Key:
20+
<input id='parse-server-custom-clientkey' class='custom-server-option' type='text' placeholder='your-client-key-here' value='CLIENT_KEY' title='Set your client here here.' autocorrect='off' spellcheck='false'>
21+
22+
- serverUrl: <code class="highlighter-rouge"><span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span></code>
23+
- appId: <code class="highlighter-rouge"><span class="custom-parse-server-appid">APPLICATION_ID</span></code>
24+
- clientKey: <code class="highlighter-rouge"><span class="custom-parse-server-clientkey">CLIENT_KEY</span></code>

_includes/embedded_c/cloud-code.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ void myCloudFunctionCallback(ParseClient client, int error, int httpStatus, cons
2020
// httpResponseBody holds the Cloud Function response
2121
}
2222
}
23-
parseSendRequest(client, "POST", "/1/functions/hello", "{\"value\":\"echo\"}", myCloudFunctionCallback);
23+
parseSendRequest(client, "POST", "/parse/functions/hello", "{\"value\":\"echo\"}", myCloudFunctionCallback);
2424
```

_includes/embedded_c/requests.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The main way you'll be interacting with Parse is through the `parseSendRequest` function, which sends a request to the REST API. For example, here's how to save an object with some data:
44

55
```cpp
6-
char data[] = "{ \"temperature\": 165 }"; parseSendRequest(client, "POST", "/1/classes/Temperature", data, NULL);
6+
char data[] = "{ \"temperature\": 165 }"; parseSendRequest(client, "POST", "/parse/classes/Temperature", data, NULL);
77
```
88

99
For some requests you will be interested in data returned for the request. In such a case you need to setup a callback and pass it to `parseSendRequest`.
@@ -15,7 +15,7 @@ void mySaveCallback(ParseClient client, int error, int httpStatus, const char* h
1515
}
1616
}
1717

18-
parseSendRequest(client, "GET", "/1/classes/TestObject/gsMHOY3MAx", NULL, myCallback);
18+
parseSendRequest(client, "GET", "/parse/classes/TestObject/gsMHOY3MAx", NULL, myCallback);
1919
```
2020
2121
Using this function, you have full access to the REST API to create objects, delete objects, send analytics events, and more. Take a look at the [REST API Guide]({{ site.baseUrl }}/rest/guide) to find out all the details.

_includes/ios/push-notifications.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ curl -X GET \
875875
-G \
876876
--data-urlencode 'limit=1000' \
877877
--data-urlencode 'where={ "city": "San Francisco", "deviceType": { "$in": [ "ios", "android", "winphone", "embedded" ] } }' \
878-
https://api.parse.com/1/installations
878+
https://YOUR.PARSE-SERVER.HERE/parse/installations
879879
</code></pre>
880880

881881
If you type the above into a console, you should be able to see the first 1,000 objects that match your query. Note that constraints are always ANDed, so if you want to further reduce the search scope, you can add a constraint that matches the specific installation for your device:
@@ -888,7 +888,7 @@ curl -X GET \
888888
-G \
889889
--data-urlencode 'limit=1' \
890890
--data-urlencode 'where={ “objectId”: {YOUR_INSTALLATION_OBJECT_ID}, "city": "San Francisco", "deviceType": { "$in": [ "ios", "android", "winphone", "embedded" ] } }' \
891-
https://api.parse.com/1/installations
891+
https://YOUR.PARSE-SERVER.HERE/parse/installations
892892
</code></pre>
893893

894894
If the above query returns no results, it is likely that your installation does not meet the targeting criteria for your campaign.

0 commit comments

Comments
 (0)