How to use warehouse - 10 common examples

To help you get started, we’ve selected a few warehouse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hexojs / hexo / lib / models / cache.js View on Github external
module.exports = ctx => {
  const Cache = new Schema({
    _id: {type: String, required: true},
    hash: {type: String, default: ''},
    modified: {type: Number, default: Date.now() } // UnixTime
  });

  Cache.static('compareFile', function(id, hashFn, statFn) {
    const cache = this.findById(id);

    // If cache does not exist, then it must be a new file. We have to get both
    // file hash and stats.
    if (!cache) {
      return Promise.all([hashFn(id), statFn(id)]).spread((hash, stats) => this.insert({
        _id: id,
        hash,
        modified: stats.mtime.getTime()
      })).thenReturn({
github hexojs / hexo / lib / models / post_asset.js View on Github external
module.exports = ctx => {
  const PostAsset = new Schema({
    _id: {type: String, required: true},
    slug: {type: String, required: true},
    modified: {type: Boolean, default: true},
    post: {type: Schema.Types.CUID, ref: 'Post'},
    renderable: {type: Boolean, default: true}
  });

  PostAsset.virtual('path').get(function() {
    const Post = ctx.model('Post');
    const post = Post.findById(this.post);
    if (!post) return;

    // PostAsset.path is file path relative to `public_dir`
    // no need to urlescape, #1562
    // strip /\.html?$/ extensions on permalink, #2134
    return pathFn.join(_.replace(post.path, /\.html?$/, ''), this.slug);
github pypa / warehouse / warehouse / static / js / warehouse / index.js View on Github external
// Human-readable timestamps for project histories
docReady(() => {
  timeAgo();
});

// toggle search panel behavior
docReady(() => {
  if (document.querySelector(".-js-add-filter")) searchFilterToggle();
});

// Kick off the client side HTML includes.
docReady(HTMLInclude);

// Trigger our analytics code.
docReady(Analytics);

// Handle the JS based automatic form submission.
docReady(formUtils.submitTriggers);
docReady(formUtils.registerFormValidation);

docReady(Statuspage);

// Copy handler for copy tooltips, e.g.
//   - the pip command on package detail page
//   - the copy hash on package detail page
//   - the copy hash on release maintainers page
docReady(() => {
  let setCopiedTooltip = (e) => {
    e.trigger.setAttribute("data-tooltip-label", "Copied!");
    e.trigger.setAttribute("role", "alert");
    e.clearSelection();
github pypa / warehouse / warehouse / static / js / warehouse / index.js View on Github external
};

// Bind the dropdowns when the page is ready
docReady(bindDropdowns);

// Get modal keypress event listeners ready
docReady(BindModalKeys);

// Get filter pane keypress event listeners ready
docReady(BindFilterKeys);

// Get WebAuthn compatibility checks ready
docReady(GuardWebAuthn);

// Get WebAuthn provisioning ready
docReady(ProvisionWebAuthn);

// Get WebAuthn authentication ready
docReady(AuthenticateWebAuthn);

docReady(() => {
  const tokenSelect = document.getElementById("token_scope");

  if (tokenSelect === null) {
    return;
  }

  tokenSelect.addEventListener("change", () => {
    const tokenScopeWarning = document.getElementById("api-token-scope-warning");
    if (tokenScopeWarning === null) {
      return;
    }
github pypa / warehouse / warehouse / static / js / warehouse / index.js View on Github external
// toggle search panel behavior
docReady(() => {
  if (document.querySelector(".-js-add-filter")) searchFilterToggle();
});

// Kick off the client side HTML includes.
docReady(HTMLInclude);

// Trigger our analytics code.
docReady(Analytics);

// Handle the JS based automatic form submission.
docReady(formUtils.submitTriggers);
docReady(formUtils.registerFormValidation);

docReady(Statuspage);

// Copy handler for copy tooltips, e.g.
//   - the pip command on package detail page
//   - the copy hash on package detail page
//   - the copy hash on release maintainers page
docReady(() => {
  let setCopiedTooltip = (e) => {
    e.trigger.setAttribute("data-tooltip-label", "Copied!");
    e.trigger.setAttribute("role", "alert");
    e.clearSelection();
  };

  new Clipboard(".copy-tooltip").on("success", setCopiedTooltip);

  let setOriginalLabel = (element) => {
    element.setAttribute("data-tooltip-label", "Copy to clipboard");
github pypa / warehouse / warehouse / static / js / warehouse / index.js View on Github external
trigger.dataset.dropdownBound = true;
    }
  }
};

// Bind the dropdowns when the page is ready
docReady(bindDropdowns);

// Get modal keypress event listeners ready
docReady(BindModalKeys);

// Get filter pane keypress event listeners ready
docReady(BindFilterKeys);

// Get WebAuthn compatibility checks ready
docReady(GuardWebAuthn);

// Get WebAuthn provisioning ready
docReady(ProvisionWebAuthn);

// Get WebAuthn authentication ready
docReady(AuthenticateWebAuthn);

docReady(() => {
  const tokenSelect = document.getElementById("token_scope");

  if (tokenSelect === null) {
    return;
  }

  tokenSelect.addEventListener("change", () => {
    const tokenScopeWarning = document.getElementById("api-token-scope-warning");
github pypa / warehouse / warehouse / static / js / warehouse / index.js View on Github external
closeDropdown();
        }
      });

      // Set the 'data-dropdownBound' attribute so we don't bind multiple
      // handlers to the same trigger after the client-side-includes load
      trigger.dataset.dropdownBound = true;
    }
  }
};

// Bind the dropdowns when the page is ready
docReady(bindDropdowns);

// Get modal keypress event listeners ready
docReady(BindModalKeys);

// Get filter pane keypress event listeners ready
docReady(BindFilterKeys);

// Get WebAuthn compatibility checks ready
docReady(GuardWebAuthn);

// Get WebAuthn provisioning ready
docReady(ProvisionWebAuthn);

// Get WebAuthn authentication ready
docReady(AuthenticateWebAuthn);

docReady(() => {
  const tokenSelect = document.getElementById("token_scope");
github pypa / warehouse / warehouse / static / js / warehouse / index.js View on Github external
});

// toggle search panel behavior
docReady(() => {
  if (document.querySelector(".-js-add-filter")) searchFilterToggle();
});

// Kick off the client side HTML includes.
docReady(HTMLInclude);

// Trigger our analytics code.
docReady(Analytics);

// Handle the JS based automatic form submission.
docReady(formUtils.submitTriggers);
docReady(formUtils.registerFormValidation);

docReady(Statuspage);

// Copy handler for copy tooltips, e.g.
//   - the pip command on package detail page
//   - the copy hash on package detail page
//   - the copy hash on release maintainers page
docReady(() => {
  let setCopiedTooltip = (e) => {
    e.trigger.setAttribute("data-tooltip-label", "Copied!");
    e.trigger.setAttribute("role", "alert");
    e.clearSelection();
  };

  new Clipboard(".copy-tooltip").on("success", setCopiedTooltip);
github pypa / warehouse / warehouse / static / js / warehouse / index.js View on Github external
timeAgo();
});

// toggle search panel behavior
docReady(() => {
  if (document.querySelector(".-js-add-filter")) searchFilterToggle();
});

// Kick off the client side HTML includes.
docReady(HTMLInclude);

// Trigger our analytics code.
docReady(Analytics);

// Handle the JS based automatic form submission.
docReady(formUtils.submitTriggers);
docReady(formUtils.registerFormValidation);

docReady(Statuspage);

// Copy handler for copy tooltips, e.g.
//   - the pip command on package detail page
//   - the copy hash on package detail page
//   - the copy hash on release maintainers page
docReady(() => {
  let setCopiedTooltip = (e) => {
    e.trigger.setAttribute("data-tooltip-label", "Copied!");
    e.trigger.setAttribute("role", "alert");
    e.clearSelection();
  };

  new Clipboard(".copy-tooltip").on("success", setCopiedTooltip);
github pypa / warehouse / warehouse / static / js / warehouse / index.js View on Github external
document.getElementById("sticky-notifications").appendChild(warning_div);
  }
});

// Human-readable timestamps for project histories
docReady(() => {
  timeAgo();
});

// toggle search panel behavior
docReady(() => {
  if (document.querySelector(".-js-add-filter")) searchFilterToggle();
});

// Kick off the client side HTML includes.
docReady(HTMLInclude);

// Trigger our analytics code.
docReady(Analytics);

// Handle the JS based automatic form submission.
docReady(formUtils.submitTriggers);
docReady(formUtils.registerFormValidation);

docReady(Statuspage);

// Copy handler for copy tooltips, e.g.
//   - the pip command on package detail page
//   - the copy hash on package detail page
//   - the copy hash on release maintainers page
docReady(() => {
  let setCopiedTooltip = (e) => {