Skip to content

Commit 9711ff1

Browse files
committed
Features:
image transformation Changes: deprecated .findOne() from Query deprecated .includeSchema() from Query
1 parent adcdf80 commit 9711ff1

37 files changed

+5913
-5056
lines changed

config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const config = {
2-
protocol: "https",
2+
protocol: "https",
33
host: "cdn.contentstack.io",
44
port: 443,
55
version: "v3",
@@ -9,6 +9,6 @@ const config = {
99
assets: "/assets/",
1010
environments: "/environments/"
1111
}
12-
};
12+
};
1313

14-
export default config;
14+
export default config;

csio-templates/tmpl/layout.tmpl

+114-36
Original file line numberDiff line numberDiff line change
@@ -30,42 +30,120 @@
3030
<?js if (title != 'Home') { ?>
3131
<h1 class="page-title"><?js= title ?></h1>
3232
<?js } else { ?>
33-
<h1 class="page-title">Built.io Contentstack - Javascript SDK</h1>
33+
<h1 class="page-title">Contentstack - Javascript SDK</h1>
3434
<div id="installation" class="group">
35-
<h2>Overview</h2>
36-
<p>Built.io Contentstack is a content management system that facilitates the process of publication by separating the content from site-related programming and design.</p>
37-
<h2 class="first-header ">Installation</h2>
38-
<div id="install_and_configure" class="subgroup">
39-
<h3>For Node.js</h3>
40-
<p>You need to install <a href="http://nodejs.org/" target="_blank">node.js</a> v4.8.4 or later to use the Built.io Contentstack SDK.</p>
41-
<ol>
42-
<li>
43-
Run this command in a Terminal or Command Prompt&nbsp;to&nbsp;obtain and install the latest&nbsp;version of the&nbsp;Javascript SDK on your system.
44-
<pre class=" hljs coffeescript">$ <span class="hljs-built_in">npm</span> install contentstack</pre>
45-
<span class="imp-note">Note:</span> You might need administrator privileges to perform this installation.
46-
</li>
47-
<li>
48-
To&nbsp;require the SDK module in your application use the following command.
49-
<pre class=" hljs coffeescript"><span class="hljs-reserved">var</span> contentstack = <span class="hljs-built_in">require</span>(<span class="hljs-string">'contentstack'</span>);</pre>
50-
</li>
51-
</ol>
52-
<h3>For web browsers</h3>
53-
<ol>
54-
<li>Download the latest version of the Built.io Contentstack Javascript SDK from <a href="/sdk/js/contentstack.zip" target="_blank">here</a>.</li>
55-
<li>
56-
Extract the zip package to get the <strong>contentstack.min.js</strong> file, and include it in a script tag as shown below.
57-
<pre class=" hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">script</span> <span class="hljs-attribute">type</span>=<span class="hljs-value">"text/javascript"</span> <span class="hljs-attribute">src</span>=<span class="hljs-value">"contentstack.min.js"</span>&gt;</span><span class="javascript"></span><span class="hljs-tag">&lt;/<span class="hljs-title">script</span>&gt;</span></pre>
58-
</li>
59-
</ol>
60-
<h3>Initalize the Stack</h3>
61-
<p>
62-
<strong>Built.io Contentstack</strong><strong>&nbsp;object</strong> would be available for use, as shown below.
63-
<pre class=" hljs coffeescript"><span class="hljs-reserved">var</span> Stack = Contentstack.Stack({
64-
<span class="hljs-string">"api_key"</span>: <span class="hljs-string">"blt123456789000000"</span>,
65-
<span class="hljs-string">"access_token"</span>: <span class="hljs-string">"bltqwertyuiop1234"</span>,
66-
<span class="hljs-string">"environment"</span>: <span class="hljs-string">"development"</span>
67-
});</pre>
68-
</p>
35+
<h2><a id="JavaScript_SDK_for_Contentstack_1"></a>JavaScript SDK for Contentstack</h2>
36+
<p>Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. <a href="https://www.contentstack.com/">Read More</a>.</p>
37+
<p>Contentstack provides JavaScript SDK to build application on top of JavaScript. Given below is the detailed guide and helpful resources to get started with our JavaScript SDK.</p>
38+
<p>The JavaScript SDK can also be used to create Node.js and React native applications.</p>
39+
<h3><a id="Prerequisite_9"></a>Prerequisite</h3>
40+
<p>You need Node.js version 4.4.7 or later installed to use the Contentstack JavaScript SDK.</p>
41+
<h3><a id="Setup_and_Installation_13"></a>Setup and Installation</h3>
42+
<h4><a id="For_JavaScript_Browser_15"></a>For JavaScript (Browser)</h4>
43+
<p>To use the JavaScript SDK, download it from <a href="https://contentstack.com/docs/platforms/javascript-browser/javascript_sdk_latest">here</a> and include it in the &lt;script&gt; tag:</p>
44+
<pre><code>&lt;script type="text/javascript" src="/path/to/contentstack.min.js"&gt;&lt;/script&gt;;
45+
</code></pre>
46+
<p>To initialize the SDK, you will need to specify the API Key, Access Token, and Environment Name of your stack.</p>
47+
<pre><code>const Stack = Contentstack.Stack("api_key", "access_token", "environment_name");
48+
</code></pre>
49+
<h4><a id="For_Nodejs_25"></a>For Node.js</h4>
50+
<p>Node.js uses the Javascript SDK to create apps. To use the JavaScript SDK, download it from <a href="https://contentstack.com/docs/platforms/javascript-browser/javascript_sdk_latest">here</a>, OR install it via npm:</p>
51+
<pre><code>npm -i contentstack
52+
</code></pre>
53+
<p>To import the SDK in your project, use the following command:</p>
54+
<pre><code>import contentstack from ‘contentstack’
55+
</code></pre>
56+
<p>To initialize the SDK, you will need to specify the API Key, Access Token, and Environment Name of your stack.</p>
57+
<pre><code>const Stack = Contentstack.Stack("api_key","access_token","environment_name");
58+
</code></pre>
59+
<h4><a id="For_React_Native_39"></a>For React Native</h4>
60+
<p>React Native uses the Javascript SDK to create apps. To use the JavaScript SDK, download it from <a href="https://contentstack.com/docs/platforms/javascript-browser/javascript_sdk_latest">here</a>, OR install ist via npm:</p>
61+
<pre><code>npm -i contentstack
62+
</code></pre>
63+
<p>To import the SDK in your project, use the following command:</p>
64+
<pre><code>import contentstack from `contentstack/react-native`
65+
</code></pre>
66+
<p>To initialize the SDK, you will need to specify the API Key, Access Token, and Environment Name of your stack.</p>
67+
<pre><code>const Stack = Contentstack.Stack("api_key", "access_token", "environment_name");
68+
</code></pre>
69+
<h3><a id="Key_Concepts_for_using_Contentstack_54"></a>Key Concepts for using Contentstack</h3>
70+
<h4><a id="Stack_56"></a>Stack</h4>
71+
<p>A stack is like a container that holds the content of your app. Learn more about <a href="https://www.contentstack.com/docs/guide/stack">Stacks</a>.</p>
72+
<h4><a id="Content_Type_60"></a>Content Type</h4>
73+
<p>Content type lets you define the structure or blueprint of a page or a section of your digital property. It is a form-like page that gives Content Managers an interface to input and upload content. <a href="https://www.contentstack.com/docs/guide/content-types">Read more</a>.</p>
74+
<h4><a id="Entry_64"></a>Entry</h4>
75+
<p>An entry is the actual piece of content created using one of the defined content types. Learn more about <a href="https://www.contentstack.com/docs/guide/content-management#working-with-entries">Entries</a>.</p>
76+
<h4><a id="Asset_68"></a>Asset</h4>
77+
<p>Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded to Contentstack. These files can be used in multiple entries. Read more about <a href="https://www.contentstack.com/docs/guide/content-management#working-with-assets">Assets</a>.</p>
78+
<h4><a id="Environment_72"></a>Environment</h4>
79+
<p>A publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published. Learn how to work with <a href="https://www.contentstack.com/docs/guide/environments">Environments</a>.</p>
80+
<h3><a id="Contentstack_JavaScript_SDK_5minute_Quickstart_78"></a>Contentstack JavaScript SDK: 5-minute Quickstart</h3>
81+
<h4><a id="Initializing_your_SDK_80"></a>Initializing your SDK</h4>
82+
<p>You will need to specify the API key, Access token, and Environment Name of your stack to initialize the SDK:</p>
83+
<pre><code>const Stack = Contentstack.Stack("api_key", "access_token", "environment_name");
84+
</code></pre>
85+
<p>Once you have initialized the SDK, you can start getting content in your app.</p>
86+
<h4><a id="Querying_content_from_your_stack_90"></a>Querying content from your stack</h4>
87+
<p>To get a single entry, you need to specify the content type as well as the ID of the entry.</p>
88+
<pre><code>const Query = Stack.ContentType('blog').Entry("blt123something");
89+
90+
Query.fetch()
91+
.then(function success(entry) {
92+
console.log(entry.get('title')); // Retrieve field value by providing a field's uid
93+
console.log(entry.toJSON()); // Convert the entry result object to JSON
94+
}, function error(err) {
95+
// err object
96+
});
97+
</code></pre>
98+
<p>To retrieve multiple entries of a content type, you need to specify the content type uid. You can also specify search parameters to filter results.</p>
99+
<pre><code>const Query = Stack.ContentType('blog').Query();
100+
101+
Query
102+
.where("title", "welcome")
103+
.includeSchema()
104+
.includeCount()
105+
.toJSON()
106+
.find()
107+
.then(function success(result) {
108+
// result is array where -
109+
// result[0] =&amp;gt; entry objects
110+
// result[result.length-1] =&amp;gt; entry objects count included only when .includeCount() is queried.
111+
// result[1] =&amp;gt; schema of the content type is included when .includeSchema() is queried.
112+
}, function error(err) {
113+
// err object
114+
});
115+
</code></pre>
116+
<h4><a id="Cache_Policies_123"></a>Cache Policies</h4>
117+
<p>You can set a cache policy on a stack and/or query object.</p>
118+
<h5><a id="Setting_a_cache_policy_on_a_stack_127"></a>Setting a cache policy on a stack</h5>
119+
<p>This option allows you to globalize a cache policy. This means the cache policy you set will be applied to all the query objects of the stack.</p>
120+
<pre><code>//Setting a cache policy on a stack
121+
Stack.setCachePolicy(Contentstack.CachePolicy.NETWORK_ELSE_CACHE)
122+
</code></pre>
123+
<h5><a id="Setting_a_cache_policy_on_a_query_object_134"></a>Setting a cache policy on a query object</h5>
124+
<p>This option allows you to set/override a cache policy on a specific query object.</p>
125+
<pre><code>// setting a cache policy on a queryobject
126+
Query.setCachePolicy(Contentstack.CachePolicy.CACHE_THEN_NETWORK)
127+
</code></pre>
128+
<h3><a id="Advanced_Queries_141"></a>Advanced Queries</h3>
129+
<p>You can query for content types, entries, assets and more using our JavaScript API Reference.</p>
130+
<p><a href="https://contentstack.com/docs/platforms/javascript-browser/api-reference">JavaScript API Reference Doc</a></p>
131+
<h3><a id="Working_with_Images_147"></a>Working with Images</h3>
132+
<p>We have introduced Image Delivery APIs that let you retrieve images and then manipulate and optimize them for your digital properties. It lets you perform a host of other actions such as crop, trim, resize, rotate, overlay, and so on.</p>
133+
<p>For example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query parameters at the end of the image URL, such as, <a href="https://images.contentstack.io/v3/assets/blteae40eb499811073/bltc5064f36b5855343/59e0c41ac0eddd140d5a8e3e/download?crop=300,400">https://images.contentstack.io/v3/assets/blteae40eb499811073/bltc5064f36b5855343/59e0c41ac0eddd140d5a8e3e/download?crop=300,400</a>. There are several more parameters that you can use for your images.</p>
134+
<p><a href="https://www.contentstack.com/docs/apis/image-delivery-api/">Read Image Delivery API documentation</a>.</p>
135+
<p>SDK functions for Image Delivery API coming soon.</p>
136+
<h3><a id="Helpful_Links_157"></a>Helpful Links</h3>
137+
<ul>
138+
<li><a href="https://www.contentstack.com">Contentstack Website</a></li>
139+
<li><a href="https://contentstack.com/docs">Official Documentation</a></li>
140+
<li><a href="https://contentstack.com/docs/apis/content-delivery-api/">Content Delivery API Docs</a></li>
141+
</ul>
142+
<h3><a id="The_MIT_License_MIT_163"></a>The MIT License (MIT)</h3>
143+
<p>Copyright © 2012-2017 <a href="https://www.built.io/">Built.io</a>. All Rights Reserved</p>
144+
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
145+
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
146+
<p>THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
69147
</div>
70148
</div>
71149
<?js } ?>
@@ -76,7 +154,7 @@
76154

77155
<footer>
78156
<div class="inner-content center">
79-
<span class="copy-right"><a href="mailto:[email protected]" target="_self">[email protected]</a> | Copyright © 2012-2016 Built.io. All Rights Reserved.</span>
157+
<span class="copy-right"><a href="mailto:[email protected]" target="_self">[email protected]</a> | © 2017 Contentstack. All rights reserved.</span>
80158
</div>
81159
</footer>
82160

0 commit comments

Comments
 (0)